I'm trying to use my own loss function in Keras. In particular, being y_pred the predicted vector and y_true the true vector, i want that:
y_pred[i] = y_pred[i] if y_true[i] != 0
y_pred[i] = 0 if y_true[i] == 0
so I've tried the following:
def myloss(y_true, y_pred):
mask = K.not_equal(y_true, 0)
mask = K.cast(mask, dtype = 'float32')
loss_value = K.mean(K.square(mask*y_pred - y_true), axis = 1)
return loss_value
but I'm getting this error:
TypeError: Value passed to parameter 'x' has DataType bool not in list of allowed values: bfloat16, float16, float32, float64, uint8, int8, uint16, int16, int32, int64, complex64, complex128
Someone knows how to help me?