提交 8a11a42c 编写于 作者: T tianxin04

fix pyreader return empty array as None in paddle 1.5

fix #151
paddle 1.4 does not occur this problem
上级 4650e959
......@@ -177,6 +177,8 @@ def evaluate(exe, test_program, test_pyreader, graph_vars, eval_phase):
total_acc += np.sum(np_acc * np_num_seqs)
total_num_seqs += np.sum(np_num_seqs)
labels.extend(np_labels.reshape((-1)).tolist())
if np_qids is None:
np_qids = np.array([])
qids.extend(np_qids.reshape(-1).tolist())
scores.extend(np_probs[:, 1].reshape(-1).tolist())
np_preds = np.argmax(np_probs, axis=1).astype(np.float32)
......
......@@ -238,7 +238,7 @@ class ClassifyReader(BaseReader):
batch_labels = [record.label_id for record in batch_records]
batch_labels = np.array(batch_labels).astype("int64").reshape([-1, 1])
if batch_records[0].qid:
if batch_records[0].qid is not None:
batch_qids = [record.qid for record in batch_records]
batch_qids = np.array(batch_qids).astype("int64").reshape([-1, 1])
else:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册