Output width and heigh with transposed convolution
I have an input of shape torch.Size([4, 256, 1, 5] and I want to upsample it to torch.Size([4, 256, 2, 11]) using torch.nn.ConvTranspose2d(ip_sz, op_sz, kernel_size, stride, padding, output_padding)
I tried different combinations of kernel_size, stride, padding, output_padding however, I am unable to get the desired result.
import torch
import torch.nn as nn

class Dummy(nn.Module):
    def __init__(self, ip_sz, op_sz, kernel_size=3, stride=2, padding=1, output_padding=1):
        super(Dummy, self).__init__()
        self.conv1 = nn.ConvTranspose2d(ip_sz, op_sz, kernel_size=kernel_size, 
                                        stride=stride, padding=padding, output_padding=output_padding)
    
    def forward(self, x):
        x = self.conv1(x)
        print(x.shape)
        return x

dummy_model = Dummy(256, 256)
dummy_model(torch.rand([4, 256, 1, 5]))


Convolution with following parameters should work:
new_dummy = Dummy(256, 256, kernel_size=(2, 3), stride=2, padding=0, output_padding=0)

