Dear all.

I am trying to describe the Huber loss as below by myself.

Instantiating by loss=huber_loss(delta=0.5), and calling it by loss(a,b),

the code seems to work as I intend but I am not sure the way to describe

is correct or not. What I want to know is how to tell the delta to the class

function. Is this correct?

##
Thank you

Yu

##
class huber_loss(tf.keras.losses.Loss):

def **init**(self,delta):

self.delta=delta

super(huber_loss,self).**init**()

def call(self,y_true,y_pred):

a=tf.where(tf.abs(y_pred-y_true)<self.delta,

0.5*(y_pred-y_true)**2,**

0.5*self.delta2+self.delta*(tf.abs(y_pred-y_true)-self.delta))

return tf.math.reduce_mean(a)

0.5*self.delta