External-Attention-pytorch icon indicating copy to clipboard operation
External-Attention-pytorch copied to clipboard

MobileViT-einops.EinopsError: Error while processing rearrange-reduction pattern "b d (h ph) (w pw) -> b (ph pw) (h w) d".

Open JiangMei0201 opened this issue 3 years ago • 4 comments

Thanks for your great repo. I changed some models'backbone into MobileViT, but it were wrong in traning. I checked the feature size carefully and I don‘t know how to solve it. Looking for your reply and thanks a lot.

JiangMei0201 avatar Dec 23 '21 14:12 JiangMei0201

In External-Attention-pytorch/model/backbone/MobileViT.py,line134,you can change it. nn.Conv2d(inp, hidden_dim, kernel_size=1, stride=self.stride, bias=False),

Jyy01 avatar Dec 30 '21 09:12 Jyy01

In External-Attention-pytorch/model/backbone/MobileViT.py,line134,you can change it. nn.Conv2d(inp, hidden_dim, kernel_size=1, stride=self.stride, bias=False), 谢谢您的帮助!!!我按照您的建议修改line 134,这个错误解决了。但是出现了新的错误如下: raise ValueError('Expected more than 1 value per channel when training, got input size {}'.format(size)) ValueError: Expected more than 1 value per channel when training, got input size torch.Size([1, 256, 1, 1]) 我尝试了drop_last=True和改大batchsize,仍未解决。请问您遇到过这个错误吗?

JiangMei0201 avatar Jan 02 '22 13:01 JiangMei0201

看起来像是你的输入数据的问题,你可以先定义一个随机数,然后调试一下,观察每一层的输出结果是否正确。 input = torch.randn(1, 3, 256, 256)

Jyy01 avatar Jan 20 '22 03:01 Jyy01

@JiangMei0201 您好我也遇到了同样的问题,请问您解决了嘛

WangQvQ avatar Jan 12 '23 13:01 WangQvQ