我正在用我自己的语料库训练一个手套模型,我很难以utf-8
格式保存/加载它。在
在这里我尝试了:
from glove import Corpus, Glove
#data
lines = [['woman', 'umbrella', 'silhouetted'], ['person', 'black', 'umbrella']]
#GloVe training
corpus = Corpus()
corpus.fit(lines, window=4)
glove = Glove(no_components=4, learning_rate=0.1)
glove.fit(corpus.matrix, epochs=10, no_threads=8, verbose=True)
glove.add_dictionary(corpus.dictionary)
glove.save('glove.model.txt')
保存的文件glove.model.txt
不可读,我无法用utf-8
编码保存它。在
当我试图阅读时,例如将其转换为Word2Vec格式:
^{pr2}$我有以下错误:
UnicodeDecodeError: 'utf-8' codec can't decode byte 0x80 in position 0: invalid start byte
你知道我怎么用我自己的手套模型吗?在
我刚刚找到了一种以
utf-8
格式保存数据的方法,我在这里分享,以防有人遇到同样的问题不要使用手套保存方法
glove.save('glove.model.txt')
尝试自己模拟手套记录:那你就可以读了。在
相关问题 更多 >
编程相关推荐