![](/img/trans.png)
[英]How to resolve `RuntimeError: The size of tensor a (3) must match the size of tensor b (128) at non-singleton dimension 1` for SNN?
[英]RuntimeError: The size of tensor a (128) must match the size of tensor b (256) at non-singleton dimension 3
请我帮助我如何在 256x256 的图像尺寸上训练我的模型 我更改了图像大小,但出现了无法解决的错误:
文件“train_128.py”,第 149 行,在 main
g_img_rec_loss = torch.abs(img_rec - imgs).mean()
RuntimeError:张量 a (128) 的大小必须与非单维 3 的张量 b (256) 的大小相匹配
代码来源是: https ://github.com/biswassanket/synth_doc_generation
提前致谢
发生错误是因为您的变量img_rec
是 size (batch_size, 3, 128, 128) 而另一个变量imgs
是 size (batch_size, 3, 256, 256)。
如果您从 dataLoader 传递 256 * 256 图像,您还需要确保生成 256 * 256 图像,而您没有这样做。
在这行代码中。 当您进行输出时,您将获得 128 * 128 的图像,因此您可能需要更改 netG 中的参数或调整输出大小。
希望这可以帮助
SanrthakJain:我检查了代表生成器模型的 netG https://github.com/biswassanket/synth_doc_generation/blob/main/layout2im/models/generator_128.py
你能指导我应该做哪些修改来修复这个错误吗?
提前致谢。
谢谢你的问题我遇到了同样的问题,请 SarthakJain 你能与我们分享如何调整输出大小来解决这个问题吗?
对像我这样的初学者的帮助表示赞赏
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.