-
Notifications
You must be signed in to change notification settings - Fork 45.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cifar10_input.py calls tf.strided_slice() with 3 arguments, 4 needed. #817
Comments
I am having the same problem. See my description here on stackoverflow. |
I have the same problem |
This problem also happens while running, ptb_word_lm.py. Version of tensorflow : '0.12.0' Entire traceback: TypeError Traceback (most recent call last) in init(self, config, data, name) /home/ubuntu/Dropbox/xai/Machine175/AttentionModels/rnn/ptb/reader.pyc in ptb_producer(raw_data, batch_size, num_steps, name) TypeError: strided_slice() takes at least 4 arguments (3 given) |
I used slice() instead of strided_slice(), It was working. Is there any recommendation for this issue? |
I have found out the solution for my issue above. |
After looking at @Cuongvn08 I have put the following changes in which seem to make it work: In cifar10_input.py
Then in both cifar10_input.py and cifar10.py I had to search for "deprecated" and wherever I found it, replace it with a valid function based on what I read in the api guide (hopefully correctly). Examples of this:
and
It seems to be chugging along happily now. I'll see if it completes OK and if the changes I put in above give the desired diagnostic outputs. I'd still like to hear a definitive answer from someone closer to the code. |
@debajyotidatta looks like #824 fixes the problem - runs fine for me with those changes |
Does anyone know a more extensive documentation for strided_slice? I don't understand what the 4th argument should look like. The only one I seem to come across is https://github.com/tensorflow/tensorflow/blob/master/tensorflow/g3doc/api_docs/python/functions_and_classes/shard8/tf.strided_slice.md |
@piatra this page is fairly helpful: |
Automating the changes required (with GNU sed and perl 5.22.2):
@piatra - the answer from #824 is to add a 4th [needed argument] of |
See the 2nd edit in my comment which sorts this out.
BobbyAtSperry
From: Samuel Marks [mailto:notifications@github.com]
Sent: 31 December 2016 04:45
To: tensorflow/models <models@noreply.github.com>
Cc: bobbyAtSperry <bobby.gilbert@sperryrail.com>; Comment <comment@noreply.github.com>
Subject: Re: [tensorflow/models] cifar10_input.py calls tf.strided_slice() with 3 arguments, 4 needed. (#817)
Hmm, I tried with your changes... automated:
find -type f -name '*.py' -exec sed -i -e 's/tf.strided_slice/tf.slice/g' -e 's/tf.contrib.deprecated/tf.summary/g' {} \;
And got a different error:
$ python cifar10_train.py
Traceback (most recent call last):
File "cifar10_train.py", line 120, in <module>
tf.app.run()
File "/not_tmp/.venvs/tflow/local/lib/python2.7/site-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 "/not_tmp/tensorflow/models/tutorials/image/cifar10/cifar10.py", line 156, in distorted_inputs
batch_size=FLAGS.batch_size)
File "/not_tmp/tensorflow/models/tutorials/image/cifar10/cifar10_input.py", line 161, in distorted_inputs
read_input = read_cifar10(filename_queue)
File "/not_tmp/tensorflow/models/tutorials/image/cifar10/cifar10_input.py", line 94, in read_cifar10
[result.depth, result.height, result.width])
File "/not_tmp/.venvs/tflow/local/lib/python2.7/site-packages/tensorflow/python/ops/gen_array_ops.py", line 2448, in reshape
name=name)
File "/not_tmp/.venvs/tflow/local/lib/python2.7/site-packages/tensorflow/python/framework/op_def_library.py", line 759, in apply_op
op_def=op_def)
File "/not_tmp/.venvs/tflow/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 2242, in create_op
set_shapes_for_outputs(ret)
File "/not_tmp/.venvs/tflow/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1617, in set_shapes_for_outputs
shapes = shape_func(op)
File "/not_tmp/.venvs/tflow/local/lib/python2.7/site-packages/tensorflow/python/framework/ops.py", line 1568, in call_with_requiring
return call_cpp_shape_fn(op, require_shape_fn=True)
File "/not_tmp/.venvs/tflow/local/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.py", line 610, in call_cpp_shape_fn
debug_python_shape_fn, require_shape_fn)
File "/not_tmp/.venvs/tflow/local/lib/python2.7/site-packages/tensorflow/python/framework/common_shapes.py", line 675, in _call_cpp_shape_fn_impl
raise ValueError(err.message)
ValueError: Cannot reshape a tensor with 3073 elements to shape [3,32,32] (3072 elements) for 'Reshape' (op: 'Reshape') with input shapes: [3073], [3].
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub <#817 (comment)> , or mute the thread <https://github.com/notifications/unsubscribe-auth/ATxFkaIkLI__BFDebiAQgcKFfErl1X1Jks5rNd3UgaJpZM4LV8ck> . <https://github.com/notifications/beacon/ATxFkVruUe-WuVsZRdyFqS3yLM-x3xfIks5rNd3UgaJpZM4LV8ck.gif>
|
did you resolve this problem? I also encountered the same problem. |
@bobbyAtSperry , ValueError: Cannot reshape a tensor with 3073 elements to shape [3,32,32] (3072 elements) for 'Reshape' (op: 'Reshape') with input shapes: [3073], [3]. |
@mianmian3 Yes. See my reply further up the chain or summarised in the answer here. The specific line to fix this is There is an alternative comprehensive answer to this question here, but you have to use the reply I've commented on or you will still have other problems. |
Strided_slice has made the "stride" option optional (defaulting to all ones...) ... this is available in master (but not the release you are using). so you can change tf.strided_slice(record_bytes, [0], [label_bytes]), tf.int32) to tf.strided_slice(record_bytes, [0], [label_bytes], [1]), tf.int32) |
@aselle I think it's worth making the code work with 0.12.x as well, even though it already works with the TF master. The code is referred from the TF tutorial. Many readers of that document would not be familiar with TF code base (that's why they read the introductory document after all.) The example code not working out of the box is discouraging to these new users, IMO. It might make sense to keep it broken if the API change is large and it's hard to keep the compatibility. But it isn't the case of this issue. Please take a look at #849 when you have time. |
I made the changes as put in #849, and the trained the model. But during evaluation I get the error: Traceback (most recent call last): |
Here's my .patch file: https://gist.github.com/SamuelMarks/17e968288545042da4e718e886e458e3 But it gives me:
|
@utsavgarg Thanks for the catch! Just noticed that and fixed #849 accordingly. |
Closing because fix from previous comment was submitted. |
Please let us know which model this issue is about (specify the top-level directory)
models/tutorials/image/cifar10/cifar10_input.py:87
File "/mnt/st12tb/models/tutorials/image/cifar10/cifar10_input.py", line 87, in read_cifar10
tf.strided_slice(record_bytes, [0], [label_bytes]), tf.int32)
models/tutorials/image/cifar10/cifar10_input.py:93
File "/mnt/st12tb/models/tutorials/image/cifar10/cifar10_input.py", line 93, in read_cifar10
[label_bytes + image_bytes]),
In both cases, running the script, e.g. with "python cifar10_train.py" on TensorFlow v0.12 yields
TypeError: strided_slice() takes at least 4 arguments (3 given)
The text was updated successfully, but these errors were encountered: