我想尝试将 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/