hub icon indicating copy to clipboard operation
hub copied to clipboard

Fix KerasLayer compatibility with Keras 3.x/TF 2.16+

Open athulya-anil opened this issue 3 months ago • 1 comments

Fixes #101201

  • Replaced deprecated _add_existing_weight implementation that previously relied on unsupported arguments (experimental_autocast, getter) removed in Keras 3.x.
  • Introduced custom weight lists (_hub_trainable_weights, _hub_non_trainable_weights) instead of using the deprecated _track_variable approach.
  • Overrode trainable_weights and non_trainable_weights properties to properly expose hub weights to the Keras layer system.
  • Resolves the ValueError: Only instances of keras.Layer can be added to a Sequential model and related integration failures when using hub.KerasLayer in Sequential/Functional models.

athulya-anil avatar Sep 27 '25 18:09 athulya-anil

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

google-cla[bot] avatar Sep 27 '25 18:09 google-cla[bot]