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: The size of tensor a (512) must match the size of tensor b (256) at non-singleton dimension 3 #17

Open
NBIronman opened this issue May 23, 2021 · 14 comments

Comments

@NBIronman
Copy link

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
Copy link

lcl180 commented Jun 2, 2021

I have the same problem. Have you solved it?

@piggy789
Copy link

I have the same problem. Have you solved it?

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

@qingqiqiu
Copy link

请问这个系数怎么改呀?

@santu574
Copy link

i have the same problem'

@santu574
Copy link

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

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

@y8421036
Copy link

I have the same problem. Have you solved it?

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

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

@wqcolin
Copy link

wqcolin commented Jun 16, 2021

I have the same problem. Have you solved it?

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

求大佬详细说说

@sotam-a
Copy link

sotam-a commented Jun 17, 2021

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

@NBIronman
Copy link
Author

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

@wqcolin
Copy link

wqcolin commented Jun 21, 2021

问题解决了,因为预处理时将原来的(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
Copy link

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

@QianLingjun
Copy link

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

@SiruLiu645
Copy link

你好,我修改了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
Copy link

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

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