Depending on the setup of the convolutions, you won’t be able to get exactly the same output shape from transposed convolution using the same setup.
Have a look at the Convolution Arithmetic 11 for more information.
I’m not sure, what input shape you are using, but e.g. for an input of [batch_size, 1, 224], you would have to use an output_padding of 1 and 3 for the nn.ConvTranspose1d in your decoder to get the same output shape.