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

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

Open
zhang-pan opened this issue Aug 22, 2021 · 2 comments

Comments

@zhang-pan
Copy link

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

@xudongLi-Alex
Copy link

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

@wstchhwp
Copy link

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大小需要修改成你自己定义的!

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

3 participants