2016-12-28 95 views
4

我已经从教程here中的链接下载了CIFAR10代码,并试图运行本教程。我用命令运行它tensorflow cifar10教程失败

python cifar10_train.py 

它开始正常并按预期下载数据文件。当它试图打开它失败,出现以下跟踪输入文件:

Traceback (most recent call last): 
    File "cifar10_train.py", line 120, 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 116, in main 
    train() 
    File "cifar10_train.py", line 63, in train 
    images, labels = cifar10.distorted_inputs() 
    File "/notebooks/Python Scripts/tensorflowModels/tutorials/image/cifar10/cifar10.py", line 157, in distorted_inputs 
    batch_size=FLAGS.batch_size) 
    File "/notebooks/Python Scripts/tensorflowModels/tutorials/image/cifar10/cifar10_input.py", line 161, in distorted_inputs 
    read_input = read_cifar10(filename_queue) 
    File "/notebooks/Python Scripts/tensorflowModels/tutorials/image/cifar10/cifar10_input.py", line 87, in read_cifar10 
    tf.strided_slice(record_bytes, [0], [label_bytes]), tf.int32) 
TypeError: strided_slice() takes at least 4 arguments (3 given) 

果然,当我调查的代码存在cifar10_input.py调用strided_slice()只有3个参数:

tf.strided_slice(record_bytes, [0], [label_bytes]) 

虽然tensorflow文档确实声明必须至少有4个参数。

什么问题?我已经下载了最新的tensorflow(0.12),我正在运行cifar代码的主分支。

+1

这可能是他们的GitHub页面上的一个问题。我看了几个版本,他们都需要4个参数。 –

+0

谢谢。我已经添加了关于GitHub的讨论并获得了我在下面添加的解决方案(我认为)。我仍然有点不确定为什么代码处于非工作状态,但目前似乎正在运行。 – BobbyG

回答

2

github一些讨论中,我已经把下面的变化,这似乎使其工作:

在cifar10_input.py

- result.label = tf.cast(tf.strided_slice(record_bytes, [0], [label_bytes]), tf.int32) 
+ result.label = tf.cast(tf.slice(record_bytes, [0], [label_bytes]), tf.int32) 



- depth_major = tf.reshape(tf.strided_slice(record_bytes, [label_bytes], [label_bytes + image_bytes]),  [result.depth, result.height, result.width]) 
+ depth_major = tf.reshape(tf.slice(record_bytes, [label_bytes], [image_bytes]), [result.depth, result.height, result.width]) 

然后在这两个cifar10_input.py和cifar10.py我有搜索“不推荐”和无论我在哪里找到它,根据我在api指南中阅读的内容(希望是正确的)替换为有效的函数。这方面的例子:

- tf.contrib.deprecated.image_summary('images', images) 
+ tf.summary.image('images', images) 

- tf.contrib.deprecated.histogram_summary(tensor_name + '/activations', x) 
- tf.contrib.deprecated.scalar_summary(tensor_name + '/sparsity', 
+ tf.summary.histogram(tensor_name + '/activations', x) 
+ tf.summary.scalar(tensor_name + '/sparsity', 

看来现在愉快地被隆隆一起。我会看看它是否完成,如果我上面所做的更改给出了所需的诊断结果。

我仍然想听到更接近代码的人的明确答案。