Giter Site home page Giter Site logo

Comments (5)

mattdangerw avatar mattdangerw commented on June 26, 2024 1

@miticollo good point. Perhaps?

Still rubs me the wrong way that model.layers would return something that is not a layer. Users should be able to confidently call any layer method (e.g. layer.count_params()) on everything inside model.layers in a loop. Though potentially we should also have model summary plot ops as well as layers, in which case we should not sure model.layers to loop through everything.

For now I will open a bug in core Keras, assign to myself, and mark open for contributions.

from keras-nlp.

chunduriv avatar chunduriv commented on June 26, 2024

cc: @mattdangerw

from keras-nlp.

miticollo avatar miticollo commented on June 26, 2024

This is a semantic issue.

AttributeError is raised here because a keras.ops (like GetItem) doesn't have the weights property.
In Keras, a Layer is an Operation, but vice versa is not true. Anyway, a Functional model can also include raw Keras 3 ops.
Maybe, a dirty workaround could be to add the weights property to Operation class:

@property
def weights(self):
    weights = []
    return weights

IMO this solution is not semantically correct because weights for an operation don't make any sense.

Or an alternative solution could be to wrap the keras.ops into a Lambda layer. I prefer avoiding this layer because of its limitations but maybe in this case it can be used safe.

Finally this issue should be moved in keras repository.

from keras-nlp.

mattdangerw avatar mattdangerw commented on June 26, 2024

Thanks @miticollo. Agreed, this should move to the keras repo.

Could we just have models.layers filter down to only return Layer and not Operation? That's what is used by the summary utils, and generally speaking I think having model.layers return something that is not a Layer is just unexpected.

Not sure if anything would break, but we could try it out. @miticollo are you interested in taking it on?

from keras-nlp.

miticollo avatar miticollo commented on June 26, 2024

Thank u for the answer! At the moment I'm a bit busy with the latest exams at University (one is on Deep Learning). So I can't do it.
Anyway using a filter it could be a good a idea. But currently summary shows also the keras.ops. So is this behaviour still intended?

from keras-nlp.

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.