2016-11-27 118 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