mindspore.nn.warmup_lr
- mindspore.nn.warmup_lr(learning_rate, total_step, step_per_epoch, warmup_epoch)[source]
- Gets learning rate warming up. The learning rate for each step will be stored in a list. - For the i-th step, the formula of computing warmup_learning_rate[i] is: \[warmup\_learning\_rate[i] = learning\_rate * tmp\_epoch / warmup\_epoch\]- Where \(tmp\_epoch= \min(current\_epoch, warmup\_epoch),\ current\_epoch=floor(\frac{i}{step\_per\_epoch})\) - Parameters
- Returns
- list[float]. The size of list is total_step. 
- Raises
- TypeError – If learning_rate is not a float. 
- TypeError – If total_step or step_per_epoch or decay_epoch is not an int. 
- ValueError – If learning_rate is less than 0. 
 
 - Supported Platforms:
- Ascend- GPU- CPU
 - Examples - >>> import mindspore.nn as nn >>> >>> learning_rate = 0.1 >>> total_step = 6 >>> step_per_epoch = 2 >>> warmup_epoch = 2 >>> lr = nn.warmup_lr(learning_rate, total_step, step_per_epoch, warmup_epoch) >>> net = nn.Dense(2, 3) >>> optim = nn.SGD(net.trainable_params(), learning_rate=lr)