# oneflow.optim.lr_scheduler.LinearLR¶

class `oneflow.optim.lr_scheduler.``LinearLR`(optimizer: oneflow.nn.optimizer.optimizer.Optimizer, start_factor: float = 0.3333333333333333, end_factor: float = 1.0, total_iters: int = 5, last_step: int = - 1, verbose: bool = False)

Decays the learning rate of each parameter group by linearly changing small multiplicative factor until the number of step reaches a pre-defined milestone: total_iters.

Parameters
• optimizer (Optimizer) – Wrapped optimizer.

• start_factor (float) – The number we multiply learning rate in the first step. The multiplication factor changes towards end_factor in the following steps. Default: 1./3.

• end_factor (float) – The number we multiply learning rate at the end of linear changing process. Default: 1.0.

• total_iters (int) – The number of iterations that multiplicative factor reaches to 1. Default: 5.

• last_step (int) – The index of the last step. Default: -1.

• verbose (bool) – If `True`, prints a message to stdout for each update. Default: `False`.

Example

```>>> # Assuming optimizer uses lr = 0.05 for all groups
>>> # lr = 0.025    if step == 0
>>> # lr = 0.03125  if step == 1
>>> # lr = 0.0375   if step == 2
>>> # lr = 0.04375  if step == 3
>>> # lr = 0.05    if step >= 4
>>> scheduler = LinearLR(self.opt, start_factor=0.5, total_iters=4)
>>> for step in range(100):
>>>     train(...)
>>>     validate(...)
>>>     scheduler.step()
```
`__init__`(optimizer: oneflow.nn.optimizer.optimizer.Optimizer, start_factor: float = 0.3333333333333333, end_factor: float = 1.0, total_iters: int = 5, last_step: int = - 1, verbose: bool = False)

Initialize self. See help(type(self)) for accurate signature.

Methods

 `__delattr__`(name, /) Implement delattr(self, name). `__dir__`() Default dir() implementation. `__eq__`(value, /) Return self==value. `__format__`(format_spec, /) Default object formatter. `__ge__`(value, /) Return self>=value. `__getattribute__`(name, /) Return getattr(self, name). `__gt__`(value, /) Return self>value. `__hash__`() Return hash(self). `__init__`(optimizer[, start_factor, …]) Initialize self. `__init_subclass__` This method is called when a class is subclassed. `__le__`(value, /) Return self<=value. `__lt__`(value, /) Return self