Refer to :
https://discuss.pytorch.org/t/inferred-padding-size-for-nn-convtranspose2d/12141
Inferred padding size for nn.ConvTranspose2d
The formula for output height and width is given in the docs: http://pytorch.org/docs/0.3.0/nn.html#torch.nn.ConvTranspose2d
So you can infer the amount of padding needed to make sure you get to your output size:
http://pytorch.org/docs/0.3.0/nn.html#torch.nn.ConvTranspose2d