-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
# 读取 Word2Vec 并对新输入进行词向量计算 def average_vec(words): # 读取 Word2Vec 模型 w2v = Word2Vec.load('TrainingSet/w2v_model.pkl') vec = np.zeros(300).reshape((1, 300)) for word in words: try: vec += w2v[word].reshape((1, 300)) except KeyError: continue return vec
在这段里执行到vec += w2v[word].reshape((1, 300))时报错TypeError: 'Word2Vec' object is not subscriptable,若将w2v强制转换为列表又报错TypeError: 'Word2Vec' object is not iterable,我实在找不到解决方法,请问要如何解决这个问题呢?
Metadata
Metadata
Assignees
Labels
No labels