embeddings = np.zeros([len(vocab), dim])
model = Word2Vec.load_word2vec_format(glove_filename, binary=True)
count = 0
for word in vocab:
if model.__contains__(word):
word_idx = vocab[word]
embeddings[word_idx] = np.asarray(model[word])
else:
count += 1
print(word)
print ("number of unknown word in word embedding", count)
np.savez_compressed(trimmed_filename, embeddings=embeddings)
word2vec对于bin的使用
最新推荐文章于 2023-04-04 10:36:37 发布