netrack / keras-metrics

Metrics for Keras. DEPRECATED since Keras 2.3.0
MIT License
164 stars 23 forks source link

TypeError: 'NoneType' object is not callable #51

Closed DomenicoMessina closed 3 years ago

DomenicoMessina commented 4 years ago

I tried to customize keras-metrics, because i want to use a balanced_accuracy as metric. So i added keras-metrics in a folder of my project, but i can't modify ìt as well.
In metrics.py: def __init__(self, name=None, label=0, cast_strategy=None, **kwargs): super(layer, self).__init__(name=name, **kwargs) self.stateful = True self.label = label self.cast_strategy = cast_strategy self.epsilon = K.constant(K.epsilon(), dtype="float64")

but cast_strategy is called, there is return self.cast_strategy( y_true, y_pred, dtype=dtype, label=self.label) cast strategy is not callable! Can someone help me? I'm working for my master thesis.

ybubnov commented 4 years ago

Hi @DomenicoMessina, you should pass one of the cast strategies in order to make your code work. For example, with true_positive metric:

from keras_metrics import metrics
from keras_metrics import casts

binary_true_positive = metrics.true_positive(name="tp", cast_strategy=casts.binary)