supose we have a model “saved” that has been trained and saved, and we also have another model “changed” that defined completely the same with “saved” but added some extra modules, so, how can we load the “saved” model’s weights into the “changed” model.

For example:

class A(nn.Module):

def **init**():

self.stack = nn.sequantial(…Linear and ReLU )

def forward(x):

return self.stack(x)

And

class B(nn.Module):

self.stack = nn.sequantial(…Linear and ReLU )

self.Linear = nn.Linear

def forward(x):

x = self.stack(x)

return self.Linear(x)

So, how can we load a pretrained model defined by class A into class B?