YimianDai / open-aff

code and trained models for "Attentional Feature Fusion"
729 stars 95 forks source link

ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1, 256, 1, 1]) #43

Open war0927 opened 1 year ago

war0927 commented 1 year ago

我采用你的方法进行特征融合, nn.AdaptiveAvgPool2d(1), nn.Conv2d(channels, inter_channels, kernel_size=1, stride=1, padding=0), nn.BatchNorm2d(inter_channels), nn.ReLU(inplace=True), nn.Conv2d(inter_channels, channels, kernel_size=1, stride=1, padding=0), nn.BatchNorm2d(channels), 第一行将自适应池化的输出按照原文设为1时会报错ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1, 256, 1, 1]),请问有解决办法吗。

Xj1567589354 commented 11 months ago

这种维度不匹配的问题就不要问了咯,对齐维度不就好了,这种低级错误

liyiersan commented 5 months ago

batch size设置为1,使用BN层没有意义,把Batch size改为大于1即可。