tensorflow-mnist-tutorial icon indicating copy to clipboard operation
tensorflow-mnist-tutorial copied to clipboard

Expected int32, got list containing Tensors of type '_Message' instead.

Open gabrielaraujof opened this issue 9 years ago • 9 comments

  • Env:

    • Python 3.5.3
    • Linux Mint 18 Cinnamon 64-bit
    • matplotlib 1.5.0
    • tensorflow 1.0.0
  • Installation:

I have installed both matplotlib and tensorflow with pip.

  • The bug:
$ python mnist_1.0_softmax.py
Extracting data/train-images-idx3-ubyte.gz
Extracting data/train-labels-idx1-ubyte.gz
Extracting data/t10k-images-idx3-ubyte.gz
Extracting data/t10k-labels-idx1-ubyte.gz
Traceback (most recent call last):
  File "mnist_1.0_softmax.py", line 78, in <module>
    I = tensorflowvisu.tf_format_mnist_images(X, Y, Y_)  # assembles 10x10 images by default
  File "/home/gabriel/Work/tensorflow-mnist-tutorial/tensorflowvisu.py", line 42, in tf_format_mnist_images
    everything_incorrect_first = tf.concat(0, [incorrectly_recognised_indices, correctly_recognised_indices]) # images reordered with indeces of unrecognised images first
  File "/home/gabriel/.pyenv/versions/3.5.3/lib/python3.5/site-packages/tensorflow/python/ops/array_ops.py", line 1047, in concat
    dtype=dtypes.int32).get_shape(
  File "/home/gabriel/.pyenv/versions/3.5.3/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 651, in convert_to_tensor
    as_ref=False)
  File "/home/gabriel/.pyenv/versions/3.5.3/lib/python3.5/site-packages/tensorflow/python/framework/ops.py", line 716, in internal_convert_to_tensor
    ret = conversion_func(value, dtype=dtype, name=name, as_ref=as_ref)
  File "/home/gabriel/.pyenv/versions/3.5.3/lib/python3.5/site-packages/tensorflow/python/framework/constant_op.py", line 176, in _constant_tensor_conversion_function
    return constant(v, dtype=dtype, name=name)
  File "/home/gabriel/.pyenv/versions/3.5.3/lib/python3.5/site-packages/tensorflow/python/framework/constant_op.py", line 165, in constant
    tensor_util.make_tensor_proto(value, dtype=dtype, shape=shape, verify_shape=verify_shape))
  File "/home/gabriel/.pyenv/versions/3.5.3/lib/python3.5/site-packages/tensorflow/python/framework/tensor_util.py", line 367, in make_tensor_proto
    _AssertCompatible(values, dtype)
  File "/home/gabriel/.pyenv/versions/3.5.3/lib/python3.5/site-packages/tensorflow/python/framework/tensor_util.py", line 302, in _AssertCompatible
    (dtype.name, repr(mismatch), type(mismatch).__name__))
TypeError: Expected int32, got list containing Tensors of type '_Message' instead.
  • How did this occurred:

I just cloned the repo, installed the packages and tried to run the very first file in the codelab instructions.

gabrielaraujof avatar Feb 21 '17 00:02 gabrielaraujof

I checked the code, the tensorflow docs and realized that tf.concat has now a different order in the argument list. The code was this:

everything_incorrect_first = tf.concat(0, [incorrectly_recognised_indices, correctly_recognised_indices])

Whereas it should be this, I suppose:

everything_incorrect_first = tf.concat([incorrectly_recognised_indices, correctly_recognised_indices], 0)

Although, I changed the code and got a new error:

$ python mnist_1.0_softmax.py
Extracting data/train-images-idx3-ubyte.gz
Extracting data/train-labels-idx1-ubyte.gz
Extracting data/t10k-images-idx3-ubyte.gz
Extracting data/t10k-labels-idx1-ubyte.gz
Traceback (most recent call last):
  File "mnist_1.0_softmax.py", line 78, in <module>
    I = tensorflowvisu.tf_format_mnist_images(X, Y, Y_)  # assembles 10x10 images by default
  File "/home/gabriel/Work/tensorflow-mnist-tutorial/tensorflowvisu.py", line 55, in tf_format_mnist_images
    superimposed_digits = tf.select(correct_prediction_s, tf.zeros_like(correct_tags),correct_tags+computed_tags) # only pring the correct and computed digits on unrecognised images
AttributeError: module 'tensorflow' has no attribute 'select'

Am I using the incorrect version of tensorflow? If yes, what version should I be using for now?

gabrielaraujof avatar Feb 21 '17 00:02 gabrielaraujof

you seem to have an old version of the code I have pushed TF 1.0 changes recently try to refresh (i.e. git pull)

martin-gorner avatar Feb 21 '17 14:02 martin-gorner

That was something odd, because I had forked the repo just 2 days ago. Anyway, I've updated the code and the script is working now. **However, the animation didn't show up. Any clue why I'm not seeing it? **

gabrielaraujof avatar Feb 21 '17 22:02 gabrielaraujof

I downloaded the latest tensorflow today and cloned the repo and I had to convert the tf.concat() functions to the original param structure to get them to work: everything_incorrect_first = tf.concat(0, [incorrectly_recognised_indices, correctly_recognised_indices])

Maybe TensorFlow changed their concat function to be like it was before but I thought I would let you know.

tcrack326 avatar Feb 22 '17 16:02 tcrack326

It should be fixed by this commit https://github.com/martin-gorner/tensorflow-mnist-tutorial/commit/f8ed776cc705a73a688bc212495b78dec8f72505.

Please give a try :).

kkdai avatar Feb 23 '17 05:02 kkdai

Odd, you are not the first person reporting this although it works well for me. Are you installing Tensorflow using "pip3 install --upgrade tensorflow" ? Or maybe you are specifying a versioned package explicitly ?

martin-gorner avatar Feb 23 '17 13:02 martin-gorner

Yes, you're exactly right. I had a couple of issues. I was using a conda environment where tensorflow had previously been installed and wouldn't update. I created a fresh environment but ran into this issue described here where the tensorflow install wouldn't work in a new conda environment:

https://github.com/ContinuumIO/anaconda-issues/issues/542

Once that was working I ran into another issue due to using a Mac with matplotlib:

http://stackoverflow.com/questions/21784641/installation-issue-with-matplotlib-python

Once I got through these everything is working normally with the current code.

Sorry for the confusion. Hopefully this can help others avoid confusion in the future. Love the course!

tcrack326 avatar Feb 23 '17 15:02 tcrack326

Thanks. I'll leave this issue open for a couple of days to capture similar experiences.

martin-gorner avatar Feb 23 '17 15:02 martin-gorner

The other person reporting a similar issue also confirmed he was testing with the wrong Python environment. Closing.

martin-gorner avatar Feb 24 '17 09:02 martin-gorner