Since you are working on an Auto-encoder I assume you could calculate the loss using the input and output directly. Depending on the model architecture you could pass variable input shapes to the model. E.g. if you are just using conv and pooling operations, this might be possible. I assume that input with a largely different input shape could create worse results as your model wasn’t trained on these, but that’s just a guess.