I understood about adapting keys. I tried few things myself.
Here is how I’m saving and loading the model.

torch.save(
        {
            'model_state_dict': net.state_dict(),
            'optimizer_state_dict': optimizer.state_dict(),
        }, './model.pth')



Loading the model…
class Initialise(nn.Module):
    def __init__(self):
        super(Initialise, self).__init__()
        self.encoder = nn.Sequential(nn.Linear(28*28*3, 256), nn.ReLU())
        self.classifier = nn.Sequential(nn.Linear(256, 100),nn.LogSoftmax(dim=1))
  
    def forward(self, x):
        x = self.encoder(x)
        x = self.classifier(x)

    
        return x

model= Initialise()
checkpoint = torch.load('./model.pth', map_location='cuda')
model.load_state_dict(checkpoint['model_state_dict'], strict=False)

But at the moment I’m facing the below error.
_IncompatibleKeys(missing_keys=['encoder.0.weight', 'encoder.0.bias'], unexpected_keys=['0.0.weight', '0.0.bias'])
If I understand properly, I should just have to change layer name before saving from 0 to encoder , right?