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 (639) must match the size of tensor b (319) at non-singleton dimension 3 #3

Closed
zixulll opened this issue Nov 14, 2022 · 7 comments

Comments

@zixulll
Copy link

zixulll commented Nov 14, 2022

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
Copy link
Owner

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

@zixulll
Copy link
Author

zixulll commented Nov 14, 2022

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
Copy link
Owner

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

@SheffieldCao
Copy link

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
Copy link
Owner

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

@zixulll
Copy link
Author

zixulll commented Nov 15, 2022

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
Copy link
Author

zixulll commented Nov 15, 2022

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

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