The output size of a transposed convolution is given by:
o = (i -1)*s - 2*p + k + output_padding 

Note that  ConvTranspose layers come with an output_padding parameter, which defaults to 0.
The formulas are also shown in the documentation 603 of PyTorch’s convolution layers.
(I used a slightly different notation for the Conv layer output. My formula can be simplified to the one shown in the docu though.)