From 560dc83ab9a1cf247b4175a41fdb67636a559660 Mon Sep 17 00:00:00 2001 From: Francois Chollet Date: Mon, 11 Sep 2023 10:10:32 -0700 Subject: [PATCH] Fixed saved file namespace. PiperOrigin-RevId: 564423073 --- keras/saving/saving_lib.py | 4 ++-- keras/saving/saving_lib_test.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/keras/saving/saving_lib.py b/keras/saving/saving_lib.py index a50dd1998ee..e685d1aa09a 100644 --- a/keras/saving/saving_lib.py +++ b/keras/saving/saving_lib.py @@ -62,6 +62,7 @@ "_callable_losses", "_captured_weight_regularizer", "_checkpoint_dependencies", + "_layer_checkpoint_dependencies", "_deferred_dependencies", "_eager_losses", "_inbound_nodes", @@ -71,7 +72,6 @@ "_keras_api_names", "_keras_api_names_v1", "_name_based_restores", - "_non_trainable_weights", "_outbound_nodes", "_outbound_nodes_value", "_saved_model_arg_spec", @@ -364,7 +364,7 @@ def _write_to_zip_recursively(zipfile_to_save, system_path, zip_path): def _walk_trackable(trackable): - for child_attr in dir(trackable): + for child_attr in sorted(dir(trackable), reverse=True): if child_attr.startswith("__") or child_attr in ATTR_SKIPLIST: continue try: diff --git a/keras/saving/saving_lib_test.py b/keras/saving/saving_lib_test.py index d13c3457a59..b18bf86618b 100644 --- a/keras/saving/saving_lib_test.py +++ b/keras/saving/saving_lib_test.py @@ -749,7 +749,7 @@ def test_layer_index_naming(self): model.save_weights(weights_filepath) with h5py.File(weights_filepath, "r") as f: self.assertAllEqual( - list(f["_layer_checkpoint_dependencies"].keys()), + list(f["layers"].keys()), ["dense", "dense_1", "dense_2", "dense_3"], )