Skip to content
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
11 changes: 11 additions & 0 deletions torchsummary/torchsummary.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@ def hook(module, input, output):
summary[m_key]["output_shape"] = [
[-1] + list(o.size())[1:] for o in output
]
'''
Adding check for dictionaries in the output. Dictionary are faster
for lookup and makes for more readable code.
'''
if isinstance(output, (dict)):
summary[m_key]["output_shape" ] = [
[-1] + list(output[key].size())[1:] for key in
output.keys()
]
print(summary[m_key]["output_shape"])

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