Skip to content

Instantly share code, notes, and snippets.

@alexbw
Created July 17, 2018 16:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexbw/4324938e06283f4f550ee61ef4f56055 to your computer and use it in GitHub Desktop.
Save alexbw/4324938e06283f4f550ee61ef4f56055 to your computer and use it in GitHub Desktop.
Auto-generated graph code for Huber loss
def tf__huber_loss(a):
with tf.name_scope('huber_loss'):
def if_true():
with tf.name_scope('if_true'):
loss = a * a / 2
return loss,
def if_false():
with tf.name_scope('if_false'):
loss = delta * (tf.abs(a) - delta / 2)
return loss,
loss = ag__.utils.run_cond(tf.less_equal(tf.abs(a), delta), if_true,
if_false)
return loss
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment