c - 如何为其他语言(word2vec)制作预训练 vector ?

标签 c python-2.7 gensim word2vec

我想尝试将 word2vec 实现为 Vietnamase 语言,但我对预训练 vector 感到困惑,当我尝试在英语中使用时,我使用 Google News-vectors-negative300.bin.gz (大约 3.4 GB)用于预训练 vector 并且效果很好。如果我使用越南语言,我应该让数据本身预先训练 vector 吗? 如何制作预训练 vector ,例如 Google News-vectors-male300.bin.gz,然后我尝试将 Google News-vectors-male300.bin 转换为文本格式,结果如下:

3000000 300

0.001129 -0.000896 0.000319 0.001534 0.001106 -0.001404 -0.000031 -0.000420 -0.000576 0.001076 -0.001022 -0.000618 -0.000755 0 .001404 -0.001640 -0.000633 0.001633 -0.001007 -0.001266 0.000652 -0.000416 -0.001076 0.001526 -0.000275 0.000140 0.001572 0.00135 8 -0.000832 -0.001404 0.001579 0.000254 -0.000732 -0.000105 -0.001167 0.001579

如何将字母或单词更改为上面的形式?

最佳答案

您应该使用您的语言数据训练模型。可以在Python中使用“解码”和“编码”函数。在用你的句子训练模型之前,你应该对你的句子单词进行统一编码。

for sentence in sentences:
    for word in sentence:
        word = word.decode('utf-8')

此后,您的模型可以使用“utf-8”支持的任何语言进行训练:)

关于c - 如何为其他语言(word2vec)制作预训练 vector ?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37461117/

相关文章:

c - C语言中的指针和赋值函数

python - python中的字符串解码方法错误

nlp - 如何在 gensim 中使用 build_vocab?

C 将结构传递给回调函数 (Tizen)

c - typedef 结构体和指针

C 编译器错误 "expected ... before ..."和无效类型参数

python - 如何用 python 制作网站图表?

python - 谷歌应用引擎 : ImportError: No module named appengine. 分机

python-3.x - 如何修复 'C extension not loaded, training will be slow. Install a C compiler and reinstall gensim for fast training.'

python-3.x - 如何获取gensim LDA中所有文档的document_topics分布?