diff --git a/tensorflow_model.py b/tensorflow_model.py index 8c9229f..6cbdac4 100644 --- a/tensorflow_model.py +++ b/tensorflow_model.py @@ -490,7 +490,10 @@ def recall(self): @property def f1(self): - return 2 * self.precision * self.recall / (self.precision + self.recall) + if self.precision + self.recall == 0: + return 0 + else: + return 2 * self.precision * self.recall / (self.precision + self.recall) class TopKAccuracyEvaluationMetric: