Skip to content

Commit 4115952

Browse files
authored
Merge pull request jikexueyuanwiki#177 from chuangwailinjie/master
修正nce_loss方法参数顺序
2 parents 5e90ebe + e66e90d commit 4115952

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

SOURCE/tutorials/word2vec/word2vec_basic.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def generate_batch(batch_size, num_skips, skip_window):
138138
# tf.nce_loss automatically draws a new sample of the negative labels each
139139
# time we evaluate the loss.
140140
loss = tf.reduce_mean(
141-
tf.nn.nce_loss(nce_weights, nce_biases, embed, train_labels,
141+
tf.nn.nce_loss(nce_weights, nce_biases, train_labels,embed,
142142
num_sampled, vocabulary_size))
143143

144144
# Construct the SGD optimizer using a learning rate of 1.0.
@@ -216,7 +216,7 @@ def plot_with_labels(low_dim_embs, labels, filename='tsne.png'):
216216
tsne = TSNE(perplexity=30, n_components=2, init='pca', n_iter=5000)
217217
plot_only = 500
218218
low_dim_embs = tsne.fit_transform(final_embeddings[:plot_only,:])
219-
labels = dictionary.keys()[:plot_only]
219+
labels = list(dictionary.keys())[:plot_only]
220220
plot_with_labels(low_dim_embs, labels)
221221

222222
except ImportError:

0 commit comments

Comments
 (0)