【发布时间】:2017-05-25 16:39:59
【问题描述】:
在 CNTK 中 - 如何在同一层上使用多个过滤器尺寸(例如过滤器尺寸 2、3、4、5)?
在完成here 的工作之后(链接到下面github中的代码(1)),我想获取文本,使用嵌入层,应用四种不同大小的过滤器(2,3,4,5),连接结果并将其馈送到全连接层。 Network architecture figure
Keras 示例代码:
main_input = Input(shape=(100,)
embedding = Embedding(output_dim=32, input_dim=100, input_length=100, dropout=0)(main_input)
conv1 = getconvmodel(2,256)(embedding)
conv2 = getconvmodel(3,256)(embedding)
conv3 = getconvmodel(4,256)(embedding)
conv4 = getconvmodel(5,256)(embedding)
merged = merge([conv1,conv2,conv3,conv4],mode="concat")
def getconvmodel(filter_length,nb_filter):
model = Sequential()
model.add(Convolution1D(nb_filter=nb_filter,
`enter code here`input_shape=(100,32),
filter_length=filter_length,
border_mode='same',
activation='relu',
subsample_length=1))
model.add(Lambda(sum_1d, output_shape=(nb_filter,)))
#model.add(BatchNormalization(mode=0))
model.add(Dropout(0.5))
return model
(1): /joshsaxe/eXposeDeepNeuralNetwork/blob/master/src/modeling/models.py
【问题讨论】:
标签: cntk