2016-11-27 127 views
1

最近,我安裝了tensorflow並在CIFAR教程中得到了python導入錯誤。
我使用Mac OS X,僅限CPU,Python 2.7。Tensorflow - CIFAR教程中的導入錯誤

$ python cifar10_train.py 

Filling queue with 20000 CIFAR images before starting to train. This will take a few minutes.
Traceback (most recent call last):
File "cifar10_train.py", line 120, in
tf.app.run()
File "/Users/sunwoo/tensorflow/lib/python2.7/site-packages/tensorflow/python/platform/app.py", line 30, in run
sys.exit(main(sys.argv[:1] + flags_passthrough))
File "cifar10_train.py", line 116, in main
train()
File "cifar10_train.py", line 76, in train
class _LoggerHook(tf.train.SessionRunHook):
AttributeError: 'module' object has no attribute 'SessionRunHook'

如何導入tf.train.SessionRunHook?

+0

你能給我更詳細的代碼嗎?我無法弄清楚一條線路會發生什麼。 – daoliker

+0

我的代碼在這裏。 https://github.com/tensorflow/tensorflow/blob/r0.11/tensorflow/models/image/cifar10/cifar10_train.py – hamzzi

回答

0

它看起來像你使用的master branch of cifar10_train.py,與舊版本的TensorFlow(0.11或更早版本)。 master分支是recently modified以使用新的API,這在TensorFlow 0.11或更低版本中不可用。

有兩種方法可以解決這個問題。將TensorFlow升級到版本0.12或更高版本,或者檢出the r0.11 branch of the TensorFlow source,並使用the version of cifar10_train.py from that branch

+0

感謝您的幫助!我可以在'v0.11.0rc2'標籤上運行'cihar10_train.py'。 – hamzzi