提交 18e4d606 编写于 作者: W Wgm-Inspur

Revision of demo\text_classification\predict.py

上级 1d260307
......@@ -21,7 +21,6 @@ if __name__ == '__main__':
['作为老的四星酒店,房间依然很整洁,相当不错。机场接机服务很好,可以在车上办理入住手续,节省时间。'],
]
label_map = {0: 'negative', 1: 'positive'}
label_map_rev = {'negative':0, 'positive':1}
model = hub.Module(
name='ernie_tiny',
......@@ -31,4 +30,4 @@ if __name__ == '__main__':
label_map=label_map)
results, probs = model.predict(data, max_seq_len=50, batch_size=1, use_gpu=False, return_prob=True)
for idx, text in enumerate(data):
print('Data: {} \t Lable: {} \t Prob: {}'.format(text[0], results[idx], probs[idx][label_map_rev[results[idx]]]))
print('Data: {} \t Lable: {} \t Prob: {}'.format(text[0], results[idx], probs[idx]))
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册