2
如何給一個特定的詞來測試一個訓練有素的word2vec模型?如何在tensorflow中給word2vec模型一個特定的詞
例如
輸入 「狗」,並返回像 「貓」 字nearst, 「鳥」 等。
謝謝!
如何給一個特定的詞來測試一個訓練有素的word2vec模型?如何在tensorflow中給word2vec模型一個特定的詞
例如
輸入 「狗」,並返回像 「貓」 字nearst, 「鳥」 等。
謝謝!
即張量流程示例已經有一個函數來計算的相似性,並顯示最近的單詞。 最簡單的方法是使用該功能。
在定義valid_examples之後的第4步中,可以給出你自己的單詞。
valid_examples = np.random.choice(valid_window, valid_size, replace=False)
num_sampled = 64 # Number of negative examples to sample.
sample_word = "dog";
if sample_word in dictionary:
sample_index = dictionary[sample_word]
else:
sample_index = 0 # dictionary['UNK']
valid_examples[0] = sample_index
然後你可以在第一行看到結果。對於恩,我的結果是
最近的狗:授權,侄子,文具,狨猴,哇,KVAC, dasyprocta,半人馬,