3DUNet-Pytorch icon indicating copy to clipboard operation
3DUNet-Pytorch copied to clipboard

RuntimeError: The size of tensor a (512) must match the size of tensor b (256) at non-singleton dimension 3

Open NBIronman opened this issue 3 years ago • 14 comments

Hello, I ran your code and appeared“RuntimeError: The size of tensor a (512) must match the size of tensor b (256) at non-singleton dimension 3”,Can you help me solve it?

NBIronman avatar May 23 '21 05:05 NBIronman

I have the same problem. Have you solved it?

lcl180 avatar Jun 02 '21 01:06 lcl180

I have the same problem. Have you solved it?

把网络最后那几个map上采样的系数改了就行了

piggy789 avatar Jun 10 '21 00:06 piggy789

请问这个系数怎么改呀?

qingqiqiu avatar Jun 10 '21 07:06 qingqiqiu

i have the same problem'

santu574 avatar Jun 12 '21 09:06 santu574

我也有同样的问题。你解决了吗?

把网络最后那几个地图上的样本的改变了就行了 请问该怎么改呢

santu574 avatar Jun 12 '21 09:06 santu574

I have the same problem. Have you solved it?

把网络最后那几个map上采样的系数改了就行了

你好,请问具体怎么改啊,我是小白,还请详细指点一下,谢谢了

y8421036 avatar Jun 14 '21 16:06 y8421036

I have the same problem. Have you solved it?

把网络最后那几个map上采样的系数改了就行了

求大佬详细说说

wqcolin avatar Jun 16 '21 14:06 wqcolin

I also have this problem but don't have the expertise to identify the root of the error. Help is appreciated!

sotam-a avatar Jun 17 '21 17:06 sotam-a

把网络看明白,最后作者分别把解码部分每层输出都引出来了,每个输出的上采样调整成一样的大小就行了

NBIronman avatar Jun 18 '21 01:06 NBIronman

问题解决了,因为预处理时将原来的(x,512,512)大小的图像变成了新的大小(y,256,256),但是在网络中训练后预测的图片大小是(y,512,512),因此不能计算loss。 只需要在ResUnet.py文件中将第135line到161line之间的nn.Upsample(scale_factor=(1, x, x)变成nn.Upsample(scale_factor=(1, 0.5x, 0.5x)。 就是将nn.Upsample(scale_factor=(y, x, x)中后面两个参数减半 PS:Test的时候需要把参数再改回来

wqcolin avatar Jun 21 '21 14:06 wqcolin

这样修改是可以正常训练和测试的。但是训练和测试阶段上采样的方式不一样,相当于改变了模型的结构,这样对测试结果,应该会有影响吧。

QianLingjun avatar Jan 13 '22 02:01 QianLingjun

是最后一层的输出,应该不会有影响的,相当于resize吧

QianLingjun avatar Jan 13 '22 03:01 QianLingjun

你好,我修改了resnet部分上采样参数,网络开始训练之后又报错:Sizes of tensors must match except in dimension 1. Expected size 20 but got size 21 for tensor number 1 in the list.请问这个应该如何解决

SiruLiu645 avatar Apr 04 '23 03:04 SiruLiu645

您好,改上采样的数据倒是能跑train,但是跑出来的结果不会很差吗,我改完后再进行test的时候需要再将上采样改回来,test后的结果基本上是漆黑一片,请问您当时也是这样吗

RAdayone avatar Apr 25 '23 14:04 RAdayone