I need a custom loss functions in Keras for a regression problem. I have to predict two values (y1, y2) but I want to penalize the error if:
if y1_pred > v1 and y1_true < v1:
or
if y2_pred < v2 and y2_true > v2:
I need something similar to:
if y1_pred > v1 and y1_true < v1:
p = 1 + (k * (y1_pred-y1_true))
K.mean(K.square(y1_pred-y1_true) * p)
else:
K.mean(K.square(y1_pred-y1_true))
if y2_pred < v2 and y2_true > v2:
p = 1 + (k * (y2_true-y2_pred))
K.mean(K.square(y2_pred-y2_true) * p)
else:
K.mean(K.square(y2_pred-y2_true))
v1, v2 and k are constants.