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

I have a dimension problem #34

Closed
piajun opened this issue Dec 10, 2019 · 2 comments
Closed

I have a dimension problem #34

piajun opened this issue Dec 10, 2019 · 2 comments

Comments

@piajun
Copy link

piajun commented Dec 10, 2019

19-12-10 08:40:22.144 - INFO: Model [SRGANModel] is created.
19-12-10 08:40:22.144 - INFO: Start training from epoch: 0, iter: 0
/home/thrc_pyj/anaconda3/envs/torch1/lib/python3.7/site-packages/torch/nn/modules/loss.py:91: UserWarning: Using a target size (torch.Size([16, 3, 129, 129])) that is different to the input size (torch.Size([16, 3, 172, 172])). This will likely lead to incorrect results due to broadcasting. Please ensure they have the same size.
return F.l1_loss(input, target, reduction=self.reduction)
Traceback (most recent call last):
File "train.py", line 310, in
main()
File "train.py", line 158, in main
model.optimize_parameters(current_step)
File "/home/thrc_pyj/mmsr-master/codes/models/SRGAN_model.py", line 145, in optimize_parameters
l_g_pix = self.l_pix_w * self.cri_pix(self.fake_H, self.var_H)
File "/home/thrc_pyj/anaconda3/envs/torch1/lib/python3.7/site-packages/torch/nn/modules/module.py", line 493, in call
result = self.forward(*input, **kwargs)
File "/home/thrc_pyj/anaconda3/envs/torch1/lib/python3.7/site-packages/torch/nn/modules/loss.py", line 91, in forward
return F.l1_loss(input, target, reduction=self.reduction)
File "/home/thrc_pyj/anaconda3/envs/torch1/lib/python3.7/site-packages/torch/nn/functional.py", line 2230, in l1_loss
expanded_input, expanded_target = torch.broadcast_tensors(input, target)
File "/home/thrc_pyj/anaconda3/envs/torch1/lib/python3.7/site-packages/torch/functional.py", line 62, in broadcast_tensors
return torch._C._VariableFunctions.broadcast_tensors(tensors)
RuntimeError: The size of tensor a (172) must match the size of tensor b (129) at non-singleton dimension 3

I have no idea how the 172 come up. It should be 129(I set GT_size = 129).
Can anyone help me?

@piajun
Copy link
Author

piajun commented Dec 11, 2019

My scale is 3, and I used the ESRGAN model , so I guess that maybe the pretrained model does not match my data? (the pretrained model's scale is 4, but mine is 3)

@piajun
Copy link
Author

piajun commented Dec 12, 2019

I think I find the reason because when I changed the default model_G to the SRResnet model I trained by myself, it start to run.

@xinntao xinntao closed this as completed Jul 8, 2020
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