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

RuntimeError: Expected 4-dimensional input for 4-dimensional weight [64, 64, 3, 3], but got 3-dimensional input of size [64, 104, 144] instead #25

Open
Boyang-Song opened this issue Nov 30, 2024 · 2 comments

Comments

@Boyang-Song
Copy link

作者大大打扰您,我也遇到类似的错误,然后我发现问题应该出在FPN网络中这里:
src_enhanced_map = seq2map(src_epipolar,idx_back[-2:],size=(C,H,W))
src_enhanced_map_la = self.la(src_enhanced_map)
src_enhanced_map = torch.where((torch.sum(abs(src_enhanced_map),dim=0)==0).squeeze(0).repeat(C,1,1),src_enhanced_map_la,src_enhanced_map)
src_intra[b] = src_intra[b] + self.res(src_enhanced_map)

src_enhanced_map是C,H,W三维的,然后使用self.la = nn.Conv2d(final_chs, final_chs, 3, bias=False,padding=1)卷积时报错,输入应该是四维不是三维。请问是我下载的这版代码有问题吗?我看只有一个人有过类似问题○| ̄|_

@TQTQliu
Copy link
Owner

TQTQliu commented Nov 30, 2024

您好,应该是环境问题,您可以根据Readme检查一下。
或者,您可以将报错的那行src_enhanced_map_la = self.la(src_enhanced_map)改为src_enhanced_map_la = self.la(src_enhanced_map.unsqueeze(0)).squeeze(0).

@Boyang-Song
Copy link
Author

好的好的,感谢您,我确实已经用了第二种方法,可能是环境不同,三维张量输入二维卷积没有自动补齐为四维张量

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

2 participants