Giter Site home page Giter Site logo

Comments (2)

taehoonlee avatar taehoonlee commented on May 13, 2024

@pgenevski, Keras-applications and TF-hub have different usages.

  1. Keras has its default session, and the keras model is created and initialized on the default session in your codes. Thus, once you create another session and work on the session, you must lose the pretrained weights. The keras's results are from random initialization.
  2. TF-Hub is not coupled with the default session, and defining global_variables_initializer as a loader of pretrained weights. Thus, you can get the same results on every newly created session in your codes, because the results are computed with pretrained weights.

from keras-applications.

pgenevski avatar pgenevski commented on May 13, 2024

Thank you! Indeed it turned out that Keras would load the weights into its own session as soon as the model is instantiated. A possible workaround is to instantiate the tf session first, set it explicitly on the Keras backend and then use the model as a tensor in the tf graph (as specified in the functional Keras API).
I have updated the notebook to reflect this approach.

As a side note, although it works, IMHO it would have been cleaner if Keras used tf variable initializers instead of eagerly materializing the model weights upon creation.

from keras-applications.

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.