我是靠谱客的博主 俭朴小蝴蝶,这篇文章主要介绍RuntimeError mat1 dim 1 must match mat2 dim 0RuntimeError: mat1 dim 1 must match mat2 dim 0,现在分享给大家,希望可以做个参考。
RuntimeError: mat1 dim 1 must match mat2 dim 0
代码
self.fc1 = nn.Linear(128, 120)
self.fc2 = nn.Linear(120, 84)
假设forward中要依次执行fc1和fc2
fc1的out_features 等于fc2的in_features就不会有错误,这里都是120不会有错误
反之
self.fc1 = nn.Linear(128, 121)
self.fc2 = nn.Linear(120, 84)
则出现让面的错误提示
最后
以上就是俭朴小蝴蝶最近收集整理的关于RuntimeError mat1 dim 1 must match mat2 dim 0RuntimeError: mat1 dim 1 must match mat2 dim 0的全部内容,更多相关RuntimeError内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复