Skip to content

Instantly share code, notes, and snippets.

@Syzygy2048
Created February 18, 2018 19:58
Show Gist options
  • Save Syzygy2048/e2aa3cacbb5c39b4e856973d1b19c82c to your computer and use it in GitHub Desktop.
Save Syzygy2048/e2aa3cacbb5c39b4e856973d1b19c82c to your computer and use it in GitHub Desktop.
all my code related to loss:
loss = tf.losses.softmax_cross_entropy(onehot_labels=labels, logits=logits)
total_loss = tf.losses.get_total_loss()
...
train_step = slim.learning.create_train_op(total_loss, optimizer, variables_to_train=variables_to_train) #better than Optimizer.minimize because it prevents problems like vanishing gradient
...
#this is writing everything to tensorboard
tf.summary.scalar('total loss', total_loss)
tf.summary.scalar('loss', loss)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment