Skip to content

Instantly share code, notes, and snippets.

@gonzaloruizdevilla
Created May 18, 2018 12:23
Show Gist options
  • Save gonzaloruizdevilla/c9224e6bdf768710d438f3c74590fceb to your computer and use it in GitHub Desktop.
Save gonzaloruizdevilla/c9224e6bdf768710d438f3c74590fceb to your computer and use it in GitHub Desktop.
Word2vec compute loss
# Compute the NCE loss, using a sample of the negative labels each time.
loss = tf.reduce_mean(
tf.nn.nce_loss(weights=nce_weights,
biases=nce_biases,
labels=train_labels,
inputs=embed,
num_sampled=num_sampled,
num_classes=vocabulary_size))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment