提交 f8c0fb44 编写于 作者: X Xiangci Li 提交者: Meiyim

Fixed errors when only evaluating the fine-tuned model for sequence labeling.

上级 92449c63
......@@ -109,6 +109,11 @@ def create_model(args, pyreader_name, ernie_config, is_prediction=False):
def calculate_f1(num_label, num_infer, num_correct):
num_infer = np.sum(num_infer)
num_label = np.sum(num_label)
num_correct = np.sum(num_correct)
if num_infer == 0:
precision = 0.0
else:
......
......@@ -289,10 +289,14 @@ def main(args):
# final eval on dev set
if nccl2_trainer_id ==0 and args.do_val:
if not args.do_train:
current_example, current_epoch = reader.get_train_progress()
evaluate_wrapper(reader, exe, test_prog, test_pyreader, graph_vars,
current_epoch, 'final')
if nccl2_trainer_id == 0 and args.do_test:
if not args.do_train:
current_example, current_epoch = reader.get_train_progress()
predict_wrapper(reader, exe, test_prog, test_pyreader, graph_vars,
current_epoch, 'final')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册