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

avgpool的bug #19

Open
H1d30nbu3h opened this issue Sep 21, 2023 · 4 comments
Open

avgpool的bug #19

H1d30nbu3h opened this issue Sep 21, 2023 · 4 comments

Comments

@H1d30nbu3h
Copy link

我用hrsc训练的时候,通道注意力的

def forward(self, x):
avg_pool = F.avg_pool2d(x, x.size(2), stride=x.size(2))# 平均池化操作
res=self.gate_c(avg_pool).unsqueeze(2).unsqueeze(3).expand_as(x)# 通过通道注意力模块处理平均池化的结果
return res
平均池化报错了,RuntimeError: Given input size: (256x100x96). Calculated output size: (256x1x0). Output size is too small
因该是部分图片大小不太规矩,请问您当时是怎么解决的呢?

@IsenLwww
Copy link

IsenLwww commented Mar 9, 2024

我也遇到这个问题了,请问您当时解决了吗

@H1d30nbu3h
Copy link
Author

我也遇到这个问题了,请问您当时解决了吗

因为数据集有一张图片长宽是反的 h<w,所以你需要加一个判断,在
’tride = x.size(2)
if x.size(2) > x.size(3):
stride = x.size(3)
avg_pool = F.avg_pool2d(x, stride, stride=stride) # 平均池化操作
res = self.gate_c(avg_pool).unsqueeze(2).unsqueeze(3).expand_as(x)

给哥们点个赞

@IsenLwww
Copy link

我也遇到这个问题了,请问您当时解决了吗

因为数据集有一张图片长宽是反的 h<w,所以你需要加一个判断,在 ’tride = x.size(2) if x.size(2) > x.size(3): stride = x.size(3) avg_pool = F.avg_pool2d(x, stride, stride=stride) # 平均池化操作 res = self.gate_c(avg_pool).unsqueeze(2).unsqueeze(3).expand_as(x)

给哥们点个赞

谢谢大哥,太牛了

@IsenLwww
Copy link

我也遇到这个问题了,请问您当时解决了吗

因为数据集有一张图片长宽是反的 h<w,所以你需要加一个判断,在 ’tride = x.size(2) if x.size(2) > x.size(3): stride = x.size(3) avg_pool = F.avg_pool2d(x, stride, stride=stride) # 平均池化操作 res = self.gate_c(avg_pool).unsqueeze(2).unsqueeze(3).expand_as(x)

给哥们点个赞

大哥请问你遇到过这个问题吗
在losses.py里 max_pos, armmax_pos = pos.max(0)
RuntimeError: cannot perform reduction function max on tensor with no elements because the operation does not have an identity
自己解决得好像有些问题

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