GithubHelp home page GithubHelp logo

Comments (5)

vivekjoshy avatar vivekjoshy commented on June 2, 2024

What's even more weirder is that I'm defining the input sizes explicitly like so:

Config.COMPUTED_BATCH_SIZE = 128

with strategy.scope():
    model = my_model()
    input_shapes = [
        [Config.COMPUTED_BATCH_SIZE, 192], 
        [Config.COMPUTED_BATCH_SIZE, 192], 
        [COMPUTED_CHANNELS, 105, 129, 100], 
        [COMPUTED_CHANNELS, 105, 129, 100], 
        [COMPUTED_CHANNELS, 105, 129, 100], 
        [Config.COMPUTED_BATCH_SIZE, 70], 
        [Config.COMPUTED_BATCH_SIZE, 320]
    ]
    model.build(input_shape=input_shapes)

But the batch size shown in the error log is 256 in [70, 256] which I assume is the transposed tensor.

Ignore this since it appears that Hidden Size * 2 is also 256. So it could be a transpose inside a Dense layer.

Edit:

I've tracked it down to this code:

hidden_size = 128
self.descriptor_embedding = layers.Dense(
    hidden_size * 2, # 256
    activation='relu',
    input_shape=(Config.COMPUTED_BATCH_SIZE, 70)
)


learned_descriptors = tf.expand_dims(
    self.descriptor_embedding(descriptors),
    1
) # [BS, 1, HS * 2]

from tensorflow.

vivekjoshy avatar vivekjoshy commented on June 2, 2024

It seems to be an issue with tf.expand_dims(x, axis=1). Any axis other than 0 will cause this error. tf.transpose also causes this error.

from tensorflow.

tilakrayal avatar tilakrayal commented on June 2, 2024

@vivekjoshy,
When I tried to execute the code by explicitly setting the size after you decode, using tf.reshape, the code was executed successfully. While with the other approach it was executed with the error.

tf.reshape(tf.image.decode_jpeg(image, channels = 3),[256,256, 3]), class_idx

Kindly find the gist of it here.

from tensorflow.

vivekjoshy avatar vivekjoshy commented on June 2, 2024

Fixed by passing in explicit shapes everywhere.

from tensorflow.

google-ml-butler avatar google-ml-butler commented on June 2, 2024

Are you satisfied with the resolution of your issue?
Yes
No

from tensorflow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.