Class LearningRateSchedulerBase
- Namespace
- AiDotNet.LearningRateSchedulers
- Assembly
- AiDotNet.dll
Base class for learning rate schedulers providing common functionality.
public abstract class LearningRateSchedulerBase : ILearningRateScheduler
- Inheritance
-
LearningRateSchedulerBase
- Implements
- Derived
- Inherited Members
Remarks
This abstract base class implements the common behavior for all learning rate schedulers, including state management, step tracking, and serialization support.
For Beginners: This is the foundation that all learning rate schedulers build upon. It handles the common tasks like keeping track of what step we're on and saving/loading state so that training can be resumed from a checkpoint.
Constructors
LearningRateSchedulerBase(double, double)
Initializes a new instance of the LearningRateSchedulerBase class.
protected LearningRateSchedulerBase(double baseLearningRate, double minLearningRate = 0)
Parameters
baseLearningRatedoubleThe initial learning rate.
minLearningRatedoubleThe minimum learning rate (floor). Default is 0.
Fields
_baseLearningRate
The base (initial) learning rate.
protected double _baseLearningRate
Field Value
_currentLearningRate
The current learning rate.
protected double _currentLearningRate
Field Value
_currentStep
The current step count.
protected int _currentStep
Field Value
_minLearningRate
The minimum learning rate (floor).
protected double _minLearningRate
Field Value
Properties
BaseLearningRate
Gets the base (initial) learning rate.
public double BaseLearningRate { get; }
Property Value
CurrentLearningRate
Gets the current learning rate.
public double CurrentLearningRate { get; }
Property Value
CurrentStep
Gets the current step (iteration or epoch count depending on scheduler type).
public int CurrentStep { get; }
Property Value
Methods
ComputeLearningRate(int)
Computes the learning rate for a given step.
protected abstract double ComputeLearningRate(int step)
Parameters
stepintThe step number.
Returns
- double
The computed learning rate.
GetLearningRateAtStep(int)
Gets the learning rate for a specific step without advancing the scheduler.
public virtual double GetLearningRateAtStep(int step)
Parameters
stepintThe step number to get the learning rate for.
Returns
- double
The learning rate at the specified step.
GetState()
Gets the scheduler state for serialization/checkpointing.
public virtual Dictionary<string, object> GetState()
Returns
- Dictionary<string, object>
A dictionary containing the scheduler state.
LoadState(Dictionary<string, object>)
Loads the scheduler state from a checkpoint.
public virtual void LoadState(Dictionary<string, object> state)
Parameters
stateDictionary<string, object>The state dictionary to load from.
Reset()
Resets the scheduler to its initial state.
public virtual void Reset()
Step()
Advances the scheduler by one step and returns the new learning rate.
public virtual double Step()
Returns
- double
The updated learning rate for the next step.