volo icon indicating copy to clipboard operation
volo copied to clipboard

RuntimeError: The size of tensor a (28) must match the size of tensor b (14) at non-singleton dimension 2

Open zhang-pan opened this issue 3 years ago • 2 comments

When use the pre-trained model VOLO-D4-448, the error as flow: Traceback (most recent call last): File "F:/volo-main/main1_all_complete.py", line 416, in main() File "F:/volo-main/main1_all_complete.py", line 168, in main train_loss,train_accuracy=train(train_loader,model, loss_f,optimizer,epoch,args) File "F:/volo-main/main1_all_complete.py", line 239, in train logits,aux,auxx =model(image) File "D:\Python36\lib\site-packages\torch\nn\modules\module.py", line 889, in _call_impl result = self.forward(*input, **kwargs) File "F:\volo-main\models\volo.py", line 614, in forward x = self.forward_tokens(x) File "F:\volo-main\models\volo.py", line 579, in forward_tokens x = x + self.pos_embed RuntimeError: The size of tensor a (28) must match the size of tensor b (14) at non-singleton dimension 2

zhang-pan avatar Aug 22 '21 09:08 zhang-pan

Hi, did you fix it? I meet same problem.

xudongLi-Alex avatar Apr 20 '22 10:04 xudongLi-Alex

class VOLO(nn.Module): def init(self, layers, img_size=640, in_chans=3, patch_size=8, stem_hidden_dim=64, embed_dims=None, num_heads=None, downsamples=None, outlook_attention=None, mlp_ratios=None, qkv_bias=False, qk_scale=None, drop_rate=0., attn_drop_rate=0., drop_path_rate=0., norm_layer=nn.LayerNorm, post_layers=None, return_mean=False, return_dense=True, mix_token=True, pooling_scale=2, out_kernel=3, out_stride=2, out_padding=1):

image_size大小需要修改成你自己定义的!

wstchhwp avatar Jun 16 '22 06:06 wstchhwp