当前位置:网站首页>torch optimizer小解析
torch optimizer小解析
2022-07-06 22:49:00 【构建的乐趣】
我是按torch 1.11版本写的:
以sgd为例:
里面的maximize = group[‘maximize’]说明了maxmize参数可以分group指定。当然也可以全局使用,并且maxmize是sgd独有的(截至1.11版本)
注意,其他版本的优化器如adam,我没看到maxmize参数。想要执行梯度上升,我想的办法是重写优化器。
注意,self.param_groups是一个列表,是在基类中定义的,sgd里找不到。由上面的图片可知,sgd是按self.param_groups对各个params进行梯度优化(上升或下降)
注意sgd init方法中的defaults变量,这是要给基类init方法的。有关super,可以看看b站一个视频,讲的非常细:
回到基类,注意下图的defaults注释:
后面用了字典的setdefault方法来将全局默认defaults给每个group:
边栏推荐
- STM32F103 realize IAP online upgrade application
- 最全常用高数公式
- JS input and output
- 2.证券投资基金的概述
- If you ask me about R code debugging, I will tell you head, STR, help
- 5G VoNR+之IMS Data Channel概念
- AttributeError: module ‘torch._ C‘ has no attribute ‘_ cuda_ setDevice‘
- 【二叉树】二叉树寻路
- 指针与数组在函数中输入实现逆序输出
- A simple and beautiful regression table is produced in one line of code~
猜你喜欢
MySQL数据库(基础篇)
Lessons and thoughts of the first SQL injection
How does vscade use the built-in browser?
Ansible概述和模块解释(你刚走过了今天,而扑面而来的却是昨天)
DFS and BFS concepts and practices +acwing 842 arranged numbers (DFS) +acwing 844 Maze walking (BFS)
Windows are not cheap things
Liste des hôtes d'inventaire dans ansible (je vous souhaite des fleurs et de la romance sans fin)
九章云极DataCanvas公司摘获「第五届数字金融创新大赛」最高荣誉!
[Android kotlin collaboration] use coroutinecontext to realize the retry logic after a network request fails
Ansible reports an error: "MSG": "invalid/incorrect password: permission denied, please try again“
随机推荐
Weebly mobile website editor mobile browsing New Era
【愚公系列】2022年7月 Go教学课程 005-变量
史上最全学习率调整策略lr_scheduler
九章云极DataCanvas公司摘获「第五届数字金融创新大赛」最高荣誉!
Analyse approfondie de kubebuilder
Chapter 9 Yunji datacanvas company has been ranked top 3 in China's machine learning platform market
Leetcode longest public prefix
How does vscade use the built-in browser?
When knative meets webassembly
R language principal component PCA, factor analysis, clustering analysis of regional economy analysis of Chongqing Economic Indicators
Ansible overview and module explanation (you just passed today, but yesterday came to your face)
acwing 843. N-queen problem
Local tool [Navicat] connects to remote [MySQL] operation
Oracle - views and sequences
Tree map: tree view - draw covid-19 array diagram
JS input and output
A line of R code draws the population pyramid
What is JVM? What are the purposes of JVM tuning?
In depth analysis of kubebuilder
A detailed explanation of head pose estimation [collect good articles]