简体   繁体   English

`model.parameters()`包含什么?

[英]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.

相关问题 Django model.parameters - Django model.parameters model.parameters和model.parameters()的区别,pytorch - Difference between model.parameters and model.parameters(), pytorch model.parameters() 未在 Pytorch 的线性回归中更新 - model.parameters() not updating in Linear Regression with Pytorch 使用 torch.optim 一起优化 model.parameters 和自定义可学习参数会给出非叶张量错误 - Optimising model.parameters and custom learnable parameter together using torch.optim gives non-leaf tensor error RandomizedSearchCV 是否自动包含传递给构造函数的默认 model 参数? - does RandomizedSearchCV automatically include the default model parameters that are passed to the constructor? Tensorflow 2x:参数 include_optimizer 究竟对 tensorflow.keras.save_model 有什么影响 - Tensorflow 2x: What exactly does the parameter include_optimizer affect in tensorflow.keras.save_model 所有这些参数在 yoloV4 model 中的含义 - What all these parameters means in yoloV4 model 在这个 Tensorflow 模型中,哪些模型参数从一个 epoch 到下一个 epoch 发生了变化? - In this Tensorflow model, what model parameters are changing from one epoch to the next? 在getattr()中有两个参数是什么意思? - What does it mean to have two parameters in a getattr()? python 中函数参数中的“或”是什么意思? - What does “or” in function-parameters in python mean?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM