Skip to content

Commit

Permalink
Export KerasFileEditor
Browse files Browse the repository at this point in the history
  • Loading branch information
fchollet committed Sep 23, 2024
1 parent f1da798 commit d85036c
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 7 deletions.
1 change: 1 addition & 0 deletions keras/api/_tf_keras/keras/saving/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
since your modifications would be overwritten.
"""

from keras.src.saving.file_editor import KerasFileEditor
from keras.src.saving.object_registration import CustomObjectScope
from keras.src.saving.object_registration import (
CustomObjectScope as custom_object_scope,
Expand Down
1 change: 1 addition & 0 deletions keras/api/saving/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
since your modifications would be overwritten.
"""

from keras.src.saving.file_editor import KerasFileEditor
from keras.src.saving.object_registration import CustomObjectScope
from keras.src.saving.object_registration import (
CustomObjectScope as custom_object_scope,
Expand Down
10 changes: 3 additions & 7 deletions keras/src/saving/file_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import rich.console

from keras.src import backend
from keras.src.api_export import keras_export
from keras.src.saving import saving_lib
from keras.src.saving.saving_lib import H5IOStore
from keras.src.utils import naming
Expand All @@ -31,6 +32,7 @@ def is_ipython_notebook():
return False


@keras_export("keras.saving.KerasFileEditor")
class KerasFileEditor:
"""Utility to inspect, edit, and resave Keras weights files.
Expand Down Expand Up @@ -97,10 +99,7 @@ def __init__(

def summary(self):
"""Prints the weight structure of the opened file."""
if is_ipython_notebook():
self._weights_summary_iteractive()
else:
self._weights_summary_cli()
self._weights_summary_cli()

def compare_to(self, reference_model):
"""Compares the opened file to a reference model.
Expand Down Expand Up @@ -565,9 +564,6 @@ def _generate_html_weights(dictionary, margin_left=0, font_size=20):
output = "Weights structure"
output += _generate_html_weights(self.weights_dict)

if is_ipython_notebook():
ipython.display.display(ipython.display.HTML(output))


def get_weight_spec_of_saveable(saveable, spec, visited_saveables=None):

Expand Down

0 comments on commit d85036c

Please sign in to comment.