You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
when i am running this code on small corpus i am getting key error because that key is not in dict and corpus vocab is also not that huge.
sim = similarity.eval()
for i in xrange(valid_size):
valid_word = reverse_dictionary[valid_examples[i]]
print("--",valid_word)
top_k = 5 # number of nearest neighbors
nearest = (-sim[i, :]).argsort()[1:top_k+1]
print(nearest)
log_str = "Nearest to %s:" % valid_word
print(log_str)
for k in xrange(top_k):
close_word = reverse_dictionary[nearest[k]]
I was having the exact same problem as you until I checked the size of the "reverse_dictionary" array using "print(len(reverse_dictionary))" just before the error occurred.
Your "vocabulary_size = 50000" line should be set lower. I set it to the value returned by printing the length of "reverse_dictionary" and no longer had any issues.
when i am running this code on small corpus i am getting key error because that key is not in dict and corpus vocab is also not that huge.
My output are like this:
vocab_length = 1155
batch_size = 16
embedding_size = 128
skip_window = 5
num_skips = 4
valid_size = 16
valid_window = 100
valid_examples = np.random.choice(valid_window, valid_size, replace=False)
num_sampled =64
Can anybody help please?
The text was updated successfully, but these errors were encountered: