What is the correct way of copying weights of one model into another?

Hi!

I am trying to copy weights of a pretrained model into another model of exactly similar structure. The original model gives an accuracy of 94% on a binary image classification problem but the target model is unable to predict, results in predicting only one class for entire test set.

I used this piece of code to manually copy weights from pretrained model to target:

modelmix.stem[0].weight = modelSep.stem[0].weight
modelmix.stem[1].weight = modelSep.stem[1].weight
modelmix.stem[1].bias = modelSep.stem[1].bias

where modelmix is the target and modelSep is the pretrained model. Used the same snippet for all the layers. The target model is not working. Using pytorch 1.1. Thank you