Skip to content
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

verbose=2 shows weights twice #247

Open
matthijsvk opened this issue Apr 28, 2023 · 1 comment
Open

verbose=2 shows weights twice #247

matthijsvk opened this issue Apr 28, 2023 · 1 comment

Comments

@matthijsvk
Copy link

Describe the bug

I want to see detail until layer.weight and layer.bias, and it seems this is only possible with verbose=2.
I tried setting max_depth=1000, but with verbose=1 the 'weight'/'bias' parameters are never shown in the summary.

With verbose=2, the weighs show up twice for some reason. Once at the top-level, and once under their actual layer (see below)

To Reproduce

import torch
import torch.nn as nn
from torchinfo import summary

model = nn.Sequential(
        nn.Linear(10,10),
        nn.Sequential(
            nn.Linear(10,10),
            nn.Linear(10,10)
        )
)

model_stats = summary(
    model,
    input_data=torch.randn(size=(1, 10)),
    verbose=2,
    col_names=["output_size", "kernel_size", "num_params", "mult_adds"], 
)

Output:

============================================================================================================================================
Layer (type:depth-idx)                   Output Shape              Kernel Shape              Param #                   Mult-Adds
============================================================================================================================================
Sequential                               [1, 10]                   --                        --                        --
├─Linear: 1-1                            [1, 10]                   --                        110                       110
│    └─weight                                                      [10, 10]                  ├─100
│    └─bias                                                        [10]                      └─10
├─Sequential: 1-2                        [1, 10]                   --                        --                        --
│    └─0.weight                                                    [10, 10]                  ├─100
│    └─0.bias                                                      [10]                      ├─10
│    └─1.weight                                                    [10, 10]                  ├─100
│    └─1.bias                                                      [10]                      └─10
│    └─Linear: 2-1                       [1, 10]                   --                        110                       110
│    │    └─weight                                                 [10, 10]                  ├─100
│    │    └─bias                                                   [10]                      └─10
│    └─Linear: 2-2                       [1, 10]                   --                        110                       110
│    │    └─weight                                                 [10, 10]                  ├─100
│    │    └─bias                                                   [10]                      └─10
============================================================================================================================================

Expected behavior

============================================================================================================================================
Layer (type:depth-idx)                   Output Shape              Kernel Shape              Param #                   Mult-Adds
============================================================================================================================================
Sequential                               [1, 10]                   --                        --                        --
├─Linear: 1-1                            [1, 10]                   --                        110                       110
│    └─weight                                                      [10, 10]                  ├─100
│    └─bias                                                        [10]                      └─10
├─Sequential: 1-2                        [1, 10]                   --                        --                        --
│    └─Linear: 2-1                       [1, 10]                   --                        110                       110
│    │    └─weight                                                 [10, 10]                  ├─100
│    │    └─bias                                                   [10]                      └─10
│    └─Linear: 2-2                       [1, 10]                   --                        110                       110
│    │    └─weight                                                 [10, 10]                  ├─100
│    │    └─bias                                                   [10]                      └─10
============================================================================================================================================
@rmekdma
Copy link

rmekdma commented Aug 1, 2023

For a temporary solution in Vim, you can eliminate duplicates using the following command: :%s/.*└.*\..*\n//g

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants