lee-zq / 3DUNet-Pytorch

3DUNet implemented with pytorch
494 stars 110 forks source link

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

Open NBIronman opened 3 years ago

NBIronman commented 3 years ago

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?

lcl180 commented 3 years ago

I have the same problem. Have you solved it?

piggy789 commented 3 years ago

I have the same problem. Have you solved it?

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

qingqiqiu commented 3 years ago

请问这个系数怎么改呀?

santu574 commented 3 years ago

i have the same problem'

santu574 commented 3 years ago

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

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

y8421036 commented 3 years ago

I have the same problem. Have you solved it?

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

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

wqcolin commented 3 years ago

I have the same problem. Have you solved it?

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

求大佬详细说说

sotam-a commented 3 years ago

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

NBIronman commented 3 years ago

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

wqcolin commented 3 years ago

问题解决了,因为预处理时将原来的(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的时候需要把参数再改回来

QianLingjun commented 2 years ago

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

QianLingjun commented 2 years ago

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

SiruLiu645 commented 1 year ago

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

RAdayone commented 1 year ago

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