如何在大词汇量的拼写校正模型中减少过拟合?

原文标题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

原文链接:https://stackoverflow.com//questions/71994391/how-to-reduce-overfitting-in-spelling-correction-model-with-large-vocab-size

回复

我来回复
  • Nicolas Perez de Olaguer的头像
    Nicolas Perez de Olaguer 评论

    我会先复制一个在线教程或 Kaggle 比赛,然后用你的或类似的(适应特定任务)替换给定的模型。这样可以更容易地确定问题是来自您的模型架构还是您的数据或预处理(通常是这种情况,我根据您的描述进行猜测)。

    1年前 0条评论