Class PolynomialLRScheduler
- Namespace
- AiDotNet.LearningRateSchedulers
- Assembly
- AiDotNet.dll
Decays the learning rate using a polynomial function.
public class PolynomialLRScheduler : LearningRateSchedulerBase, ILearningRateScheduler
- Inheritance
-
PolynomialLRScheduler
- Implements
- Inherited Members
Examples
// Polynomial decay with power=2 (quadratic)
var scheduler = new PolynomialLRScheduler(
baseLearningRate: 0.1,
totalSteps: 100,
power: 2.0,
endLearningRate: 0.001
);
Remarks
PolynomialLR decays the learning rate from the initial value to a minimum value using a polynomial function. The decay curve can be controlled by the power parameter - power=1 gives linear decay, power>1 gives faster initial decay, power<1 gives slower initial decay.
For Beginners: This scheduler provides flexible control over how fast the learning rate decreases. With power=1, it's a straight line decrease. With power=2, it decreases slowly at first then more rapidly. With power=0.5, it decreases rapidly at first then slows down. This flexibility lets you customize the decay curve to your specific training needs.
Formula: lr = (base_lr - end_lr) * (1 - step/total_steps)^power + end_lr
Constructors
PolynomialLRScheduler(double, int, double, double)
Initializes a new instance of the PolynomialLRScheduler class.
public PolynomialLRScheduler(double baseLearningRate, int totalSteps, double power = 1, double endLearningRate = 0)
Parameters
baseLearningRatedoubleThe initial learning rate.
totalStepsintTotal number of steps over which to decay.
powerdoubleThe power of the polynomial. Default: 1.0 (linear)
endLearningRatedoubleThe final learning rate. Default: 0
Exceptions
- ArgumentException
Thrown when parameters are invalid.
Properties
EndLearningRate
Gets the end learning rate.
public double EndLearningRate { get; }
Property Value
Power
Gets the polynomial power.
public double Power { get; }
Property Value
TotalSteps
Gets the total number of steps.
public int TotalSteps { get; }
Property Value
Methods
ComputeLearningRate(int)
Computes the learning rate for a given step.
protected override double ComputeLearningRate(int step)
Parameters
stepintThe step number.
Returns
- double
The computed learning rate.
GetState()
Gets the scheduler state for serialization/checkpointing.
public override Dictionary<string, object> GetState()
Returns
- Dictionary<string, object>
A dictionary containing the scheduler state.