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

support for list as output item, not only tensors #167

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions torchsummary/torchsummary.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,15 @@ def hook(module, input, output):
summary[m_key]["input_shape"] = list(input[0].size())
summary[m_key]["input_shape"][0] = batch_size
if isinstance(output, (list, tuple)):
summary[m_key]["output_shape"] = [
[-1] + list(o.size())[1:] for o in output
]
output_shape = []
for o in output:
if isinstance(o, (list, tuple)):
for item in o:
output_shape.append([-1] + list(item.size())[1:])
else:
output_shape.append([-1] + list(o.size())[1:])

summary[m_key]["output_shape"] = output_shape
else:
summary[m_key]["output_shape"] = list(output.size())
summary[m_key]["output_shape"][0] = batch_size
Expand Down