one
one

Reputation: 2585

What does the `model.parameters()` include?

In Pytorch,

What will be registered into the model.parameters().

As far as now, what I know are as belows:

1.  Conv layer: weight  bias
2.  BN layers: weight(gamma)  bias(beta)
3.  nn.Parameter() 
    such as:   self.alpha = nn.Parameter(torch.rand(10))  defined in the model.

My question is: And are there some parameters else that are registered in the model.parameters() ?

PS. The most common case for the model.parameters() is in the optimizer, e.g. pytorch resnet example

optimizer = torch.optim.SGD(model.parameters(), args.lr,
                                momentum=args.momentum,
                                weight_decay=args.weight_decay)

Thank you in advance.

Upvotes: 0

Views: 2349

Answers (1)

Nerveless_child
Nerveless_child

Reputation: 1412

Like you wrote there, model.parameters() stores the weight and bias (if set to true) values of the model. It is given as an argument to an optimizer to update the weight and bias values of the model with one line of code optimizer.step(), which you then use when next you go over your dataset.

Upvotes: 1

Related Questions