我正试图通过对韩国电影的回顾来做出正面和负面的分类。 数据已经过预处理。 预处理数据由Google驱动器共享。 通过参考示例LSTM模型进行配置。 执行时,精度仅约为0.5。 帮帮我......
此网址为train_test_dataset。 https://drive.google.com/file/d/1rnf84idV9pj72Ammu5VQ2_rNyGZIa3pU/view?usp=sharing 火车= 70000 测试=大约33000
from keras.models import Sequential
from keras.layers import Dense, Embedding,Dropout
from keras.layers import LSTM
max_features = 20000
maxlen = 300
batch_size = 32
import numpy as np
x_train = np.load('file_path')
y_train = np.load('file_path')
x_test = np.load('file_path')
y_test = np.load('file_path')
print('train_x shape:', train_x.shape)
print('test_x shape: ', test_x.shape)
print('model generate...')
model = Sequential()
model.add(Embedding(max_features, 128))
model.add(LSTM(128, dropout=0.2, recurrent_dropout=0.2))
model.add(Dense(1, activation='sigmoid'))
model.compile(loss='binary_crossentropy',
optimizer='adam',
metrics=['accuracy'])
try:
print('Train...')
model.fit(train_x, train_y,
batch_size=batch_size,
epochs=1,
validation_data=(test_x, test_y))
score, acc = model.evaluate(test_x, test_y,
batch_size=batch_size)
print('Test score:', score)
print('Test accuracy:', acc)
except Exception as e:
print(e)