google/prettytensor

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

nsarafianos opened this issue · 16 comments

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

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.

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.

Thank you I will reach out to them.

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

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

@evanfeinberg It works. thanks!

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

@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.

@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.

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!

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

@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.

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

@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.

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