I'm new to PyTorch and tensor data thing. I have a problem about switching shape of tensors.
I have two questions.
First, what should I do if I have a tensor with torch.Size([8, 512, 16, 16])
and I want to change it into torch.Size([8, 256, 32, 32])
which is double size of the original tensor.
Second, what should I do if I have a tensor with torch.Size([8, 256, 32, 32])
and I want to change it into torch.Size([8, 512, 16, 16])
which is half size of the original tensor.
In the first question, I've tried on ZeroPadding2D(8)
function to reshape it into torch.Size([8, 512, 32, 32])
but I don't know how to change the 2nd dimension which is 512 into 256.
The actual usage in the first question is something like this.
x = input # torch.Size([8, 512, 16, 16])
x = layer(x) # torch.Size([8, 256, 32, 32]
x = x + input # what I want to do is adding tensor values before and after passing the layer together (like skip connection)
I expect the output of adding two tensors to be success but the actual output is an error about unequal size in dimensions