Skip to content

Commit

Permalink
Delete layer checkpoint deps
Browse files Browse the repository at this point in the history
  • Loading branch information
nkovela1 committed Dec 14, 2023
1 parent e669c27 commit d83362d
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions keras_nlp/utils/preset_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -165,12 +165,14 @@ def legacy_load_weights(layer, weights_path):
# We find the `Functional` class, and temporarily remove the
# `_layer_checkpoint_dependencies` property, which on older version of
# TensorFlow complete broke the variable paths for functional models.
property = layer._layer_checkpoint_dependencies
layer._layer_checkpoint_dependencies = None
try:
layer.load_weights(weights_path)
finally:
layer._layer_checkpoint_dependencies = property
functional_cls = None
for cls in inspect.getmro(layer.__class__):
if cls.__name__ == "Functional":
functional_cls = cls
property = functional_cls._layer_checkpoint_dependencies
del functional_cls._layer_checkpoint_dependencies
layer.load_weights(weights_path)
functional_cls._layer_checkpoint_dependencies = property


def load_from_preset(
Expand Down

0 comments on commit d83362d

Please sign in to comment.