Zhuysheng / RVTCLR

MIT License
4 stars 0 forks source link

margin_ranking_loss #2

Open 223d opened 6 months ago

223d commented 6 months ago

Hi ,Can you help me take a look at a question here? thankyou!

Traceback (most recent call last): File "/home/zlq/pycharm-professional-2023.1.3/pycharm-2023.1.3/plugins/python/helpers/pydev/pydevd.py", line 1496, in _exec pydev_imports.execfile(file, globals, locals) # execute the script File "/home/zlq/pycharm-professional-2023.1.3/pycharm-2023.1.3/plugins/python/helpers/pydev/_pydev_imps/_pydev_execfile.py", line 18, in execfile exec(compile(contents+"\n", file, 'exec'), glob, loc) File "/home/zlq/project/RVTCLR-main/main.py", line 57, in p.start() File "/home/zlq/project/RVTCLR-main/processor/processor.py", line 179, in start self.train(epoch + 1) File "/home/zlq/project/RVTCLR-main/processor/pretrain_skeletonclr.py", line 108, in train loss3 = self.loss_2(logits_M[0], logits_M[1], labels_M) File "/home/zlq/miniconda3/envs/RVTCLR/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1194, in _call_impl return forward_call(*input, **kwargs) File "/home/zlq/miniconda3/envs/RVTCLR/lib/python3.7/site-packages/torch/nn/modules/loss.py", line 1333, in forward return F.margin_ranking_loss(input1, input2, target, margin=self.margin, reduction=self.reduction) File "/home/zlq/miniconda3/envs/RVTCLR/lib/python3.7/site-packages/torch/nn/functional.py", line 3328, in margin_ranking_loss "input1: {}, input2: {}, target: {} ".format(input1.size(), input2.size(), target.size()) RuntimeError: margin_ranking_loss : All input tensors should have same dimension but got sizes: input1: torch.Size([2, 1]), input2: torch.Size([2, 1]), target: torch.Size([2]) python-BaseException

Zhuysheng commented 5 months ago

It seems like the tensor dimension mismatch, maybe target=target.unsqueeze(dim=-1) could solve your problem.