David Liu David Liu - 1 year ago 159
Python Question

my own data to tensorflow MNIST pipeline gives ValueError: input elements number isn't divisible by 65536

I'm using my own data with

example pipeline but getting:

ValueError: input has 16384 elements, which isn't divisible by 65536

I've been practicing with the example' data successfully. However, after introducing my own images which I resized to 128x128px and generated ubytes idx files, I get the following error:

Traceback (most recent call last):
File "tensorimage.py", line 132, in <module>
train_step = tf.train.AdamOptimizer(1e-4).minimize(cross_entropy)
File "/home/ubuntu/tensorflow/python3/lib/python3.4/site-packages/tensorflow/python/training/optimizer.py", line 196, in minimize
File "/home/ubuntu/tensorflow/python3/lib/python3.4/site-packages/tensorflow/python/training/optimizer.py", line 253, in compute_gradients
File "/home/ubuntu/tensorflow/python3/lib/python3.4/site-packages/tensorflow/python/ops/gradients.py", line 478, in gradients
in_grads = _AsList(grad_fn(op, *out_grads))
File "/home/ubuntu/tensorflow/python3/lib/python3.4/site-packages/tensorflow/python/ops/array_grad.py", line 298, in _ReshapeGrad
return [array_ops.reshape(grad, array_ops.shape(op.inputs[0])), None]
File "/home/ubuntu/tensorflow/python3/lib/python3.4/site-packages/tensorflow/python/ops/gen_array_ops.py", line 1758, in reshape
File "/home/ubuntu/tensorflow/python3/lib/python3.4/site-packages/tensorflow/python/framework/op_def_library.py", line 703, in apply_op
File "/home/ubuntu/tensorflow/python3/lib/python3.4/site-packages/tensorflow/python/framework/ops.py", line 2319, in create_op
File "/home/ubuntu/tensorflow/python3/lib/python3.4/site-packages/tensorflow/python/framework/ops.py", line 1711, in set_shapes_for_outputs
shapes = shape_func(op)
File "/home/ubuntu/tensorflow/python3/lib/python3.4/site-packages/tensorflow/python/ops/array_ops.py", line 1867, in _ReshapeShape
(num_elements, known_elements))
ValueError: input has 16384 elements, which isn't divisible by 65536

What's confusing to me is, I did indeed set the input to 16384 elements (128x128), however, I don't understand where 65536 came from. I combed through all of the code including the file

but can't find where 65536 number came from.

Answer Source

It's hard to tell without seeing more of your code exactly what's going wrong, but the summary is that TensorFlow thinks that the other dimensions of input result in a stride of 65536 elements, and so it's trying to infer the missing dimension by dividing the number of elements present by the known dimensions size, and spotting an error:


What happens if you print the size of input just before this error?

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download