I have a neural network with input shape = 1000, hidden = 500, and output = 2 neurons for classification. I am trying to do transfer learning, and my pretrained model is shaped shape = 1000, hidden = 500, and output = 200 neurons. However, when I try to initialize the classification model parameters with the learnt parameters, there is no error about different output layer neuron numbers.

Screen Shot 2021-05-27 at 1.11.50 PM1642×1256 187 KB


Screen Shot 2021-05-27 at 1.11.58 PM1630×270 58.4 KB

No error above when trying to initialize by directly setting the data. However, when I initialize with load_state_dict(), the correct behavior occurs. Below:

Screen Shot 2021-05-27 at 1.12.09 PM2998×1066 381 KB