torchstat icon indicating copy to clipboard operation
torchstat copied to clipboard

when i run the module,i got this error

Open Re3write opened this issue 6 years ago • 4 comments

File "static.py", line 10, in stat(model,(3,224,224)) File "/home/sk49/.local/lib/python3.6/site-packages/torchstat/statistics.py", line 71, in stat ms.show_report() File "/home/sk49/.local/lib/python3.6/site-packages/torchstat/statistics.py", line 64, in show_report collected_nodes = self._analyze_model() File "/home/sk49/.local/lib/python3.6/site-packages/torchstat/statistics.py", line 57, in _analyze_model model_hook = ModelHook(self._model, self._input_size) File "/home/sk49/.local/lib/python3.6/site-packages/torchstat/model_hook.py", line 24, in init self._model(x) File "/home/sk49/.local/lib/python3.6/site-packages/torch/nn/modules/module.py", line 477, in call result = self.forward(*input, **kwargs) File "/home/sk49/.local/lib/python3.6/site-packages/torchvision/models/resnet.py", line 138, in forward x = self.conv1(x) File "/home/sk49/.local/lib/python3.6/site-packages/torchstat/model_hook.py", line 78, in wrap_call Memory = compute_memory(module, input[0], output) File "/home/sk49/.local/lib/python3.6/site-packages/torchstat/compute_memory.py", line 12, in compute_memory return compute_Conv2d_memory(module, inp, out) File "/home/sk49/.local/lib/python3.6/site-packages/torchstat/compute_memory.py", line 57, in compute_Conv2d_memory mread = batch_size * (inp.size()[1:].numel() + num_params(module)) AttributeError: 'torch.Size' object has no attribute 'numel'

the code just like this :

from torchstat import stat import torchvision.models as models

model = models.resnet18() stat(model, (3, 224, 224))

Re3write avatar Jan 28 '19 09:01 Re3write

I have the same error. Have you solved it?

ghost avatar Feb 27 '19 02:02 ghost

I have exactly the same error!

Steve-Tod avatar May 14 '19 13:05 Steve-Tod

By installing the fixed version from https://github.com/lyakaap/torchstat, I can run the code successfully

Steve-Tod avatar May 14 '19 13:05 Steve-Tod

By installing the fixed version from https://github.com/lyakaap/torchstat, I can run the code successfully

解决啦多谢,就是下载这个repo的相应版本就行,其实替换comput_parameters.py就ok了

JiangMei0201 avatar Mar 18 '22 11:03 JiangMei0201