当前位置:网站首页>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:
边栏推荐
- 谈谈讲清楚这件事的重要性
- AttributeError: module ‘torch._C‘ has no attribute ‘_cuda_setDevice‘
- 高手勿进!写给初中级程序员以及还在大学修炼的“准程序员”的成长秘籍
- A detailed explanation of head pose estimation [collect good articles]
- 【736. Lisp 语法解析】
- 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
- A row of code r shows the table of Cox regression model
- [Android kotlin collaboration] use coroutinecontext to realize the retry logic after a network request fails
- What is JVM? What are the purposes of JVM tuning?
- 基于Bevy游戏引擎和FPGA的双人游戏
猜你喜欢

Oracle -- 视图与序列

Ansible overview and module explanation (you just passed today, but yesterday came to your face)

How to design API interface and realize unified format return?

R语言主成分pca、因子分析、聚类对地区经济研究分析重庆市经济指标

acwing 843. N-queen problem

Inventory host list in ansible (I wish you countless flowers and romance)

System framework of PureMVC

A simple and beautiful regression table is produced in one line of code~

【二叉树】二叉树寻路

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
随机推荐
Programmers go to work fishing, so play high-end!
Test interview | how much can you answer the real test interview question of an Internet company?
Lessons and thoughts of the first SQL injection
U++ 游戏类 学习笔记
[hand torn STL] list
Depth first traversal template principle of tree and graph
Inventory host list in ansible (I wish you countless flowers and romance)
How does vscade use the built-in browser?
JS variable
R语言主成分pca、因子分析、聚类对地区经济研究分析重庆市经济指标
What is JVM? What are the purposes of JVM tuning?
Local tool [Navicat] connects to remote [MySQL] operation
接口间调用为什么要用json、fastjson怎么赋值的、fastjson [email protected]映射关系问题
R descriptive statistics and hypothesis testing
Comparison between thread and runnable in creating threads
Introduction to the PureMVC series
窗口可不是什么便宜的东西
Structure actual training camp | after class homework | module 6
Canteen user dish relationship system (C language course design)
In depth analysis of kubebuilder