Skip to content

Commit

Permalink
Improve file editor html
Browse files Browse the repository at this point in the history
  • Loading branch information
fchollet committed Sep 27, 2024
1 parent 3fb091f commit 57677d8
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions keras/src/saving/file_editor.py
Original file line number Diff line number Diff line change
Expand Up @@ -553,14 +553,16 @@ def _weights_summary_cli(self):

def _weights_summary_interactive(self):

def _generate_html_weights(dictionary, margin_left=0, font_size=20):
def _generate_html_weights(dictionary, margin_left=0, font_size=1):
html = ""
for key, value in dictionary.items():
if isinstance(value, dict) and value:
html += (
f'<details style="margin-left: {margin_left}px;">'
+ f'<summary style="font-size: {font_size}px;">'
+ f"{key}</summary>"
+ '<summary style="'
+ f'font-size: {font_size}em; '
+ "font-weight: 'bold';"
+ f'">{key}</summary>'
+ _generate_html_weights(
value, margin_left + 20, font_size - 1
)
Expand All @@ -569,7 +571,7 @@ def _generate_html_weights(dictionary, margin_left=0, font_size=20):
else:
html += (
f'<details style="margin-left: {margin_left}px;">'
+ f'<summary style="font-size: {font_size}px;">'
+ f'<summary style="font-size: {font_size}em;">'
+ f"{key} : shape={value.shape}"
+ f", dtype={value.dtype}</summary>"
+ f"<div style="
Expand Down

0 comments on commit 57677d8

Please sign in to comment.