FBeta
class is a grandchild of ConfusionMatrix
:
(family situation: ConfusionMatrix < CMScores < FBeta
)
Both ConfusionMatrix
and FBeta
override an “on_epoch_end
” callback, which, in case of an FBeta instance, wipes out ConfusionMatrix
take on “on_epoch_end
”.
FBeta
tries to use self.metric
in its version of “on_epoch_end
”, but the only place in the hierarchy where self.metric
is created is ConfusionMatrix
's “on_epoch_end
”, which gets ignored in this case.
Hence an “FBeta does not have a metric attribute” error.
It is easier to see it in the code than to word it in English:
class ConfusionMatrix(Callback):
...
def on_epoch_end(self, **kwargs):
self.metric = self.cm # <<< this never gets created / called
# in case of FBeta instance
# ...
class CMScores(ConfusionMatrix):
# ...
class FBeta(CMScores):
# ...
def on_epoch_end(self, last_metrics, **kwargs):
# ...
# throws here since "self.metric" was not created anywhere
if self.avg: metric = (self._weights(avg=self.avg) * self.metric).sum() # <<<<
return add_metrics(last_metrics, metric)
I was going to submit a PR, but then I am not exactly sure what should go instead of self.metric
in:
if self.avg: metric = (self._weights(avg=self.avg) * self.metric).sum()
since I tried running with self.cm
which is visible, but the fbeta
score I get makes no sense