问题说明:
安装torchsummary后,运行代码出现报错。
pip install torchsummary
出现报错:AttributeError: 'tuple' object has no attribute 'size'
百度后寻找到解决方法!应该是pip下载包的版本有问题!
百度找到的解决方法原文在文末。
解决方法
首先进入Github: https://github.com/Bond-H/pytorch-summary。
code下载后找到自己虚拟环境安装位置,进入
D:\anaconda3\envs\torch39\Lib\site-packages\torchsummary
torch39处为自己虚拟环境名字
如下图
把code下来的文件替换到自己的目录下
重启jupyter后再次运行代码
成功运行!
原文地址:https://clay-atlas.com/blog/2020/05/13/pytorch-cn-note-torch-summary-no-attribute-size/