当前位置:网站首页>PyTorch 10. Learning rate
PyTorch 10. Learning rate
2022-04-23 07:28:00 【DCGJ666】
PyTorch 10. Learning rate
scheduler
scheduler: An optimizer must adjust its learning rate
class _LRScheduler(object):
def __init__(self, optimizer, last_epoch=-1):
pass
def get_lr(self):
return [base_lr * self.gamma ** (self.last_epoch//self.step_size) for base_lr in self.base_lrs]
def step(self):
if epoch is None:
epoch = self.last_epoch + 1
self.last_epoch = epoch
for param_group, lr in zip(self.optimizer.param_groups, self.get_lr()):
param_group['lr'] = lr
optimizer: Associated optimizer
last_epoch: Record epoch Count
base_lrs: Record the initial learning rate
The main method :
step(): Update next epoch Learning rate of
get_lr(): Calculate next epoch Learning rate of
StepLR
lr_scheduler.StepLR(optimizer, step_size, gamma=0.1,last_epoch=-1)
function : Adjust the learning rate at equal intervals
main parameter :
step_size: Adjust the number of intervals
gamma: Adjustment factor
arrange mode : lr = lr * gamma
MultiStepLR
lr_scheduler.MultiStepLR(optimizer, milestones, gamma=0.1, last_epoch=-1)
function : Adjust the learning rate at a given interval
main parameter :
milestones: Set the number of adjustment times ,milestones = [50, 125, 160]
gamma: Adjustment factor
arrange mode : lr = lr *gamma
ExponentialLR
lr_scheduler.ExponentialLR(optimizer, gamma, last-epoch=-1)
function : Adjust the learning rate by exponential decay
main parameter :
gamma: The bottom of the index
CosineAnnealingLR
lr_scheduler.CosineAnnealingLR(optimizer, T_max, eta_min=0, last_epoch=-1)
function : Cosine period adjusted learning rate
main parameter :
T_max: Descent cycle
eta_min: Lower limit of learning rate
arrange mode :
l r t = l r m i n + 1 2 ( l r m a x − l r m i n ) ( 1 + c o s ( T c u r T m a x π ) ) lr_t = lr_{min}+\frac{1}{2}(lr_{max}-lr_{min})(1+cos(\frac{T_{cur}}{T_{max}}\pi)) lrt=lrmin+21(lrmax−lrmin)(1+cos(TmaxTcurπ))
ReduceLRonPlateau
lr_scheduler.ReduceLROnPlateau(optimizer, mode='min', factor=0.1, patience=10, verbose=False, threshold=0.0001, threshold_mode='rel',cooldown=0, min_lr=0, eps=1e-08)
function : Monitoring indicators , When the index no longer changes, adjust
main parameter :
mode: min/max Two modes
factor: Adjustment factor
patience: “ Patience, ”, Accept several times without change
cooldown: “ Cooling time ”, Stop monitoring for a while
verbose: Whether to print the log
min_lr: Lower limit of learning rate
eps: Minimum attenuation of learning rate
Reference resources :
https://zhuanlan.zhihu.com/p/146865009
版权声明
本文为[DCGJ666]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204230611343971.html
边栏推荐
- Thanos. SH kill bully script, easily delete half of the files in the system at random
- 画 ArcFace 中的 margin 曲线
- 基于51单片机的温湿度监测+定时报警系统(c51源码)
- 直观理解 torch.nn.Unfold
- 【期刊会议系列】IEEE系列模板下载指南
- 美摄助力百度“度咔剪辑”,让知识创作更容易
- 使用proteus仿真STM32超声波SRF04测距!Code+Proteus
- EasyUI combobox determines whether the input item exists in the drop-down list
- PyTorch 17. GPU并发
- torch.where能否传递梯度
猜你喜欢
美摄助力百度“度咔剪辑”,让知识创作更容易
Detailed explanation of device tree
x509解析
Raspberry Pie: two color LED lamp experiment
带低压报警的51单片机太阳能充电宝设计与制作(完整代码资料)
Machine learning III: classification prediction based on logistic regression
【点云系列】Neural Opacity Point Cloud(NOPC)
美摄科技受邀LVSon2020大会 分享《AI合成虚拟人物的技术框架与挑战》
【点云系列】PnP-3D: A Plug-and-Play for 3D Point Clouds
Machine learning II: logistic regression classification based on Iris data set
随机推荐
AUTOSAR从入门到精通100讲(八十六)-UDS服务基础篇之2F
UEFI学习01-ARM AARCH64编译、ArmPlatformPriPeiCore(SEC)
Error in multi machine and multi card training
安装 pycuda 出现 PEP517 的错误
美摄助力百度“度咔剪辑”,让知识创作更容易
美摄科技推出桌面端专业视频编辑解决方案——美映PC版
unhandled system error, NCCL version 2.7.8
MySQL installation and configuration - detailed tutorial
Machine learning notes 1: learning ideas
关于短视频技术轮廓探讨
Swin transformer to onnx
PyTorch 9. 优化器
面试总结之特征工程
scons 搭建嵌入式arm编译
防汛救灾应急通信系统
[point cloud series] pnp-3d: a plug and play for 3D point clouds
【点云系列】 A Rotation-Invariant Framework for Deep Point Cloud Analysis
《Attention in Natural Language Processing》翻译
Use originpro express for free
Systrace 解析