当前位置:网站首页>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:
边栏推荐
- Liste des hôtes d'inventaire dans ansible (je vous souhaite des fleurs et de la romance sans fin)
- STM32封装ESP8266一键配置函数:实现实现AP模式和STA模式切换、服务器与客户端创建
- 当 Knative 遇见 WebAssembly
- 基于Bevy游戏引擎和FPGA的双人游戏
- Read of shell internal value command
- [digital analog] source code of MATLAB allcycles() function (not available before 2021a)
- 深入解析Kubebuilder
- Depth first traversal template principle of tree and graph
- Ansible中的inventory主機清單(預祝你我有數不盡的鮮花和浪漫)
- Common Oracle SQL statements
猜你喜欢

Weebly移动端网站编辑器 手机浏览新时代

一文搞懂常见的网络I/O模型

Why do many people misunderstand technical debt

Windows are not cheap things

Monitoring cannot be started after Oracle modifies the computer name

How to choose an offer and what factors should be considered

Weebly mobile website editor mobile browsing New Era

A row of code r shows the table of Cox regression model

System framework of PureMVC

5G VoNR+之IMS Data Channel概念
随机推荐
A simple and beautiful regression table is produced in one line of code~
【愚公系列】2022年7月 Go教学课程 005-变量
JS also exports Excel
Thread和Runnable创建线程的方式对比
Why do many people misunderstand technical debt
Oracle -- 视图与序列
JS variable case
Markdown editor
DFS and BFS concepts and practices +acwing 842 arranged numbers (DFS) +acwing 844 Maze walking (BFS)
为什么很多人对技术债务产生误解
STM32F103实现IAP在线升级应用程序
AttributeError: module ‘torch._C‘ has no attribute ‘_cuda_setDevice‘
3.基金的类型
Basic idea of counting and sorting
Talk about the importance of making it clear
【数模】Matlab allcycles()函数的源代码(2021a之前版本没有)
Analysis -- MySQL statement execution process & MySQL architecture
[736. LISP syntax parsing]
关于01背包个人的一些理解
Code source de la fonction [analogique numérique] MATLAB allcycles () (non disponible avant 2021a)