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

Training tensor not match error #37

Open
a462428 opened this issue Jan 11, 2022 · 8 comments
Open

Training tensor not match error #37

a462428 opened this issue Jan 11, 2022 · 8 comments

Comments

@a462428
Copy link

a462428 commented Jan 11, 2022

Hi I face some errors,

Oneline-DLTv1/resnet.py", line 288, in forward
feature_loss = torch.sum(torch.mul(feature_loss_mat, mask_ap)) / sum_value
RuntimeError: The size of tensor a (315) must match the size of tensor b (560) at non-singleton dimension 3

when training:
python train.py --gpus 2 --cpus 8 --lr 0.0001 --batch_size 32

Could you please share me how to solve it thx!

@Berumotto1
Copy link

python test.py also has same error. anyone can help me?

@Berumotto1
Copy link

Berumotto1 commented Mar 4, 2022

python test.py also has same error. anyone can help me?

I change the torch version and it works!
Pytorch 1.0.1 (1.2.0)
torchvision 0.2.2

@Hasko1415
Copy link

I have the same issue,

feature_loss = torch.sum(torch.mul(feature_loss_mat, mask_ap)) / sum_value
RuntimeError: The size of tensor a (315) must match the size of tensor b (560) at non-singleton dimension 3

After downgrading PyTorch to the 1.0.1 version, then I got "[CUDA error: no kernel image is available for execution on the device]" error.
Does anyone know how to solve the issue? Many thanks!

@zyy839
Copy link

zyy839 commented Feb 25, 2023

I'm also having the same issue, did anyone fix it? Please enlighten

@qxzha
Copy link

qxzha commented May 29, 2023

if anyone knows how to fix it, please inform me.

@Fubuki901
Copy link

It is because nn.TripletMarginLoss(). If the input tensor is (B, C, H, W),
In PyTorch 1.0.1 version as this work used, this loss function will take the second dim as C, and it works.
But in some latest versions, this loss function will take the last dim as C, so you need to tanspose the input tensor to (B, H, W, C)

@zyy839
Copy link

zyy839 commented Jan 29, 2024 via email

@GSShaoxinxin
Copy link

Thanks all of you

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

7 participants