我用来训练 word2vec 模型的所有单词都必须在 model.vocab 中,不是吗?

All of the words, those I use to train the word2vec model, must be in model.vocab, aren't they?

我使用下一段代码来训练模型:

norms_train = [ [''], [ u'word', u'to', u'learn', ... ], ...]
model = word2vec.Word2Vec(norms_train, size=100, window=10)

用程序检查结果:

i, j = 0, 0
for text in norms_train:
    j += len(text)
    for word in text:
        if word not in model.vocab:
            i += 1
print i, '/', j

13129 / 185379

您用于训练 Word2Vec 模型的所有单词都应该在 model.vocab 中。一个单词出现的最小次数可能有一个阈值,必须存在该阈值才能将其包含在模型词汇表中。

我假设参数 min_count 默认设置为 5,即如果一个词在训练数据中出现的次数少于 5 次,则该词不会出现在 model.vocab 中。