我在python3中安装了最新版本的Tensorflow:
(tensorflow) [abigail@localhost anaconda3]$ python3 -c 'import tensorflow as tf; print(tf.__version__)'
0.12.0-rc0
我想在models /目录中运行word2vector示例。但是,我收到了一个错误:
tensorflow) [abigail@localhost anaconda3]$ python models/embedding/word2vec.py --train_data=text8 --eval_data=questions-words.txt --save_path=/tmp
I tensorflow/models/embedding/word2vec_kernels.cc:200] Data file: text8 contains 100000000 bytes, 17005207 words, 253854 unique words, 71290 unique frequent words.
Data file: text8
Vocab size: 71290 + UNK
Words per epoch: 17005207
Traceback (most recent call last):
File "models/embedding/word2vec.py", line 534, in <module>
tf.app.run()
File "/home/abigail/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/python/platform/app.py", line 43, in run
sys.exit(main(sys.argv[:1] + flags_passthrough))
File "models/embedding/word2vec.py", line 517, in main
model = Word2Vec(opts, session)
File "models/embedding/word2vec.py", line 166, in __init__
self.build_graph()
File "models/embedding/word2vec.py", line 368, in build_graph
tf.contrib.deprecated.scalar_summary("NCE loss", loss)
File "/home/abigail/anaconda3/envs/tensorflow/lib/python3.5/site-packages/tensorflow/__init__.py", line 36, in __getattr__
return getattr(contrib, item)
AttributeError: module 'tensorflow.contrib' has no attribute 'deprecated'
这个错误是什么?
答案 0 :(得分:0)
TL; DR:使用r0.12
分支中的version of tensorflow/models/embedding/word2vec.py
来匹配已安装版本的API。
当您运行与已安装的TensorFlow版本不兼容的教程版本时,会出现此错误。在0.12版本发布后,文件tensorflow/models/embedding/word2vec.py
为changed to use a new tf.contrib.deprecated
API。当我们清理API以获得稳定版本时,TensorFlow将经历一段时间的变化,因此在此期间使用与您安装的版本相匹配的模型代码版本将非常重要。