PaddleNLP
PaddleNLP copied to clipboard
[Question]: 在情感分析任务中,使用predict_sentence.py进行预测时,如何获取模型输出的每个类别的置信度
请提出你的问题
在情感分析任务中,使用predict_sentence.py进行预测时,如何获取每个类别的置信度 results = predict(model, data, tokenizer, label_map, batch_size=args.batch_size)
for idx, text in enumerate(data):
print('Data: {} \t Label: {}'.format(text, results[idx]))
在这results里面存储的是每个句子的标签,现在我想知道每个句子的置信度或者模型输出的概率值,怎么弄呢
你好,可以从代码中的probs获取概率值,probs是经过softmax后的数值,表达了样本归属不同情感的概率:
https://github.com/PaddlePaddle/PaddleNLP/blob/7c06b02e3161bd398e0decd439d47efd15f3feee/examples/sentiment_analysis/skep/predict_sentence.py#L124
This issue is stale because it has been open for 60 days with no activity. 当前issue 60天内无活动,被标记为stale。
This issue was closed because it has been inactive for 14 days since being marked as stale. 当前issue 被标记为stale已有14天,即将关闭。