How to change weight after traning nueralNetwork

You can get the parameters by state_dict = model.state_dit(), and state_dict will hold all the trainable parameters.

You can do whatever changes you want to the content of the dict.

At last you just use model.load_state_dict(state_dict) to load all the updated state_dict back to the model.

4 Likes