how to implement hamming loss as a custom metric in keras model
I have a multilabel classification with 6 classes
model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy',hamming_loss])
I tried using
from sklearn.metrics import hamming_loss
def custom_hl(y_true, y_pred):
return hamming_loss(y_true, y_pred)
which doesn't work because i have the y_true , y_pred as follow
YTRUE
Tensor("Cast_10:0", shape=(None, 6), dtype=float32)
YPRED
Tensor("model_1/dense_1/Sigmoid:0", shape=(None, 6), dtype=float32)
also tried the function in this question and it doesn't work Getting the accuracy for multi-label prediction in scikit-learn is there any way I can get the hamming loss as metric in keras thanks for any help