kyzhouhzau / BERT-NER

Use Google's BERT for named entity recognition (CoNLL-2003 as the dataset).
MIT License
1.23k stars 335 forks source link

eval_metric_ops[confusion_matrix] must be Operation or Tensor #82

Open jeicy07 opened 4 years ago

jeicy07 commented 4 years ago

When the code is doing the evaluation, there is an error when returning the evaluation result : result = estimator.evaluate(input_fn=eval_input_fn). Detailed error is probably related to the confusion matrix. It says that: TypeError: eval_metric_ops[confusion_matrix] must be Operation or Tensor, given: <tf.Variable 'total_confusion_matrix:0' shape=(12, 12) dtype=float64_ref> my tensorflow's version is 1.11.0

chuanzhizh commented 4 years ago

When the code is doing the evaluation, there is an error when returning the evaluation result : result = estimator.evaluate(input_fn=eval_input_fn). Detailed error is probably related to the confusion matrix. It says that: TypeError: eval_metric_ops[confusion_matrix] must be Operation or Tensor, given: <tf.Variable 'total_confusion_matrix:0' shape=(12, 12) dtype=float64_ref> my tensorflow's version is 1.11.0

hi, is the problem solved?

chuanzhizh commented 4 years ago

the earlier version of my tensorflow is 1.10.0 python3.5, when I update my tensorflow to 1.15.0 and python to 3.6, the problem solved

jeicy07 commented 4 years ago

the earlier version of my tensorflow is 1.10.0 python3.5, when I update my tensorflow to 1.15.0 and python to 3.6, the problem solved

hi, I didn't update my tensorflow. I just revised return (total_cm, update_op) at the end of function _streaming_confusionmatrix in metrics.py to return (total_cm.read_value(), update_op).