【发布时间】:2020-09-15 08:28:04
【问题描述】:
我正在研究 2017 年任务 4A dataset can be found here 的分类问题 我正在使用深度 LSTM 网络。在预处理中,我做了小写->分词->词形还原->去除停用词->去除标点符号。对于词嵌入,我使用了 WORD2VEC 模型。我的训练集中有 18,000 个样本,测试中有 2000 个样本。
我的模型的代码是
model = Sequential()
model.add(Embedding(max_words, 30, input_length=max_len))
model.add(BatchNormalization())
model.add(Activation('tanh'))
model.add(Dropout(0.3))
model.add(Bidirectional(LSTM(32, use_bias=True, return_sequences=True)))
model.add(BatchNormalization())
model.add(Activation('tanh'))
model.add(Dropout(0.5))
model.add(Bidirectional(LSTM(32, use_bias=True, return_sequences=True), input_shape=(128, 1,64)))
model.add(BatchNormalization())
model.add(Activation('tanh'))
model.add(SeqSelfAttention(attention_activation='sigmoid'))
model.add(Dense(1, activation='sigmoid'))
model.summary()
max_words 的值为 2000,max_len 为 300
但即使在这之后,我的测试准确率也没有超过 50%。我无法弄清楚问题所在。 PS - 我也在使用验证技术。损失函数是“Binary Crossentropy”,优化器是“Adam”。
【问题讨论】:
-
你用的是什么损失函数?
-
@alift 二元交叉熵和优化器是 Adam
-
训练样例的准确率是多少?如果它也接近 50%,您可能会遭受欠拟合
-
@alift 训练准确率从 30-35% 逐渐提高到 50%。所以你可能是正确的,模型是欠拟合的。但是,我也尝试将 LSTM 层从 32 增加到 64,但这只会增加计算时间,而不会影响准确性。
-
你有多少数据?你可能还不够。如果是这样的话,让你的模型变大会使问题变得更糟。在放大模型之前,我会减少 dropout。
标签: tensorflow keras neural-network nlp lstm