LinearLR#
- class torch.optim.lr_scheduler.LinearLR(optimizer, start_factor=0.3333333333333333, end_factor=1.0, total_iters=5, last_epoch=-1)[source]#
通过线性改变小的乘法因子来衰减每个参数组的学习率。
乘法操作会一直进行,直到 epoch 数量达到预设的里程碑:total_iters。请注意,这种衰减可以与其他来自此调度器外部的学习率变化同时发生。当 last_epoch=-1 时,将初始学习率设置为 lr。
- 参数
示例
>>> # Assuming optimizer uses lr = 0.05 for all groups >>> # lr = 0.003687 if epoch == 0 >>> # lr = 0.004875 if epoch == 1 >>> # lr = 0.006062 if epoch == 2 >>> # lr = 0.00725 if epoch == 3 >>> # ... >>> # lr = 0.05 if epoch >= 40 >>> scheduler = LinearLR(optimizer, start_factor=0.05, total_iters=40) >>> for epoch in range(100): >>> train(...) >>> validate(...) >>> scheduler.step()
- load_state_dict(state_dict)[source]#
加载调度器的状态。
- 参数
state_dict (dict) – 调度器状态。应该是一个由调用
state_dict()返回的对象。