Skip to content
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

TypeError: Expected int32, got <prettytensor.pretty_tensor_class.Layer > of type 'Layer' instead. #48

Closed
nsarafianos opened this issue Feb 9, 2017 · 16 comments

Comments

@nsarafianos
Copy link

commented Feb 9, 2017

I'm trying to run the StackGAN code (https://github.com/hanzhanggit/StackGAN) using TF1.0 and prettytensor (0.7.2) and I receive the following error
"TypeError: Expected int32, got <prettytensor.pretty_tensor_class.Layer object at 0x7f396c1ea590> of type 'Layer' instead." when I run the (sh demo/birds_demo.sh).

A friend who ran the same in TF 0.12 had no problems. Is this because of TF1.0? Do you have any idea what's the problem or what can be done to overcome it?

Thank you

@eiderman

This comment has been minimized.

Copy link
Contributor

commented Feb 20, 2017

Do you have more of an error message or a line of code? This looks like it is either from changes to arg order in TF that StackGAN does not support or a registration problem for Pretty Tensor objects.

@nsarafianos

This comment has been minimized.

Copy link
Author

commented Feb 20, 2017

Thank you for your response. The problem occurs in line 64 of demo.py. Here's the full error message.

Traceback (most recent call last):
  File "demo/demo.py", line 192, in <module>
    build_model(sess, embeddings.shape[-1], batch_size)
  File "demo/demo.py", line 64, in build_model
    fake_images = model.get_generator(tf.concat(1, [c, z]))
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/ops/array_ops.py", line 1047, in concat
    dtype=dtypes.int32).get_shape(
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/ops.py", line 651, in convert_to_tensor
    as_ref=False)
  File "/usr/local/lib/python2.7/dist-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 "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/constant_op.py", line 176, in _constant_tensor_conversion_function
    return constant(v, dtype=dtype, name=name)
  File "/usr/local/lib/python2.7/dist-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 "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/tensor_util.py", line 367, in make_tensor_proto
    _AssertCompatible(values, dtype)
  File "/usr/local/lib/python2.7/dist-packages/tensorflow/python/framework/tensor_util.py", line 302, in _AssertCompatible
    (dtype.name, repr(mismatch), type(mismatch).__name__))
TypeError: Expected int32, got <prettytensor.pretty_tensor_class.Layer object at 0x7ff261e9ac10> of type 'Layer' instead.
@eiderman

This comment has been minimized.

Copy link
Contributor

commented Feb 20, 2017

@nsarafianos

This comment has been minimized.

Copy link
Author

commented Feb 20, 2017

Thank you I will reach out to them.

@evanfeinberg

This comment has been minimized.

Copy link

commented Feb 21, 2017

@nsarafianos I just ran into the same issue. Fixed it by changing the TF concat order:

https://www.tensorflow.org/install/migration

@nsarafianos

This comment has been minimized.

Copy link
Author

commented Feb 21, 2017

@evanfeinberg Thank you

@seongkyun

This comment has been minimized.

Copy link

commented May 10, 2017

@evanfeinberg It works. thanks!

@EruditeStranger

This comment has been minimized.

Copy link

commented May 24, 2017

@evanfeinberg Could you please elaborate on what exactly what needed to be changed?

@nsarafianos

This comment has been minimized.

Copy link
Author

commented May 24, 2017

@EruditeStranger From the TF migration page: tf.concat arguments have been reordered to tf.concat(values, axis, name='concat') whereas in line 64 of the demo it's the other way around (i.e., tf.concat(1, [c, z])). So if I remember correctly you just swap the 1 with [c,z] and you're good to go.

@EruditeStranger

This comment has been minimized.

Copy link

commented May 24, 2017

@nsarafianos Just to be clear, were you suggesting reordering the arguments to tf.concat([c, z],1)? Because it doesn't seem to work for me.
I really apologize if this seems like a silly question; I've only just started with GANs.

@EruditeStranger

This comment has been minimized.

Copy link

commented May 24, 2017

My apologies - it did in fact, work. This bug led me to change a whole bunch of the code that had compatibility issues with TensorFlow 1.0

Thanks a bunch, @nsarafianos @evanfeinberg!

@Narmee249

This comment has been minimized.

Copy link

commented Jul 14, 2017

i'm facing the same issue, i already tried reordering of tf.concat but din't work out for me. please suggest something. Thanks @nsarafianos @evanfeinberg @EruditeStranger @eiderman

@cw1091293482

This comment has been minimized.

Copy link

commented Nov 1, 2017

@nsarafianos @EruditeStranger @seongkyun @evanfeinberg Actually it works for me after I changed the tf.concat(1, [c, z]) 【argument in TF1.0】to tf.concat([c, z],1)【argument in TF0.12】, but after changed, I am facing another issue happend in line: x_code = self.d_encode_img_template.construct(input= x_var).
the error is# ValueError: too many values to unpack.
Have you or anyone else face this issue when reproduce StackGAN, and what may be the possible solutions?
Thank you.

@cw1091293482

This comment has been minimized.

Copy link

commented Nov 1, 2017

It seem that he/she also faces this issue: hanzhanggit/StackGAN#27

@kyle-pena-nlp

This comment has been minimized.

Copy link

commented Nov 2, 2017

@cw1091293482 I am facing a different issue than you are. But it is of the same root cause... the authors need to list the exact versions of the libraries they used in a requirements file so that we can replicate their buildout without modifying their code.

@llewis257

This comment has been minimized.

Copy link

commented Apr 18, 2018

How in details did you overcome the compatibility issues? @EruditeStranger
I have the same problem. Thanks in advance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
9 participants
You can’t perform that action at this time.