当我在tensorflow上运行cifar10时,会出现AttributeError:没有属性' random_crop'

时间:2017-02-08 03:31:22

标签: python tensorflow

我从互联网下载带有tensorflow的cifar10代码,当我运行cifar10_train.py时,会出现以下错误:

ubuntu@ip-172-31-58-100:~$ python cifar10_train.py
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcublas.so.7.5 locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcudnn.so.5 locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcufft.so.7.5 locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcuda.so.1 locally
I tensorflow/stream_executor/dso_loader.cc:128] successfully opened CUDA library libcurand.so.7.5 locally
Traceback (most recent call last):
  File "cifar10_train.py", line 142, in <module>
    tf.app.run()
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/platform/app.py", line 43, in run
    sys.exit(main(sys.argv[:1] + flags_passthrough))
  File "cifar10_train.py", line 137, in main
    train()
  File "cifar10_train.py", line 68, in train
    images, labels = cifar10.distorted_inputs()  
  File "/home/ubuntu/cifar10.py", line 121, in distorted_inputs
    batch_size=FLAGS.batch_size)
  File "/home/ubuntu/cifar10_input.py", line 130, in distorted_inputs
    distorted_image = tf.image.random_crop(reshaped_image, [height, width])
AttributeError: 'module' object has no attribute 'random_crop'

有谁知道发生了什么?非常感谢!

1 个答案:

答案 0 :(得分:0)

此代码可能来自tensorflow的旧版本,而不是您安装的版本。

尝试更改行

tf.image.random_crop(reshaped_image, [height, width])

tf.random_crop(reshaped_image, [height, width])