wencheng256 / BRNet

Other
12 stars 0 forks source link

RuntimeError: The size of tensor a (639) must match the size of tensor b (319) at non-singleton dimension 3 #3

Closed zixulll closed 2 years ago

zixulll commented 2 years ago

Hello, thank you for your excellent work. The code always displays tensor mismatch when running monocular training. Can you help me to provide some solutions? Thank you very much. The error message is as follows: Traceback (most recent call last): File "train.py", line 18, in trainer.train() File "/home/yzhang/BRNet/trainer.py", line 189, in train self.run_epoch() File "/home/yzhang/BRNet/trainer.py", line 205, in run_epoch outputs, losses = self.process_batch(inputs) File "/home/yzhang/BRNet/trainer.py", line 260, in process_batch losses = self.compute_losses(inputs, outputs) File "/home/yzhang/BRNet/trainer.py", line 492, in compute_losses smooth_loss = get_smooth_loss(norm_disp, color) File "/home/yzhang/BRNet/layers.py", line 214, in get_smooth_loss grad_disp_x *= torch.exp(-grad_img_x) RuntimeError: The size of tensor a (639) must match the size of tensor b (319) at non-singleton dimension 3

wencheng256 commented 2 years ago

Sorry, I leaved some debug codes leading to this error. I pushed a new version, please pull the latest code.

zixulll commented 2 years ago

My dear brother, the tensor match error problem cannot be solved after using new code. I want to ask whether it is a code problem or a dependent library version problem?

wencheng256 commented 2 years ago

Please pull the latest and try again. I have tested the current code by myself, it can work now.

SheffieldCao commented 2 years ago

I previously met the same problem. I found that the output scale w.r.t. the inputs size is [2,1,1/2,1/4,1/8], the depth result just downsample the first one to scale=1, so when computing losses, the second scale is not aligned with the color image.

I tried another way before this commit by myself that downsampling all disps with ratio=0.5 to align with color images. And I finally got close results w.r.t. the paper. May be these two approaches are both OK. 😂.

wencheng256 commented 2 years ago

@SheffieldCao Thank you for your answer. Your solution is also right.

zixulll commented 2 years ago

Please pull the latest and try again. I have tested the current code by myself, it can work now.

Thank you very much, dear brother. You can be an academician in the future.

zixulll commented 2 years ago

@SheffieldCao You are so awesome. Thank you for the solution. I really want to go to Tongji University.