当前位置:网站首页>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:
边栏推荐
- [Android kotlin collaboration] use coroutinecontext to realize the retry logic after a network request fails
- 5G VoNR+之IMS Data Channel概念
- Read of shell internal value command
- 深入解析Kubebuilder
- Pointer and array are input in function to realize reverse order output
- JS also exports Excel
- Oracle -- 视图与序列
- Terms used in the Web3 community
- Code source de la fonction [analogique numérique] MATLAB allcycles () (non disponible avant 2021a)
- sublime使用技巧
猜你喜欢

When knative meets webassembly

Flask project uses flask socketio exception: typeerror: function() argument 1 must be code, not str

【二叉树】二叉树寻路

深入解析Kubebuilder

Markdown编辑器

装饰器基础学习02

3GPP信道模型路损基础知识

sublime使用技巧

DFS and BFS concepts and practices +acwing 842 arranged numbers (DFS) +acwing 844 Maze walking (BFS)

Chapter 9 Yunji datacanvas company has been ranked top 3 in China's machine learning platform market
随机推荐
JS variable plus
If you ask me about R code debugging, I will tell you head, STR, help
U++ 游戏类 学习笔记
National meteorological data / rainfall distribution data / solar radiation data /npp net primary productivity data / vegetation coverage data
How to package the parsed Excel data into objects and write this object set into the database?
Introduction to namespace Basics
DFS and BFS concepts and practices +acwing 842 arranged numbers (DFS) +acwing 844 Maze walking (BFS)
Ansible中的inventory主機清單(預祝你我有數不盡的鮮花和浪漫)
Tiktok may launch an independent grass planting community platform: will it become the second little red book
Analyse approfondie de kubebuilder
Gavin teacher's perception of transformer live class - rasa project actual combat e-commerce retail customer service intelligent business dialogue robot microservice code analysis and dialogue experim
Flex layout and usage
Ansible reports an error: "MSG": "invalid/incorrect password: permission denied, please try again“
Comparison between thread and runnable in creating threads
Basic knowledge of road loss of 3GPP channel model
How does vscade use the built-in browser?
九章云极DataCanvas公司蝉联中国机器学习平台市场TOP 3
3. Type of fund
Markdown编辑器
JS variable case output user name