未验证 提交 c172c081 编写于 作者: K KP 提交者: GitHub

Merge pull request #1803 from Wgm-Inspur/PaddleHub-TextClasify-OptimizePredict-WGM

Optimizing the output of classification probablity in demo\text_classification\predict.py and corresponding README.md
...@@ -162,9 +162,9 @@ model = hub.Module( ...@@ -162,9 +162,9 @@ model = hub.Module(
task='seq-cls', task='seq-cls',
load_checkpoint='./test_ernie_text_cls/best_model/model.pdparams', load_checkpoint='./test_ernie_text_cls/best_model/model.pdparams',
label_map=label_map) label_map=label_map)
results = model.predict(data, max_seq_len=50, batch_size=1, use_gpu=False) results, probs = model.predict(data, max_seq_len=50, batch_size=1, use_gpu=False, return_prob=True)
for idx, text in enumerate(data): for idx, text in enumerate(data):
print('Data: {} \t Lable: {}'.format(text[0], results[idx])) print('Data: {} \t Lable: {} \t Prob: {}'.format(text[0], results[idx], probs[idx]))
``` ```
参数配置正确后,请执行脚本`python predict.py`, 加载模型具体可参见[加载](https://www.paddlepaddle.org.cn/documentation/docs/zh/2.0-rc/api/paddle/framework/io/load_cn.html#load) 参数配置正确后,请执行脚本`python predict.py`, 加载模型具体可参见[加载](https://www.paddlepaddle.org.cn/documentation/docs/zh/2.0-rc/api/paddle/framework/io/load_cn.html#load)
...@@ -30,4 +30,4 @@ if __name__ == '__main__': ...@@ -30,4 +30,4 @@ if __name__ == '__main__':
label_map=label_map) label_map=label_map)
results, probs = model.predict(data, max_seq_len=50, batch_size=1, use_gpu=False, return_prob=True) results, probs = model.predict(data, max_seq_len=50, batch_size=1, use_gpu=False, return_prob=True)
for idx, text in enumerate(data): for idx, text in enumerate(data):
print('Data: {} \t Lable: {}'.format(text[0], 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.
先完成此消息的编辑!
想要评论请 注册