LoraLinH / Boosting-Crowd-Counting-via-Multifaceted-Attention

Official Implement of CVPR 2022 paper 'Boosting Crowd Counting via Multifaceted Attention'
MIT License
105 stars 19 forks source link

BS不能修改呀 #7

Open yangtle opened 1 year ago

yangtle commented 1 year ago

batch size只能设置1,多了的话mask和feature相乘就会有错误

JinanZou commented 1 year ago

batch size为什么是1呢,有同样的问题。

H-Hui2277 commented 1 year ago

问题主要在transfomer_cosine.TransformerEncoderLayer.forward_post和forward_pre这两个方法中。 def forward_post(self,src, shape,... def forward_pre(self,src, shape,.. 其中默认了参数src的第二维为1(使用的是torch.squeeze(src, dim=1),将为1的维度压缩了),导致后面的consistent_feature计算时,consistent_feature = torch.matmul(mask, feature),mask形状为(256, 256),而feature的形状在batch>1时为(256, batch, 512),两者进行叉乘则会出现错误。 虽然可以将suqeeze函数改成flatten,feature计算编程feature = torch.flatten(src, 1),这样就可以处理batch>1的输入了,但是不太清楚这样处理是否符合作者原本的设计,这个操作我还不是很熟悉。

ZZZ429 commented 1 year ago

问题主要在transfomer_cosine.TransformerEncoderLayer.forward_post和forward_pre这两个方法中。 def forward_post(self,src, shape,... def forward_pre(self,src, shape,.. 其中默认了参数src的第二维为1(使用的是torch.squeeze(src, dim=1),将为1的维度压缩了),导致后面的consistent_feature计算时,consistent_feature = torch.matmul(mask, feature),mask形状为(256, 256),而feature的形状在batch>1时为(256, batch, 512),两者进行叉乘则会出现错误。 虽然可以将suqeeze函数改成flatten,feature计算编程feature = torch.flatten(src, 1),这样就可以处理batch>1的输入了,但是不太清楚这样处理是否符合作者原本的设计,这个操作我还不是很熟悉。

您好 这么修改会导致精度下降吗

wbshu commented 11 months ago

我也遇到这个问题,batch size 不能改,很难受。