Skip to content

Truncation during non-interactive model summary printing #21107

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
ryan-gustafson opened this issue Mar 28, 2025 · 2 comments
Open

Truncation during non-interactive model summary printing #21107

ryan-gustafson opened this issue Mar 28, 2025 · 2 comments

Comments

@ryan-gustafson
Copy link

When printing a model summary non-interactively, the provided line_width is not honored, resulting in right-side truncation in the file context. The rich table's default of 80 seems to be used instead.

Changing:

highlight=False, force_terminal=False, color_system=None

Locally, if I set width to line_width, it produces the expected file contents:

   highlight=False, force_terminal=False, color_system=None, width=line_length

Example of non-interactive model printing with line_length > 80:

    with open(summary_path, 'w') as f:
        model.summary(expand_nested=True, show_trainable=True, line_length=120,
                      print_fn=lambda x: f.write(x + '\n'))
@dhantule
Copy link
Contributor

dhantule commented Apr 3, 2025

Hi @ryan-gustafson, thanks for reporting this.

I have reproduced this issue and I also faced truncation when printing model summary non interactively with line_length>80

Model: "sequential_24"
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┳━━━━━━━━━━━━━━━━━━━━┳━━━━━━━
┃ Layer (type)                                  ┃ Output Shape                        ┃            Param # ┃ Traina
┡━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━╇━━━━━━━━━━━━━━━━━━━━╇━━━━━━━
│ dense_48 (Dense)                              │ (None, 28, 128)                     │              3,712 │     Y 
├───────────────────────────────────────────────┼─────────────────────────────────────┼────────────────────┼───────
│ dense_49 (Dense)                              │ (None, 28, 10)                      │              1,290 │     Y 
└───────────────────────────────────────────────┴─────────────────────────────────────┴────────────────────┴───────
 Total params: 5,002 (19.54 KB)
 Trainable params: 5,002 (19.54 KB)
 Non-trainable params: 0 (0.00 B)


Can you open a PR?

Copy link

This issue is stale because it has been open for 14 days with no activity. It will be closed if no further activity occurs. Thank you.

@github-actions github-actions bot added the stale label Apr 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants