sksq96 / pytorch-summary

Model summary in PyTorch similar to `model.summary()` in Keras
MIT License
3.98k stars 412 forks source link

summary cannot be used to log output in a file. #137

Open sidhartha-roy opened 4 years ago

sidhartha-roy commented 4 years ago

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.

cifkao commented 3 years ago

Just use summary_string instead of summary.

chrismaliszewski commented 3 years ago

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")
...
Dario-Mantegazza commented 3 years ago

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