python - 如何提高 LSTM Multiclass 文本分类准确率?
问题描述
我对机器学习比较陌生。我正在建立一个监督学习 LSTM 模型。Word2Vec 用于构建词嵌入。在 100 个 epoch 结束时,准确度非常差,仅为 0.03。
我尝试将 LSTM 神经元增加到 128 个,不同的激活函数(tanh、relu 和 softmax)。仍然没有运气。
请提出一种提高准确性的方法。
EMBEDDING_SIZE = 200
MAX_SEQUENCE_LENGTH = 200
model = Sequential()
model.add(Embedding(input_dim=num_word,
output_dim=EMBEDDING_SIZE,
input_length=MAX_SEQUENCE_LENGTH,
embeddings_initializer = Constant(embedding_matrix),
trainable=False))
model.add(LSTM(32, dropout=0.2, recurrent_dropout=0.2, kernel_regularizer=regularizers.l2(0.001)))
model.add(Dense(579, activation='tanh'))
model.compile(loss='categorical_crossentropy', optimizer='adam', metrics=['accuracy'])
print(model.summary())
num_epochs = 100
history = model.fit(X_train,
y_train,
epochs=num_epochs,
shuffle = True,
batch_size=32,
validation_data=(X_test, y_test_categorical),
verbose=2)
型号总结:
总参数:145,097,931
可训练参数:48,931
不可训练参数:145,049,000
解决方案
推荐阅读
- javascript - 更改 html 文件中的所有链接以添加域 url
- r - 使用 R 自定义字段的 trello API
- angular - 当用户离开页面时,Angular 7 会从警卫中启动一个警报组件以通知
- javascript - 如何从 JavaScript 中的 select 选项中获取相应文本的值?
- realm - 如何在 Elytron Wildfly 17 中使用 jdbc 领域对用户进行身份验证?
- mysql - 谁能帮我理解这段 SQL 代码?
- javascript - react-router-dom 链接不会将用户推送到新链接
- oracle - 根据空格将字符串拆分为 3 部分
- postgresql - 正则表达式 | 在字符串末尾添加 3 个字符
- mysql - 没有唯一值的 SQL 连接表