Skip to content
This repository has been archived by the owner on May 19, 2018. It is now read-only.

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

Closed
gabrielaraujof opened this issue Feb 21, 2017 · 9 comments

Comments

@gabrielaraujof
Copy link

  • 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
Copy link
Author

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?

@martin-gorner
Copy link
Owner

martin-gorner commented Feb 21, 2017

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)

@gabrielaraujof
Copy link
Author

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? **

@tcrack326
Copy link

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.

@kkdai
Copy link

kkdai commented Feb 23, 2017

It should be fixed by this commit f8ed776.

Please give a try :).

@martin-gorner
Copy link
Owner

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 ?

@tcrack326
Copy link

tcrack326 commented Feb 23, 2017

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:

ContinuumIO/anaconda-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!

@martin-gorner
Copy link
Owner

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

@martin-gorner
Copy link
Owner

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants