如何在大词汇量的拼写校正模型中减少过拟合?
tensorflow 313
原文标题 :How to reduce overfitting in spelling correction model with large vocab size?
我正在开发一个拼写校正系统。我的数据集包含 17,00,000 个句子,词汇量为 3,26,000。我尝试添加 GRU、LSTM 层,但不是堆叠层,而是在单层架构中增加单元,从而提高训练集的准确性。但是测试集的准确率永远不会超过 14%。我已经尝试过正则化技术来减少过度拟合,但我找不到正确的方法。这是我的代码:
def create_model(layers,learning_rate):
vocab_size = len(stemmed_dict)
model = Sequential()
model.add(Embedding(vocab_size,output_dim=200,input_length=max_sequence_len-1, trainable=True))
model.add(GRU(1024,input_shape=input_sequences.shape,recurrent_dropout=0.2,kernel_regularizer=keras.regularizers.l1(0.0001),return_sequences=False))
model.add(BatchNormalization())
model.add(Dense(layers))
model.add(Activation("softmax"))
optimizer = Adam(learning_rate)
model.compile(loss=SparseCategoricalCrossentropy(), optimizer=optimizer, metrics=['accuracy'])
print(model.summary())
return model