Gensim Word2Vec:训练表现不佳。

Gensim Word2Vec: poor training performance.

这实际上可能是一个愚蠢的问题,但我只是想不通为什么我的 gensim.models.word2vec 脚本不起作用。事情是这样的,我正在使用斯坦福情绪分析数据库数据集(~11000 条评论),我正在尝试使用 gensim 构建 word2vec,这是我的脚本:

import gensim as gs 
import sys 

# open the datas
sentences = gs.models.word2vec.LineSentence('../processedWords.txt')
print("size in RAM of the sentences: {}".format(sys.getsizeof(sentences)))

# transform them
# bigram_transformer = gs.models.Phrases(sentences)

model = gs.models.word2vec.Word2Vec(sentences, min_count=10, size=100, window=5)
model.save('firstModel')
print(model.similarity('film', 'test'))
print(model.similarity('film', 'movie'))

现在,我的问题是脚本在 2 秒内运行,并且每对单词之间只给出了巨大的相似性。此外,句子中的某些单词不在内置词汇表中。

我一定是做错了什么,但想不通。

感谢您的帮助。

我几乎可以肯定这是因为您没有指定训练迭代次数;我认为iter默认为1,这对训练神经网络来说基本没用。将 iter=<int> 标志添加到您的模型声明中,例如model = gs.models.word2vec.Word2Vec(sentences, min_count=10, size=100, window=5, iter=1000)。 有点爱面子,但我做了同样的事情。