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

When running DenseNet and MobileNet I got the following errors #2

Closed
sriharsha0806 opened this issue Apr 24, 2018 · 5 comments
Closed

Comments

@sriharsha0806
Copy link

MobileNet:
Traceback (most recent call last):
File "MobileNet.py", line 365, in
summary(model, (3,32,32))
File "/home/sriharsha/miniconda3/lib/python3.6/site-packages/torchsummary/torchsummary.py", line 56, in summary
model(x)
File "/home/sriharsha/miniconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 357, in call
result = self.forward(*input, **kwargs)
File "MobileNet.py", line 114, in forward
x = self.model(x)
File "/home/sriharsha/miniconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 357, in call
result = self.forward(*input, **kwargs)
File "/home/sriharsha/miniconda3/lib/python3.6/site-packages/torch/nn/modules/container.py", line 67, in forward
input = module(input)
File "/home/sriharsha/miniconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 357, in call
result = self.forward(*input, **kwargs)
File "/home/sriharsha/miniconda3/lib/python3.6/site-packages/torch/nn/modules/container.py", line 67, in forward
input = module(input)
File "/home/sriharsha/miniconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 359, in call
hook_result = hook(self, input, result)
File "/home/sriharsha/miniconda3/lib/python3.6/site-packages/torchsummary/torchsummary.py", line 28, in hook
params += th.prod(th.LongTensor(list(module.bias.size())))
AttributeError: 'NoneType' object has no attribute 'size'

DenseNet:
Traceback (most recent call last):
File "DenseNet.py", line 237, in
summary(model, (3,32,32))
File "/home/sriharsha/miniconda3/lib/python3.6/site-packages/torchsummary/torchsummary.py", line 56, in summary
model(x)
File "/home/sriharsha/miniconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 357, in call
result = self.forward(*input, **kwargs)
File "DenseNet.py", line 226, in forward
features = self.features(x)
File "/home/sriharsha/miniconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 357, in call
result = self.forward(*input, **kwargs)
File "/home/sriharsha/miniconda3/lib/python3.6/site-packages/torch/nn/modules/container.py", line 67, in forward
input = module(input)
File "/home/sriharsha/miniconda3/lib/python3.6/site-packages/torch/nn/modules/module.py", line 359, in call
hook_result = hook(self, input, result)
File "/home/sriharsha/miniconda3/lib/python3.6/site-packages/torchsummary/torchsummary.py", line 28, in hook
params += th.prod(th.LongTensor(list(module.bias.size())))
AttributeError: 'bool' object has no attribute 'size'

@sksq96
Copy link
Owner

sksq96 commented Apr 24, 2018

  • Yes, I verified the error for DenseNet and MobileNet.
  • I found a bug, pertinent to bias in the code, which I'll fix.
  • Meanwhile could you share the implementation you used, to be sure the bugfix solves the issue.

@MKFMIKU
Copy link

MKFMIKU commented Apr 25, 2018

Face same error too on DenseNet

@sksq96
Copy link
Owner

sksq96 commented Apr 25, 2018

I have fixed the issue with these models. Please upgrade the package or pull the latest code to test the changes.

I'm closing this issue, feel free to open it up if you face any further issues.

@sksq96 sksq96 closed this as completed Apr 25, 2018
@Hrushikesh-github
Copy link

torchsummary is not working for densenet

>>> model2 = densenet121(pretrained=False)
>>> img = (3, 227, 227)
>>> summary(model2, img)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torchsummary/torchsummary.py", line 72, in summary
    model(*x)
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torchvision/models/densenet.py", line 192, in forward
    features = self.features(x)
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torch/nn/modules/container.py", line 117, in forward
    input = module(input)
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torchvision/models/densenet.py", line 111, in forward
    new_features = layer(features)
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torch/nn/modules/module.py", line 731, in _call_impl
    hook_result = hook(self, input, result)
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torchsummary/torchsummary.py", line 19, in hook
    summary[m_key]["input_shape"] = list(input[0].size())
AttributeError: 'list' object has no attribute 'size'
>>> img = (3, 224, 224)
>>> summary(model2, img)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torchsummary/torchsummary.py", line 72, in summary
    model(*x)
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torchvision/models/densenet.py", line 192, in forward
    features = self.features(x)
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torch/nn/modules/container.py", line 117, in forward
    input = module(input)
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torchvision/models/densenet.py", line 111, in forward
    new_features = layer(features)
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torch/nn/modules/module.py", line 731, in _call_impl
    hook_result = hook(self, input, result)
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torchsummary/torchsummary.py", line 19, in hook
    summary[m_key]["input_shape"] = list(input[0].size())
AttributeError: 'list' object has no attribute 'size'

@swuxyj
Copy link

swuxyj commented Apr 13, 2021

torchsummary is not working for densenet

>>> model2 = densenet121(pretrained=False)
>>> img = (3, 227, 227)
>>> summary(model2, img)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torchsummary/torchsummary.py", line 72, in summary
    model(*x)
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torchvision/models/densenet.py", line 192, in forward
    features = self.features(x)
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torch/nn/modules/container.py", line 117, in forward
    input = module(input)
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torchvision/models/densenet.py", line 111, in forward
    new_features = layer(features)
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torch/nn/modules/module.py", line 731, in _call_impl
    hook_result = hook(self, input, result)
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torchsummary/torchsummary.py", line 19, in hook
    summary[m_key]["input_shape"] = list(input[0].size())
AttributeError: 'list' object has no attribute 'size'
>>> img = (3, 224, 224)
>>> summary(model2, img)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torchsummary/torchsummary.py", line 72, in summary
    model(*x)
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torchvision/models/densenet.py", line 192, in forward
    features = self.features(x)
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torch/nn/modules/container.py", line 117, in forward
    input = module(input)
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torch/nn/modules/module.py", line 727, in _call_impl
    result = self.forward(*input, **kwargs)
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torchvision/models/densenet.py", line 111, in forward
    new_features = layer(features)
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torch/nn/modules/module.py", line 731, in _call_impl
    hook_result = hook(self, input, result)
  File "/home/hrushikesh/.local/bin/.virtualenvs/adityaya/lib/python3.6/site-packages/torchsummary/torchsummary.py", line 19, in hook
    summary[m_key]["input_shape"] = list(input[0].size())
AttributeError: 'list' object has no attribute 'size'

I also faced this problem until pip install torch-summary==1.4.4

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