tensorflow-playground
tensorflow-playground copied to clipboard
Parameter order in loss function of word2vec.py
I believe your inputs and labels are interchanged when you calculate the loss. Here is the corrected version
# Compute the loss, using a sample of the negative labels each time.
if self.loss_type == 'sampled_softmax_loss':
loss = tf.nn.sampled_softmax_loss(weights=self.weights, biases=self.biases, inputs=self.embed,
labels=self.train_labels, num_sampled=self.n_neg_samples, num_classes=self.vocabulary_size)
elif self.loss_type == 'nce_loss':
loss= tf.nn.nce_loss(weights=self.weights, biases=self.biases, inputs=self.embed,
labels=self.train_labels, num_sampled=self.n_neg_samples,num_classes= self.vocabulary_size)
self.loss = tf.reduce_mean(loss, name="loss")