I’m not sure I understand the use case correctly.



 Praveen_K:

How can I load the model as above if I have 2 parts(Encoder and Classifier) ?


You can directly save and load the state_dict of the Autoencoder even if it contains the two submodules.
Wrapping the model into an nn.Sequential container might work for your use case, but would change the state_dict keys.
Saving the state_dict of the nn.Sequential container and loading it into the Autoencoder will most likely not work out of the box and you would need to adapt the keys inside the state_dict.