My own data to tensorflow MNIST pipeline gives ValueError: input elements number isn't divisible by 65536
<p>I'm using my own data with <a href="http://stackoverflow.com/questions/tags/tensorflow"><code>tensorflow</code></a> <a href="http://stackoverflow.com/questions/tagged/mnist"><code>MNIST</code></a> example pipeline but getting:</p>

<blockquote>
  <p>ValueError: input has 16384 elements, which isn't divisible by 65536</p>
</blockquote>

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

<blockquote>
<pre>Traceback (most recent call last):
  File "tensorimage.py", line 132, in 
    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
    grad_loss=grad_loss)
  File "/home/ubuntu/tensorflow/python3/lib/python3.4/site-packages/tensorflow/python/training/optimizer.py", line 253, in compute_gradients
    colocate_gradients_with_ops=colocate_gradients_with_ops)
  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
    name=name)
  File "/home/ubuntu/tensorflow/python3/lib/python3.4/site-packages/tensorflow/python/framework/op_def_library.py", line 703, in apply_op
    op_def=op_def)
  File "/home/ubuntu/tensorflow/python3/lib/python3.4/site-packages/tensorflow/python/framework/ops.py", line 2319, in create_op
    set_shapes_for_outputs(ret)
  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</pre>
</blockquote>

<p>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 <code>tensorflow/python3/lib/python3.4/site-packages/tensorflow/contrib/learn/python/learn/datasets/mnist.py</code>
 but can't find where 65536 number came from.</p>

<p>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 <code>input</code> 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:</p>

<p><a href="https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/ops/array_ops.py#L1702" rel="nofollow">https://github.com/tensorflow/tensorflow/blob/master/tensorflow/python/ops/array_ops.py#L1702</a></p>

<p>What happens if you print the size of <code>input</code> just before this error?</p>

python ubuntu tensorflow mnist