I am trying to define my own loss function in keras which is Root Mean Squared Percentage Error. RMSPE is defined as :
I have defined my loss function as:
from keras import backend as K def rmspe(y_true, y_pred): sum = K.sqrt(K.mean(K.square( (y_true - y_pred) / K.clip(K.abs(y_true),K.epsilon(),None) ), axis=-1) ) return sum*100.
But after a few iterations it is giving me loss value as nan. Can someone point out what am i doing wrong. Thanks
When your denominator is 0, that will be Nan. Consider plus a small number on your denominator, like 0.0000001.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.