首页 > 解决方案 > 如何提高 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)

型号总结:

标签: pythontensorflowkeraslstmrecurrent-neural-network

解决方案


推荐阅读