0

我处理 的数据Facebook Babi Task,并在将模型与 LSTM 一起使用之后(在此 github https://github.com/fchollet/keras/blob/master/examples/babi_rnn.py上定义)。现在我想用一个带有卷积和 Maxpooling 的模型来学习。但是性能很低,我想知道是否有人有改进它的想法。

embed_size = 50
batch_size=32
epochs=60
kernel_size = 3
pool_size = 2
strid = 1

story_model2 = Sequential()
    # input layers and convolutional layers
story_model2.add(Embedding(vocab_size,embed_size,input_length=story_max))
story_model2.add(Conv1D(embed_size, kernel_size=kernel_size, strides=strid, padding='valid', activation='relu'))
story_model2.add(MaxPooling1D(pool_size=pool_size))
story_model2.add(Dropout(.5))
story_model2.summary()


question_model2 = Sequential()
    # input layers and convolutional layers
question_model2.add(Embedding(vocab_size,embed_size,input_length=question_max))
question_model2.add(Conv1D(embed_size, kernel_size=kernel_size, strides=strid, padding='valid', activation='relu'))
question_model2.add(MaxPooling1D(pool_size=pool_size))
question_model2.add(Dropout(.5))
question_model2.summary()


mergedOut = Add()([story_model2.output,question_model2.output])
mergedOut = Flatten()(mergedOut)    
mergedOut = Dropout(.5)(mergedOut)
mergedOut = Dense(vocab_size, activation='relu')(mergedOut)
mergedOut = Dense(vocab_size, activation='softmax')(mergedOut)

newModel = Model([story_model2.input,question_model2.input], mergedOut)
newModel.compile(optimizer=Adam(lr=0.01),loss='categorical_crossentropy',metrics=['accuracy'])
newModel.fit([X, Xq], Y, batch_size=batch_size, epochs=epochs)

学习的acc值降低

Epoch 1/60
1000/1000 [==============================] - 3s 3ms/step - loss: 2.0393 - acc: 0.1710
Epoch 2/60
1000/1000 [==============================] - 0s 452us/step - loss: 1.7408 - acc: 0.2420
Epoch 3/60
1000/1000 [==============================] - 0s 341us/step - loss: 1.6526 - acc: 0.3020
Epoch 4/60
1000/1000 [==============================] - 1s 529us/step - loss: 1.6301 - acc: 0.3400
Epoch 5/60
1000/1000 [==============================] - 1s 629us/step - loss: 1.5853 - acc: 0.3420
Epoch 6/60
1000/1000 [==============================] - 0s 474us/step - loss: 1.5693 - acc: 0.3630
Epoch 7/60
1000/1000 [==============================] - 0s 401us/step - loss: 1.5620 - acc: 0.3440
Epoch 8/60
1000/1000 [==============================] - 1s 966us/step - loss: 1.5468 - acc: 0.3540
Epoch 9/60
1000/1000 [==============================] - 0s 458us/step - loss: 1.4980 - acc: 0.3870
Epoch 10/60
1000/1000 [==============================] - 0s 428us/step - loss: 1.5259 - acc: 0.3700
Epoch 11/60
1000/1000 [==============================] - 0s 378us/step - loss: 1.5112 - acc: 0.3760
Epoch 12/60
1000/1000 [==============================] - 0s 374us/step - loss: 1.4929 - acc: 0.3810
....

我的模型作为性能返回:

1000/1000 [==============================] - 1s 1ms/step
Perte =  1.54148875618
Précision =  0.342
4

1 回答 1

0

你的辍学率可能太高了。尝试不使用它,只是为了比较。

于 2019-05-23T17:28:41.340 回答