【发布时间】:2020-02-17 20:37:43
【问题描述】:
我已经使用 lstm 表单 https://www.kaggle.com/eray1yildiz/using-lstms-with-attention-for-emotion-recognition/comments 实现了情感分析
我的预测有误,结果列表如下所示:
['enjoy', 'lovely', 'moment']
{'joy': 0.18797465, 'satisfied': 0.19864388, 'happy': 0.18680806, 'sad': 0.20265724, 'disappointment': 0.22391614}
以下是我用于预测的部分代码:
# Padding
encoded_samples = keras.preprocessing.sequence.pad_sequences(encoded_samples, maxlen=max_words)
# Make predictions
label_probs, attentions = model_with_attentions.predict(encoded_samples)
label_probs = {id2label[_id]: prob for (label, _id), prob in zip(label2id.items(), label_probs[0])}
我希望我的输出是这样的:
Input: ['enjoy', 'lovely', 'moment']
Output: 'joy'
可以这样做吗?请帮帮我..
【问题讨论】:
标签: python pandas lstm probability