I'm trying to create a custom loss function for my model. I have remove all numpy, and used only keras function to create my custom loss.
def kweighted_accuracy(y_true, y_pred):
y_true = tf.cast(y_true, tf.float32)
y_pred = tf.cast(y_pred, tf.float32)
y_abs = K.abs(y_true)
norm = K.sum(y_abs)
v = tf.equal(K.sign(y_pred),K.sign(y_true))
s = tf.boolean_mask(y_abs,v)
score = K.sum(s) / norm
return 1-score
Despite that I encounter the error : ValueError: No gradients provided for any variable.
I really don't understand why. Is it the tf.boolean_mask, or tf.equal which I should not use ?
Thanks for the help,
regards,
Alex