Concatenating 2d planes with the input image

Hi,

I’d like to concatenate each input image with 2d matrices but I’m stuck with errors.

I get (<class ‘RuntimeError’>, RuntimeError(‘Sizes of tensors must match except in dimension 0. Got 1 and 8 (The offending index is 0)’))
since the input_img has size of {Tensor: (8, 3, 256, 256)} and 2d matrices have size of {Tensor: (1, 1, 256, 256)}

input image size = 3x256x256
batch size = 8

Please help me out with this problem…! Any advice will be appreciated!

Thank you.

Can you explain what this 2D matrix is?

I can understand that there are 8 images (batch size), each of them have 3 channels (RGB) and are of size 256 x256.

However you only have 1 of these 2D matrices (batch = 1) with the same H and W.

So, do you want to concatenate the same 2D matrix to every image.

Also, do you want to ADD it the values of the RGB? → BxCxHxW = 8x3x256x256

Or do you want to concatenate it as a new channel? → BxCxHxW = 8x4x256x256

Or do you want it as a depth D dimension? → BxCxDxHxW = 8x3x1x256x256

What you are doing is correct. I don´t see why this would be wrong.

1 Like

Thanks for your reply!

1 Like