def f1_score(precision, recall):
"""Creates an op for calculating the F1 score.
Args:
precision: A tensor representing precision.
recall: A tensor representing recall.
Returns:
A tensor with the result of the F1 calculation.
"""
return tf.where(
tf.greater(precision + recall, 0), 2 * (
(precision * recall) / (precision + recall)), 0)
评论列表
文章目录