[英]What does the `model.parameters()` include?
In Pytorch, 在Pytorch,
What will be registered into the model.parameters()
. 什么将被注册到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()
? 我的问题是:在model.parameters()
中是否注册了其他一些参数?
PS . PS 。 The most common case for the model.parameters()
is in the optimizer, eg pytorch resnet example model.parameters()
最常见的情况是在优化器中,例如pytorch resnet示例
optimizer = torch.optim.SGD(model.parameters(), args.lr,
momentum=args.momentum,
weight_decay=args.weight_decay)
Thank you in advance. 先感谢您。
Like you wrote there, model.parameters()
stores the weight and bias (if set to true) values of the model. 就像您在此处编写的一样, model.parameters()
存储模型的权重和偏差(如果设置为true)。 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. 它是优化器的一个参数,可使用一行代码optimizer.step()
来更新模型的权重和偏差值,然后在下一次遍历数据集时使用该代码。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.