Skip to content

Unable to handle atomic values (int, float, etc) in output #110

@wyc1997

Description

@wyc1997

When I tried to run summary() on a pytorch YOLOv3 implementation
an error was thrown:

...
  File "/home/secret/anaconda3/lib/python3.7/site-packages/torchsummary/torchsummary.py", line 23, in <listcomp>
    [-1] + list(o.size())[1:] for o in output
AttributeError: 'int' object has no attribute 'size'

I looked into the both the models and the torchsummary and realize that the model implementation returns both the output tensor and the loss value as a tuple. Therefore, when the loss value is passed into the output o.size() will fail.
This can be fix by checking for list and tuple before passing o to o.size()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions