model.getVectors().keys()是否会返回模型中的所有键 [英] Would model.getVectors().keys() return all the Keys from a model
问题描述
下面是示例代码.我正在尝试获取newfile.txt(具有新闻文章的文件)中所有单词的矢量表示.想知道model.getVectors().keys()是输出所有键(文件中的不同单词)还是将输出限制为一定数量.
Below is a sample code. I'm trying to get vector representation for all the words in newfile.txt (file having a news article). Would like to know if model.getVectors().keys() outputs all the keys (distinct words in the file) or does it limits the output to certain number.
尽管我的输入中有很多单词,但目前我只能得到几个单词作为键.如何运作?
Currently I get only a few words as key though my input does have many. How does it work?
doc = sc.textFile('newfile.txt').map(lambda line: line.split(" "))
model = Word2Vec().fit(doc)
model.getVectors().keys()
推荐答案
我找到了答案,由于模型 setMinCount()
的此参数,未列出所有键(单词),具有默认值为5
I found the answer, all the keys(words) was not listed because of this parameter to the model setMinCount()
, has a default value of 5
来自文档
感谢您的帮助!
这篇关于model.getVectors().keys()是否会返回模型中的所有键的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!