Cannot set output_size in ConvTranspose2d

I’ve been trying to use ConvTranspose2d with the following code.

upsample = nn.ConvTranspose2d(1024, 512, kernel_size=2)                                                                                                                              
e4=torch.randn(2, 512, 56, 56)                                                                                                                                                       
b=torch.randn(2, 1024, 28, 28)                                                                                                                                                       
b_1=upsample(b, output_size=e4.size())

It is giving the error
ValueError: requested an output size of torch.Size([56, 56]), but valid sizes range from [29, 29] to [29, 29] (for an input of torch.Size([28, 28]))

I am confused with this and not able to solve. Can anyone help me on this. Thanks in advance!!!

upsample = nn.ConvTranspose2d(1024, 512, 3, stride=2, padding=1) 

Why not use this?

Thank you. This works. I get the intuition behind adding padding but why is stride needed for this?

This site provides a nice visualization about stride and padding.