Lecture 33: Parameters befor and after training

Post Reply
huijuanmeng
Posts: 1
Joined: Thu Jan 26, 2023 1:53 pm

Lecture 33: Parameters befor and after training

Post by huijuanmeng »

In this lecture, we stored the parameters of model before and after training:
params_before = []
for name, p in model.named_parameters():
params_before.append(p.detach().cpu().numpy())

params_after = []
for name, p in model.named_parameters():
params_after.append(p.detach().cpu().numpy())

And we see there are 201 values in each list.

My question is: in the code, we import our saved model, and name it "newmodel", but in "params_after" code, we still get parameters from model, why we don't need to change model name?

Thanks,
lazyprogrammer
Site Admin
Posts: 115
Joined: Sat Jul 28, 2018 3:46 am

Re: Lecture 33: Parameters befor and after training

Post by lazyprogrammer »

Thanks for your inquiry.

The variable 'newmodel' is a pipeline object. It's not the same object type as the previous model.

To understand how the parameters stored in the 'model' variable could have changed, you should study "object-oriented programming" to give you some idea of what's happening under the hood.

You should also learn more about Python variables and types. That would be my recommendation.
Post Reply

Return to “Data Science: Transformers for Natural Language Processing”