当前位置:网站首页>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
边栏推荐
- 【点云系列】Multi-view Neural Human Rendering (NHR)
- PyTorch 18. torch.backends.cudnn
- 美摄助力百度“度咔剪辑”,让知识创作更容易
- 基于Labview上位机的51单片机步进电机控制系统(上位机代码+下位机源码+ad原理图+51完整开发环境)
- Proteus 8.10安装问题(亲测稳定不闪退!)
- PyTorch 13. 嵌套函数和闭包(狗头)
- ARMCC/GCC下的stack protector
- LPDDR4笔记
- [8] Assertion failed: dims.nbDims == 4 || dims.nbDims == 5
- 【指标】Precision、Recall
猜你喜欢
随机推荐
AUTOSAR从入门到精通100讲(八十四)-UDS之时间参数总结篇
armv8m(cortex m33) MPU实战
美摄科技推出桌面端专业视频编辑解决方案——美映PC版
基于Labview上位机的51单片机步进电机控制系统(上位机代码+下位机源码+ad原理图+51完整开发环境)
【点云系列】FoldingNet:Point Cloud Auto encoder via Deep Grid Deformation
Unable to determine the device handle for GPU 0000:02:00.0: GPU is lost.
【点云系列】 场景识别类导读
基于51单片机的三路超声波测距系统(定时器方式测距)
RISCV MMU 概述
网络层重要知识(面试、复试、期末)
Machine learning II: logistic regression classification based on Iris data set
Systrace parsing
The simplest and complete example of libwebsockets
Cmder Chinese garbled code problem
Swin transformer to onnx
重大安保事件应急通信系统解决方案
基于51单片机的温湿度监测+定时报警系统(c51源码)
AUTOSAR从入门到精通100讲(五十)-AUTOSAR 内存管理系列- ECU 抽象层和 MCAL 层
Common regular expressions
Warning "force fallback to CPU execution for node: gather_191" in onnxruntime GPU 1.7









