Skip to content
This repository was archived by the owner on Dec 29, 2022. It is now read-only.
This repository was archived by the owner on Dec 29, 2022. It is now read-only.

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

Closed
@nsarafianos

Description

@nsarafianos

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

Activity

eiderman

eiderman commented on Feb 20, 2017

@eiderman
Contributor

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

nsarafianos commented on Feb 20, 2017

@nsarafianos
Author

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

eiderman commented on Feb 20, 2017

@eiderman
Contributor
nsarafianos

nsarafianos commented on Feb 20, 2017

@nsarafianos
Author

Thank you I will reach out to them.

evanfeinberg

evanfeinberg commented on Feb 21, 2017

@evanfeinberg

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

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

nsarafianos

nsarafianos commented on Feb 21, 2017

@nsarafianos
Author

@evanfeinberg Thank you

seongkyun

seongkyun commented on May 10, 2017

@seongkyun

@evanfeinberg It works. thanks!

EruditeStranger

EruditeStranger commented on May 24, 2017

@EruditeStranger

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

nsarafianos

nsarafianos commented on May 24, 2017

@nsarafianos
Author

@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

EruditeStranger commented on May 24, 2017

@EruditeStranger

@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

EruditeStranger commented on May 24, 2017

@EruditeStranger

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!

devshakyawarrahul

devshakyawarrahul commented on Jul 14, 2017

@devshakyawarrahul

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

cw1091293482 commented on Nov 1, 2017

@cw1091293482

@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

cw1091293482 commented on Nov 1, 2017

@cw1091293482

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

kyle-pena-nlp

kyle-pena-nlp commented on Nov 2, 2017

@kyle-pena-nlp

@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

llewis257 commented on Apr 18, 2018

@llewis257

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @eiderman@evanfeinberg@kyle-pena-nlp@EruditeStranger@cw1091293482

        Issue actions

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