我正在尝试加载一个西班牙语的fasttext.bin模型,从https://fasttext.cc/docs/en/crawl-vectors.html加载,并继续使用我感兴趣的特定领域的新句子对其进行训练
系统:Anaconda、Jupyter笔记本、Python 3.6、升级的Gensim
我的代码(玩具示例):
from gensim.models.fasttext import load_facebook_model
import os
os.chdir('path/to/directory')
model = load_facebook_model('cc.es.300.bin')
'enmadrarse' in model.wv.vocab
>>> False
old_vector = np.copy(model.wv['enmadrarse'])
new_sentences = [['complexidad', 'cataratas', 'enmadrarse'],
['enmadrarse', 'cataratas', 'increibles'],
['unidad','enmadrarse','complexa']]
model.build_vocab(new_sentences, update = True)
model.train(new_sentences, total_examples = len(new_sentences), epochs=model.epochs)
new_vector = np.copy(model.wv['enmadrarse'])
np.allclose(old_vector, new_vector, atol=1e-4)
>>> True
'enmadrarse' in model.wv.vocab
>>> False (still)
单词的新旧向量是相等的,它不在词汇表中,因此模型什么也学不到。我做错了什么
目前没有回答
相关问题 更多 >
编程相关推荐