pytorch-summary icon indicating copy to clipboard operation
pytorch-summary copied to clipboard

Save the model summary

Open arielsolomon opened this issue 4 years ago • 1 comments

Hi, How can I save the model summary output to variable? text file? print to file?

arielsolomon avatar Feb 25 '21 07:02 arielsolomon

The current version could support your need. Please use the newest GitHub version instead of the version installed by PyPI, because torchsummary.summary_string does not exist in torchsummary 1.5.1.

Here is an example:

import torchsummary
module = ... # Get my torch.nn.Module
with open('my_module_log.log', 'w') as f:
    report, _ = torchsummary.summary_string(model, ...)
    f.write(report)

cainmagi avatar Feb 28 '21 04:02 cainmagi