pytorch-semseg icon indicating copy to clipboard operation
pytorch-semseg copied to clipboard

unet error with (1,3,256,256) input

Open 3bobo opened this issue 6 years ago • 7 comments

I'm try to input a tensor with the size of (1, 3, 256, 256), after many conv2d and maxpool, the centre feature size is (1, 256, 8, 8), and the covn4 is (1, 128, 24, 24), after up_layer, the feature size is (1, 128, 12, 12), and after up is (1,64,24,24), but the conv3 is (1, 64, 57, 57), and if this size goes with cropping, it will be (1,64,23,23), which is different from (1,64,24,24), and makes an error.

3bobo avatar Oct 22 '18 11:10 3bobo

Do you solve this problem? Can you share yourself config file with Unet

Qirui-Y avatar May 05 '19 07:05 Qirui-Y

Same Problem

hurricane2018 avatar Jun 10 '19 01:06 hurricane2018

Do you solve this problem? I have the same problem.

RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 1. Got 24 and 23 in dimension 2 at /pytorch/aten/src/THC/generic/THCTensorMath.cu:71

flyking1994 avatar Oct 15 '19 12:10 flyking1994

Do you solve this problem? I have the same problem.

RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 1. Got 24 and 23 in dimension 2 at /pytorch/aten/src/THC/generic/THCTensorMath.cu:71

Are you applying unet to a square input or rectangular? I had to alter the model to work for validating on rectangular input

brucemuller avatar Oct 15 '19 13:10 brucemuller

Do you solve this problem? I have the same problem. RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 1. Got 24 and 23 in dimension 2 at /pytorch/aten/src/THC/generic/THCTensorMath.cu:71

Are you applying unet to a square input or rectangular? I had to alter the model to work for validating on rectangular input

My image size is (256,256,3), its a square input

flyking1994 avatar Oct 15 '19 13:10 flyking1994

def forward(self, inputs1, inputs2):
    outputs2 = self.up(inputs2)
    offset1 = outputs2.size()[2] - inputs1.size()[2]
    offset2 = inputs1.size()[2] - outputs2.size()[2]
    padding = 2 * [offset1//2, -(offset2//2)]  
    outputs1 = F.pad(inputs1, padding)
    return self.conv(torch.cat([outputs1, outputs2], 1))

I changed the calculation method of padding. It seems that this problem has been solved.

flyking1994 avatar Oct 16 '19 08:10 flyking1994

Thanks @flyking1994, +1 here for Cityscapes datasets gtFine_trainvaltest.zip and leftImg8bit_trainvaltest.zip, cropped and resized to (224, 224). Will try a run later with the original size of (2048, 1024)

svanbodegraven avatar Oct 17 '19 07:10 svanbodegraven