Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError: 'torch.Size' object has no attribute 'numel' #6

Closed
Hansoluo opened this issue Nov 7, 2018 · 8 comments
Closed

AttributeError: 'torch.Size' object has no attribute 'numel' #6

Hansoluo opened this issue Nov 7, 2018 · 8 comments

Comments

@Hansoluo
Copy link

Hansoluo commented Nov 7, 2018

When I use it to test my net, it reports an error:
File "/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'

And I found in pytorch documents torch.numel , only tensor have the attribute 'numel'. So, I have no idea How can I get this to work.If anyone can help, thanks.

I use python 3.5 Pytorch 0.4.1.

@yaotc
Copy link

yaotc commented Nov 16, 2018

the same error .

lyakaap added a commit to lyakaap/torchstat that referenced this issue Nov 20, 2018
@lyakaap
Copy link

lyakaap commented Nov 20, 2018

I fixed this problem. See #8

@woaichipinngguo
Copy link

I encountered the error again. @Hansoluo @Swall0w

@Hansoluo
Copy link
Author

Hansoluo commented Nov 22, 2018

@woaichipinngguo @yaotc I used this file compute_memory.py to replace original compute_memory.py. And it worked for me. @lyakaap, Thanks for your help.

@woaichipinngguo
Copy link

ConvTranspose2d and Upsample are not supported. @Hansoluo

@yaotc
Copy link

yaotc commented Nov 23, 2018

compute_memory.py

@Hansoluo @lyakaap Thank you all ~ It worked!

@Hansoluo
Copy link
Author

Hansoluo commented Nov 23, 2018

@woaichipinngguo "Upsample" layer have no paraments when inference, so inference memory and Flops is zero. "ConvTranspose2d" maybe you can use this math equation to calculate by hand. Or you can use it as same as "Conv2d", just add this layer in script.

def compute_memory(module, inp, out):
    ...
    elif isinstance(module, nn.ConvTranspose2d):
         return compute_Conv2d_memory(module, inp, out)
    ....

ZhouShengsheng added a commit to ZhouShengsheng/torchstat that referenced this issue Apr 18, 2019
@xiaoketongxue
Copy link

I used this file compute_memory.py to replace original compute_memory.py.
but
File "D:\Anaconda3\lib\site-packages\torchstat\compute_memory.py", line 57, in compute_Conv2d_memory
mwrite = out.numel()

AttributeError: 'torch.Size' object has no attribute 'numel'
This is why?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants