tensorflow原理(四)读tensorflow实现RNN、word2vec遇到的bug有感
在学习Tensorflow上的实现基于LSTM的语言模型的时候,
TensorFlow实战:Chapter-7上(RNN简介和RNN在NLP应用) url:https://blog.csdn.net/u011974639/article/details/77377784
(一)出现No module named 'tensorflow.models.tutorials'的问题:
将from tensorflow.models.tutorials.rnn.ptb import reader 或者 import reader
修改为
from tensorflow.models.rnn.ptb import reader
就可以了。
(二)第四第五步出现ValueError: Tensor("Placeholder:0", shape=(128,), dtype=int32) must be from the same graph as Tensor("Variable:0", shape=(50000, 128), dtype=float32_ref, device=/device:CPU:0).问题的时候
# Step 4: 建立训练模型 Build and train a skip-gram model.
将下图
注释掉,拉平靠前就好;如图修改为:
tensorflow版本:1.2.1
python版本:3.5.1
最后跑得的结果是:
希望对你有所帮助!