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

summary cannot be used to log output in a file.

Open sidhartha-roy opened this issue 4 years ago • 3 comments

The summary module is only good if I want to view it in my notebook or terminal. Not if I want to add it to a logging file.

sidhartha-roy avatar Jun 17 '20 04:06 sidhartha-roy

Just use summary_string instead of summary.

cifkao avatar Aug 11 '20 16:08 cifkao

For some reason, I didn't have summary_string although I have the latest version from pip.

I copy-pasted the version from github. I needed to modify the code because I don't have CUDA and it's the default option with the module. I modified the code as follows:

def summary(model, input_size, batch_size=-1, device={}, dtypes=None):
    if not device: device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
    result, params_info = summary_string(
        model, input_size, batch_size, device, dtypes)
    print(result)

    return params_info


def summary_string(model, input_size, batch_size=-1, device={}, dtypes=None):
    if not device: device = torch.device("cuda" if torch.cuda.is_available() else "cpu")
...

chrismaliszewski avatar Sep 02 '20 02:09 chrismaliszewski

What @chrismaliszewski wrote is still true, the github and pip versions are the same number but different code. Any update on this front?

Dario-Mantegazza avatar Feb 17 '21 14:02 Dario-Mantegazza