Reputation: 653
When using print on an existing model,
it doesn't print the model. Instead it shows:
<function resnext101_32x8d at 0x00000178CC26BA68>
>>> import torch
>>> import torchvision.models as models
>>> m1 = models.resnext101_32x8d
>>> print(m1)
<function resnext101_32x8d at 0x00000178CC26BA68>
>>>
When using summary
, it gives the following error:
AttributeError: 'function' object has no attribute 'apply'
>>> import torch
>>> import torchvision.models as models
>>> from torchvision import summary
>>> m1 = models.resnext101_32x8d
>>>
>>> summary(m1, (3, 224, 224))
Traceback(most recent call last):
File "<stdin>", line 1, in <module>
File torchsummary.py, line 68, in summary
model.apply(register_hook)
AttributeError: 'function' object has no attribute 'apply'
How to fix these issues related to print
and summary
? Any other ways to easily see all pytorch layers and model topology?
Upvotes: 2
Views: 1853
Reputation: 623
models.resnext101_32x8d
is the class constructor, you need to call the constructor, just add parentheses at the end.
m1 = models.resnext101_32x8d()
print(m1)
Upvotes: 1