Solved by ptrblck in post #2 
              
              
                If you want to use a constant size, you could create the nn.Upsample module in the __init__ method of your model and directly use it for all images: 
up = nn.Upsample(size=(24, 24))

x = torch.randn(1, 3, 10, 10)
print(up(x).shape)
> torch.Size([1, 3, 24, 24])

x = torch.randn(1, 3, 40, 40)
print(up…