【发布时间】:2021-06-09 14:11:22
【问题描述】:
我创建了一个neural network 来提取方面、情绪或修饰符。你可以在下面找到我的代码。我用它获得了大约 62% 的 F1 分数,但我不知道为什么它给了我如此糟糕的结果。您对如何改进我的模型和 f1 分数有什么建议吗?目前包括 Glove 100d、tensorflow、keras、python 3.7。
model = Sequential()
model.add(Embedding(vocab_size, 100, weights=[embedding_vectors], input_length=max_seq_length,
trainable= False))
model.add(Conv1D(1000, 1, activation=LeakyReLU(alpha=0.1)))
model.add(Conv1D(200, 1, activation=LeakyReLU(alpha=0.1)))
model.add(Dropout(0.2))
model.add(Bidirectional(LSTM(units=100, dropout = 0.5, recurrent_dropout = 0.5,
return_sequences=True, kernel_regularizer=regularizers.l2(0.000001))))
model.add(Dropout(0.5))
model.add(TimeDistributed(Dense(512, activation=LeakyReLU(alpha=0.1))))
model.add(Dense(n_tags, activation='softmax'))
opt = RMSprop(learning_rate=0.0008)
model.compile(loss="categorical_crossentropy", optimizer=opt, metrics=["categorical_accuracy"])
model.summary()
# fit model on train data
model.fit(x_train, y_train,
batch_size=32,
epochs=10)
【问题讨论】:
标签: tensorflow keras lstm recurrent-neural-network text-classification