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

Dimension mismatch for x2 and x5 in LUM_model.py #4

Closed
deepakkupanda opened this issue Mar 25, 2022 · 1 comment
Closed

Dimension mismatch for x2 and x5 in LUM_model.py #4

deepakkupanda opened this issue Mar 25, 2022 · 1 comment

Comments

@deepakkupanda
Copy link

Traceback (most recent call last):
File "LUM_train.py", line 156, in
main()
File "LUM_train.py", line 134, in main
r_x, i_x = light(val_x)
File "/anaconda/envs/azureml_py38/lib/python3.8/site-packages/torch/nn/modules/module.py", line 1102, in _call_impl
return forward_call(*input, **kwargs)
File "/mnt/batch/tasks/shared/LS_root/mounts/clusters/deepakpanda4/code/Users/deepakpanda/HEP/models/LUM_model.py", line 48, in forward
cat5 = torch.cat((x5, x2), dim=1)
RuntimeError: Sizes of tensors must match except in dimension 1. Expected size 766 but got size 765 for tensor number 1 in the list.

@fengzhang427
Copy link
Owner

This is due to the size of your valid images, which you can solve by replacing the torch.cat with the following code:
def cat_(x01, x02):
diffY = x02.size()[2] - x01.size()[2]
diffX = x02.size()[3] - x01.size()[3]
x01 = F.pad(x01, (diffX // 2, diffX - diffX // 2, diffY // 2, diffY - diffY // 2))
x = torch.cat([x02, x01], dim=1)
return x

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

2 participants