在学习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原理(四)读tensorflow实现RNN、word2vec遇到的bug有感

注释掉,拉平靠前就好;如图修改为:

tensorflow原理(四)读tensorflow实现RNN、word2vec遇到的bug有感

tensorflow版本:1.2.1

python版本:3.5.1


最后跑得的结果是:

tensorflow原理(四)读tensorflow实现RNN、word2vec遇到的bug有感


希望对你有所帮助!




相关文章:

  • 2022-01-20
  • 2022-12-23
  • 2021-10-12
  • 2021-10-06
  • 2022-12-23
  • 2022-12-23
  • 2021-11-16
猜你喜欢
  • 2021-10-09
  • 2021-04-15
  • 2022-12-23
  • 2021-11-03
  • 2021-08-29
  • 2021-05-14
  • 2021-07-12
相关资源
相似解决方案