[英]RuntimeError: The size of tensor a (128) must match the size of tensor b (256) at non-singleton dimension 3
Please I need your help on how I can train my model on image dimension of 256x256 I changed the image size but I got this error that I couldn't solve it :请我帮助我如何在 256x256 的图像尺寸上训练我的模型 我更改了图像大小,但出现了无法解决的错误:
File "train_128.py", line 149, in main文件“train_128.py”,第 149 行,在 main
g_img_rec_loss = torch.abs(img_rec - imgs).mean() g_img_rec_loss = torch.abs(img_rec - imgs).mean()
RuntimeError: The size of tensor a (128) must match the size of tensor b (256) at non-singleton dimension 3 RuntimeError:张量 a (128) 的大小必须与非单维 3 的张量 b (256) 的大小相匹配
The code source is : https://github.com/biswassanket/synth_doc_generation代码来源是: https ://github.com/biswassanket/synth_doc_generation
thanks in advance提前致谢
The error is happening because your variable img_rec
is size (batch_size, 3, 128, 128) and the other variable imgs
is size (batch_size, 3, 256, 256).发生错误是因为您的变量
img_rec
是 size (batch_size, 3, 128, 128) 而另一个变量imgs
是 size (batch_size, 3, 256, 256)。
If you are passing 256 * 256 images from your dataLoader you also need to make sure you are generating 256 * 256 images which you are not doing.如果您从 dataLoader 传递 256 * 256 图像,您还需要确保生成 256 * 256 图像,而您没有这样做。
Over here in this line of code .在这行代码中。 When you make the output you are getting a 128 * 128 image so you may need to change the params in netG or do a resize on the output.
当您进行输出时,您将获得 128 * 128 的图像,因此您可能需要更改 netG 中的参数或调整输出大小。
Hope this helps希望这可以帮助
SanrthakJain: I checked the netG which is stand for the generator model https://github.com/biswassanket/synth_doc_generation/blob/main/layout2im/models/generator_128.py SanrthakJain:我检查了代表生成器模型的 netG https://github.com/biswassanket/synth_doc_generation/blob/main/layout2im/models/generator_128.py
could you please guide me which modification I should do to fix this error?你能指导我应该做哪些修改来修复这个错误吗?
thanks in advance.提前致谢。
Thank you for your question I face the same problem please SarthakJain could you share with us how to resize in the output to solve this problem?谢谢你的问题我遇到了同样的问题,请 SarthakJain 你能与我们分享如何调整输出大小来解决这个问题吗?
Help appreciated for a beginner like me对像我这样的初学者的帮助表示赞赏
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.