I am trying to use a custom F1 score function in Keras but my target variable is an array and I don't want to one hot encode them, so I am using sparse_categorical_crossentropy
as a loss.
from keras import backend as K
def f1(y_true, y_pred):
print(type(y_true))
return y_true
When I run the above code I am getting y_true and y_pred as <class 'tensorflow.python.framework.ops.Tensor'>
. How can we convert y_true and y_pred to NumPy array, so that I can implement sklearn's F1 score function upon them?