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: input and target shapes do not match: input [16 x 512 x 8 x 8], target [16 x 512 x 2 x 2] #6

Closed
AMardiah opened this issue Oct 6, 2019 · 1 comment

Comments

@AMardiah
Copy link

AMardiah commented Oct 6, 2019

hey i'm trying to load image 128x128 and i have resized it into 64x64 in data_loader but i still get this error

Traceback (most recent call last):
File "train_gan.py", line 245, in
args.restore_file,cuda_id=cuda_id)
File "train_gan.py", line 127, in train_and_evaluate
train(netG, netD, optimG, optimD, loss_fn, train_dataloader, metrics, params, cuda_id)
File "train_gan.py", line 66, in train
g_loss = loss_fn(fake_out, fake_img, real_img)
File "C:\Users\PC\Anaconda3\envs\cgan\lib\site-packages\torch\nn\modules\module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "F:\ProgramTA\CGAN_AinilMardiah\program\loss.py", line 78, in forward
perception_loss = self.mse_loss(self.loss_network(out_images), self.loss_network(target_images))
File "C:\Users\PC\Anaconda3\envs\cgan\lib\site-packages\torch\nn\modules\module.py", line 477, in call
result = self.forward(*input, **kwargs)
File "C:\Users\PC\Anaconda3\envs\cgan\lib\site-packages\torch\nn\modules\loss.py", line 421, in forward
return F.mse_loss(input, target, reduction=self.reduction)
File "C:\Users\PC\Anaconda3\envs\cgan\lib\site-packages\torch\nn\functional.py", line 1716, in mse_loss
return _pointwise_loss(lambda a, b: (a - b) ** 2, torch._C._nn.mse_loss, input, target, reduction)
File "C:\Users\PC\Anaconda3\envs\cgan\lib\site-packages\torch\nn\functional.py", line 1674, in _pointwise_loss
return lambd_optimized(input, target, reduction)
RuntimeError: input and target shapes do not match: input [16 x 512 x 8 x 8], target [16 x 512 x 2 x 2] at c:\programdata\miniconda3\conda-bld\pytorch_1532505617613\work\aten\src\thcunn\generic/MSECriterion.cu:12

could help me how to solve the error?

@Yuyiba
Copy link

Yuyiba commented Dec 1, 2020

me too orz^

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