Tensorflow:Word2vec CBOW 模型 [英] Tensorflow: Word2vec CBOW model

查看:57
本文介绍了Tensorflow:Word2vec CBOW 模型的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 tensorflow 和 word2vec 的新手.我刚刚研究了

要实现 CBOW,您必须编写一个新的 generate_batch 生成器函数,并在应用逻辑回归之前对周围单词的向量求和.我写了一个例子,你可以参考:https://github.com/wangz10/tensorflow-playground/blob/master/word2vec.py#L105

I am new to tensorflow and to word2vec. I just studied the word2vec_basic.py which trains the model using Skip-Gram algorithm. Now I want to train using CBOW algorithm. Is it true that this can be achieved if I simply reverse the train_inputs and train_labels?

解决方案

I think CBOW model can not simply be achieved by flipping the train_inputs and the train_labels in Skip-gram because CBOW model architecture uses the sum of the vectors of surrounding words as one single instance for the classifier to predict. E.g., you should use [the, brown] together to predict quick rather than using the to predict quick.

To implement CBOW, you'll have to write a new generate_batch generator function and sum up the vectors of surrounding words before applying logistic regression. I wrote an example you can refer to: https://github.com/wangz10/tensorflow-playground/blob/master/word2vec.py#L105

这篇关于Tensorflow:Word2vec CBOW 模型的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆