Custom loss function in keras returns nan loss

Viewed 483

Following is my custom loss function in keras. Both y_true and y_pred have shape (256,384,3).

def myloss(y_true,y_pred):
    diff = y_pred - y_true
    diff = diff[96:160 , 144:240]
    return K.mean(K.square(diff), axis=-1)

Here I'm slicing a portion of the difference and finding the mean_square_loss for that. However, this function is returning nan as the loss. Why is that?

0 Answers
Related