GithubHelp home page GithubHelp logo

Getting error when calculating entropy for each images in the batch in the input tensor in a custom layer in tensorflow/Keras. about tf-keras HOT 8 OPEN

DeveshS215 avatar DeveshS215 commented on May 16, 2024
Getting error when calculating entropy for each images in the batch in the input tensor in a custom layer in tensorflow/Keras.

from tf-keras.

Comments (8)

tilakrayal avatar tilakrayal commented on May 16, 2024

@sachinprasadhs,
I was able to reproduce the issue on tensorflow v2.11 and tf-nightly. Kindly find the gist of it here.

from tf-keras.

haifeng-jin avatar haifeng-jin commented on May 16, 2024

@DeveshS215 Seems the problem is tf.get_static_value(image_ith_filter_entropy) returns None because of the tensor value cannot be calculated.
Would you please help simplify the code to the specific function and its arguments?

Thanks.

from tf-keras.

DeveshS215 avatar DeveshS215 commented on May 16, 2024

@haifeng-jin

Thank you for your help. But the thing is I already provided the simplified code as much I can. I can't simplify more because I need to calculate the entropy of each feature map of each image. But in keras layer the batch size is None during model building and so we can't calculate entropy and this is the reason of getting error and I am unable to resolve it.

from tf-keras.

Frightera avatar Frightera commented on May 16, 2024

@DeveshS215 I think the above gist is not complete as entropy_sort_index is not defined. Also it is not clear to me what .item() method should do in this case? Can you clarify it a bit more?

Thanks.

from tf-keras.

haifeng-jin avatar haifeng-jin commented on May 16, 2024

After consulting the team, we do not aware of any good solution. Let's leave this issue open to see if we can either find some community help on how to implement or consolidate the feature request to a more concrete one.

from tf-keras.

DeveshS215 avatar DeveshS215 commented on May 16, 2024

@Frightera Thanks for pointing my mistake. Actually its not entropy_sort_index instead it is entropy_array . I have corrected it. I am really sorry for it.

For .item() method : I need value of image_ith_filter_entropy to append in entropy list as number, so I used .item() to get the value as number because tf.get_static_value() returns value in ndarray format.

Thanks.

from tf-keras.

DeveshS215 avatar DeveshS215 commented on May 16, 2024

@haifeng-jin

OK.
Thanks for your help.

from tf-keras.

Frightera avatar Frightera commented on May 16, 2024

@DeveshS215 I see, so if it is a scalar value, maybe you can employ some logic using tf.reduce.xxx.

from tf-keras.

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.