SwinTransformer / AiT

101 stars 8 forks source link

RuntimeError: The size of tensor a (256) must match the size of tensor b (225) at non-singleton dimension 1 #2

Open xiaoqiang-lu opened 1 year ago

xiaoqiang-lu commented 1 year ago

Dear author: Thanks for your meaning work. During inference, I met 'RuntimeError: The size of tensor a (256) must match the size of tensor b (225) at non-singleton dimension 1'.

hust-nj commented 1 year ago

Hi, could you provide your test comand?

xiaoqiang-lu commented 1 year ago

It occurred in online eval. config file: swinv2b_480reso_parallel_depthonly.py

Traceback (most recent call last): File "code/train.py", line 270, in main() File "code/train.py", line 266, in main runner.run(dataloaders) File "/root/data3/DFC23/code/Track2/AiT/ait/code/runner/iter_based_runner_multitask.py", line 139, in run self.train(iter_loaders) File "/root/data3/DFC23/code/Track2/AiT/ait/code/runner/iter_based_runner_multitask.py", line 77, in train self.call_hook('after_train_iter') File "/root/miniconda3/envs/ait/lib/python3.7/site-packages/mmcv/runner/base_runner.py", line 309, in call_hook getattr(hook, fn_name)(self) File "/root/data3/DFC23/code/Track2/AiT/ait/code/model/eval.py", line 178, in after_train_iter self._do_evaluate(runner) File "/root/data3/DFC23/code/Track2/AiT/ait/code/model/eval.py", line 259, in _do_evaluate logger=runner.logger) File "/root/data3/DFC23/code/Track2/AiT/ait/code/model/eval.py", line 56, in multi_gpu_test rescale=True, task=task, data) File "/root/miniconda3/envs/ait/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, *kwargs) File "/root/miniconda3/envs/ait/lib/python3.7/site-packages/torch/nn/parallel/distributed.py", line 886, in forward output = self.module(inputs[0], kwargs[0]) File "/root/miniconda3/envs/ait/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(*input, kwargs) File "/root/miniconda3/envs/ait/lib/python3.7/site-packages/mmcv/runner/fp16_utils.py", line 109, in new_func return old_func(*args, kwargs) File "/root/data3/DFC23/code/Track2/AiT/ait/code/model/ait.py", line 257, in forward return self.forward_test(img, kwargs) File "/root/data3/DFC23/code/Track2/AiT/ait/code/model/ait.py", line 225, in forward_test pred_d = self.depth_head.simple_test(feat, *kwargs).unsqueeze(1) File "/root/data3/DFC23/code/Track2/AiT/ait/code/model/depth/depth_head.py", line 69, in simple_test x, None, masks, self.task_id, pred_len=self.vae_cfg.token_length) File "/root/miniconda3/envs/ait/lib/python3.7/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl return forward_call(input, kwargs) File "/root/miniconda3/envs/ait/lib/python3.7/site-packages/mmcv/runner/fp16_utils.py", line 197, in new_func return old_func(*args, **kwargs) File "/root/data3/DFC23/code/Track2/AiT/ait/code/model/transformer.py", line 307, in forward if self.qk_pos else self.encoder(src + enc_embed, None, enc_mask) RuntimeError: The size of tensor a (256) must match the size of tensor b (225) at non-singleton dimension 1

cvrookieytd commented 1 year ago

Hello. Have you succeeded in reproducing?

xiaoqiang-lu commented 1 year ago

No, it still exists.

cvrookieytd commented 1 year ago

I have evaluated the model trained by the author. The evaluated model is AiT-P(SwinV2-L), and the task is depth estimation.

But there is a big gap between the results and what the author said. I don't know if there is a problem with my operation

glofru commented 1 year ago

Hi @cvrookieytd can you tell me which version of CUDA/Python and packages were you able to evaluate the model? I am struggling in run an evaluation without getting an error. Thanks!