In [1]:
import seaborn as sns
import tensorflow as tf

%matplotlib inline

In [2]:
sess = tf.Session()

Loss function for regressions


In [3]:
x_vals = tf.linspace(-1., 1., 500)
target = tf.constant(0.)

L2 norm


In [4]:
l2_y_vals = tf.square(target - x_vals)
l2_y_out = sess.run(l2_y_vals)

L1 norm


In [5]:
l1_y_vals = tf.abs(target - x_vals)
l1_y_out = sess.run(l1_y_vals)

Pseudo-Huber loss function


In [6]:
delta1 = tf.constant(0.25)

phuber1_y_vals = tf.multiply(tf.square(delta1), tf.sqrt(1. + tf.square((target - x_vals)/delta1)) - 1.)
phuber1_y_out = sess.run(phuber1_y_vals)

delta2 = tf.constant(5.)
phuber2_y_vals = tf.multiply(tf.square(delta2), tf.sqrt(1. + tf.square((target - x_vals)/delta2)) - 1.)
phuber2_y_out = sess.run(phuber2_y_vals)

Loss function for classification


In [ ]: