chiphuyen / stanford-tensorflow-tutorials

This repository contains code examples for the Stanford's course: TensorFlow for Deep Learning Research.
http://cs20.stanford.edu
MIT License
10.32k stars 4.32k forks source link

04_linreg_eager issue #123

Open yikayiyo opened 6 years ago

yikayiyo commented 6 years ago

train(huber_loss) and train(tf.losses.huber_loss) have different resluts. it seems like

  def huber_loss(y, y_predicted, m=1.0):
    """Huber loss."""
    t = y - y_predicted
    return t ** 2 if tf.abs(t) <= m else m * (2 * tf.abs(t) - m)

should be

  return 0.5*t**2 if tf.abs(t) <= m else m*(tf.abs(t)-0.5*m)