noether.core.schedules¶
Submodules¶
- noether.core.schedules.base
- noether.core.schedules.constant
- noether.core.schedules.cosine
- noether.core.schedules.custom
- noether.core.schedules.functional
- noether.core.schedules.linear
- noether.core.schedules.linear_warmup_cosine_decay
- noether.core.schedules.polynomial
- noether.core.schedules.schemas
- noether.core.schedules.step
Attributes¶
Classes¶
Base class for schedules that monotonically decrease in value over time. |
|
Base class for schedules that monotonically increase in value over time. |
|
Base class for schedules that progress monotonically in value over time. |
|
Base class for schedules. |
|
A scheduler that switches between multiple schedules based on the percentage of steps completed. |
|
A scheduler that switches between multiple schedules based on the step number. |
|
Constant value schedule that returns the same value for all steps. |
|
Cosine annealing scheduler with decreasing values. |
|
Cosine annealing scheduler with increasing values. |
|
Custom schedule that simply returns the values provided in the constructor. |
|
A scheduler that decreases linearly from the maximum to minimum value over the total number of steps. |
|
A scheduler that increases linearly from the minimum to maximum value over the total number of steps. |
|
A cosine annealing scheduler with linear increasing warmup phase." |
|
A scheduler that decreases polynomially from the maximum to minimum value over the total number of steps. |
|
A scheduler that increases polynomially from the minimum to maximum value over the total number of steps. |
|
A scheduler that decreases exponentially from the maximum to minimum value over the total number of steps. |
|
A scheduler that progresses at fixed steps and increases or decreases by some factor at these steps. |
|
A scheduler that progresses at fixed intervals and increases or decreases by some factor at these intervals. |
|
Functions¶
|
cosine schedule from [0 to 1] |
|
linearly increasing from [0 to 1] |
|
polynomial schedule from [0 to 1] |
Package Contents¶
- class noether.core.schedules.DecreasingProgressSchedule(config)¶
Bases:
ProgressScheduleBase class for schedules that monotonically decrease in value over time.
Initialize the scheduler.
- Parameters:
config (noether.core.schedules.schemas.DecreasingProgressScheduleConfig)
- class noether.core.schedules.IncreasingProgressSchedule(config)¶
Bases:
ProgressScheduleBase class for schedules that monotonically increase in value over time.
Initialize the scheduler.
- Parameters:
config (noether.core.schedules.schemas.IncreasingProgressScheduleConfig)
- class noether.core.schedules.ProgressSchedule(config, start_value, delta)¶
Bases:
ScheduleBaseBase class for schedules that progress monotonically in value over time.
Initialize the scheduler.
- Parameters:
config (noether.core.schedules.schemas.ProgressScheduleConfig) – Configuration for the progress schedule.
start_value (float) – The initial value of the scheduler.
delta (float) – The total change in value over the schedule.
- start_value¶
- delta¶
- exclude_first¶
- exclude_last¶
- class noether.core.schedules.ScheduleBase(overhang_percent=None, overhang_steps=None)¶
Base class for schedules.
Initialize the scheduler.
- Parameters:
- overhang_percent = None¶
- overhang_steps = None¶
- get_value(step, total_steps)¶
Get the value of the schedule at a given step.
This function includes the correction for overhangs in percent or steps and then calls the _get_value method. Therefore, it should not be overwritten by subclasses. Instead, the _get_value method should be implemented.
- class noether.core.schedules.SequentialPercentSchedule(schedule_configs)¶
Bases:
ScheduleBaseA scheduler that switches between multiple schedules based on the percentage of steps completed.
Initialize the scheduler.
- Parameters:
schedule_configs (collections.abc.Sequence[SequentialPercentScheduleConfig]) – A list of schedule configurations.
**kwargs – Additional arguments to pass to the parent class.
- schedule_configs¶
- get_sequential_schedule_config(step, total_steps)¶
- Parameters:
- Return type:
- class noether.core.schedules.SequentialPercentScheduleConfig¶
- schedule: ScheduleBase¶
- class noether.core.schedules.SequentialStepSchedule(schedule_configs, **kwargs)¶
Bases:
ScheduleBaseA scheduler that switches between multiple schedules based on the step number.
Initialize the scheduler.
- Parameters:
schedule_configs (collections.abc.Sequence[SequentialStepScheduleConfig]) – A list of schedule configurations.
**kwargs – Additional arguments to pass to the parent class.
- schedule_configs¶
- get_sequential_schedule_config(step)¶
- Parameters:
step (int)
- Return type:
SequentialStepScheduleConfig | None
- class noether.core.schedules.SequentialStepScheduleConfig¶
- schedule: ScheduleBase¶
- class noether.core.schedules.ConstantSchedule(config)¶
Bases:
noether.core.schedules.base.ScheduleBaseConstant value schedule that returns the same value for all steps.
Example
schedule_config: kind: noether.core.schedules.ConstantSchedule value: ${model.optim.lr}
- Parameters:
config (ConstantScheduleConfig) – Configuration of the constant schedule. See
ConstantScheduleConfigfor details.
- value¶
- class noether.core.schedules.ConstantScheduleConfig(/, **data)¶
Bases:
noether.core.schedules.schemas.ScheduleBaseConfig- Parameters:
data (Any)
- kind: Literal['noether.core.schedules.ConstantSchedule'] = 'noether.core.schedules.ConstantSchedule'¶
The fully qualified class name of the scheduler.
- class noether.core.schedules.CosineDecreasingSchedule(config)¶
Bases:
noether.core.schedules.base.DecreasingProgressScheduleCosine annealing scheduler with decreasing values.
Example
schedule_config: kind: noether.core.schedules.CosineDecreasingSchedule max_value: ${model.optim.lr} # or just manually set the starting value end_value: 0.0
Initialize the scheduler.
- Parameters:
config (noether.core.schedules.schemas.DecreasingProgressScheduleConfig)
- class noether.core.schedules.CosineDecreasingScheduleConfig(/, **data)¶
Bases:
noether.core.schedules.base.DecreasingProgressScheduleConfig- Parameters:
data (Any)
- kind: Literal['noether.core.schedules.CosineDecreasingSchedule'] = 'noether.core.schedules.CosineDecreasingSchedule'¶
The fully qualified class name of the scheduler.
- class noether.core.schedules.CosineIncreasingSchedule(config)¶
Bases:
noether.core.schedules.base.IncreasingProgressScheduleCosine annealing scheduler with increasing values.
Example
schedule_config: kind: noether.core.schedules.CosineIncreasingSchedule max_value: ${model.optim.lr} start_value: 0.0
Initialize the scheduler.
- Parameters:
config (noether.core.schedules.schemas.IncreasingProgressScheduleConfig)
- class noether.core.schedules.CosineIncreasingScheduleConfig(/, **data)¶
Bases:
noether.core.schedules.schemas.IncreasingProgressScheduleConfig- Parameters:
data (Any)
- kind: Literal['noether.core.schedules.CosineIncreasingSchedule'] = 'noether.core.schedules.CosineIncreasingSchedule'¶
The fully qualified class name of the scheduler.
- class noether.core.schedules.CustomSchedule(config)¶
Bases:
noether.core.schedules.base.ScheduleBaseCustom schedule that simply returns the values provided in the constructor.
Example
schedule_config: kind: noether.core.schedules.CustomSchedule values: - 1.0e-3 - 5.0e-4 - 1.0e-4
- Parameters:
config (CustomScheduleConfig) – Configuration of the custom schedule. See
CustomScheduleConfigfor details.
- values¶
- class noether.core.schedules.CustomScheduleConfig(/, **data)¶
Bases:
noether.core.schedules.schemas.ScheduleBaseConfig- Parameters:
data (Any)
- kind: Literal['noether.core.schedules.CustomSchedule'] = 'noether.core.schedules.CustomSchedule'¶
The fully qualified class name of the scheduler.
- noether.core.schedules.cosine(step, total_steps)¶
cosine schedule from [0 to 1]
- noether.core.schedules.linear(step, total_steps)¶
linearly increasing from [0 to 1]
- noether.core.schedules.polynomial(step, total_steps, power)¶
polynomial schedule from [0 to 1] https://pytorch.org/docs/stable/generated/torch.optim.lr_scheduler.PolynomialLR.html
- class noether.core.schedules.LinearDecreasingSchedule(config)¶
Bases:
noether.core.schedules.base.DecreasingProgressScheduleA scheduler that decreases linearly from the maximum to minimum value over the total number of steps.
Example
schedule_config: kind: noether.core.schedules.LinearDecreasingSchedule max_value: ${model.optim.lr} end_value: 0.0
Initialize the scheduler.
- Parameters:
config (noether.core.schedules.schemas.DecreasingProgressScheduleConfig)
- class noether.core.schedules.LinearDecreasingScheduleConfig(/, **data)¶
Bases:
noether.core.schedules.base.DecreasingProgressScheduleConfig- Parameters:
data (Any)
- kind: Literal['noether.core.schedules.LinearDecreasingSchedule'] = 'noether.core.schedules.LinearDecreasingSchedule'¶
The fully qualified class name of the scheduler.
- class noether.core.schedules.LinearIncreasingSchedule(config)¶
Bases:
noether.core.schedules.base.IncreasingProgressScheduleA scheduler that increases linearly from the minimum to maximum value over the total number of steps.
Example
schedule_config: kind: noether.core.schedules.LinearIncreasingSchedule max_value: ${model.optim.lr} start_value: 0.0
Initialize the scheduler.
- Parameters:
config (noether.core.schedules.schemas.IncreasingProgressScheduleConfig)
- class noether.core.schedules.LinearIncreasingScheduleConfig(/, **data)¶
Bases:
noether.core.schedules.base.IncreasingProgressScheduleConfig- Parameters:
data (Any)
- kind: Literal['noether.core.schedules.LinearIncreasingSchedule'] = 'noether.core.schedules.LinearIncreasingSchedule'¶
The fully qualified class name of the scheduler.
- class noether.core.schedules.LinearWarmupCosineDecaySchedule(config)¶
Bases:
noether.core.schedules.base.ScheduleBaseA cosine annealing scheduler with linear increasing warmup phase.”
Example
schedule_config: kind: noether.core.schedules.LinearWarmupCosineDecaySchedule warmup_percent: 0.05 end_value: 1.0e-6 max_value: ${model.optim.lr} # or just manually set the max value
Takes either warmup_steps or warmup_percent as argument to determine the length of the warmup phase.
- Parameters:
config (LinearWarmupCosineDecayScheduleConfig) – Configuration for the linear warmup cosine decay schedule. See
LinearWarmupCosineDecayScheduleConfigfor details.
- warmup_steps¶
- warmup_percent¶
- class noether.core.schedules.LinearWarmupCosineDecayScheduleConfig(/, **data)¶
Bases:
noether.core.schedules.schemas.ScheduleBaseConfig- Parameters:
data (Any)
- max_value: float = None¶
The maximum value of the scheduler from which to start the cosine decay phase. This should be equal to the learning rate defined in the optimizer. I.e., max value is learning rate
- kind: Literal['noether.core.schedules.LinearWarmupCosineDecaySchedule'] = 'noether.core.schedules.LinearWarmupCosineDecaySchedule'¶
The fully qualified class name of the scheduler.
- warmup_steps: int | None = None¶
The number of steps to linearly increase the value from start to max.
- warmup_percent: float | None = None¶
The percentage of steps to linearly increase the value from start to max.
- validate_warmup()¶
Ensures that exactly one of ‘warmup_steps’ or ‘warmup_percent’ is specified.
- Return type:
- class noether.core.schedules.PolynomialDecreasingSchedule(config)¶
Bases:
noether.core.schedules.base.DecreasingProgressScheduleA scheduler that decreases polynomially from the maximum to minimum value over the total number of steps.
- Parameters:
config (PolynomialDecreasingScheduleConfig) – Configuration for the polynomial decreasing schedule. See
PolynomialDecreasingScheduleConfigfor details.
Example
schedule_config: kind: noether.core.schedules.PolynomialDecreasingSchedule power: 2.0 start_value: ${model.optim.lr} # reference to the lr defined above end_value: 1e-6
- power¶
- class noether.core.schedules.PolynomialDecreasingScheduleConfig(/, **data)¶
Bases:
noether.core.schedules.schemas.DecreasingProgressScheduleConfig- Parameters:
data (Any)
- kind: Literal['noether.core.schedules.PolynomialDecreasingSchedule'] = 'noether.core.schedules.PolynomialDecreasingSchedule'¶
The fully qualified class name of the scheduler.
- class noether.core.schedules.PolynomialIncreasingSchedule(config)¶
Bases:
noether.core.schedules.base.IncreasingProgressScheduleA scheduler that increases polynomially from the minimum to maximum value over the total number of steps.
- Parameters:
config (PolynomialIncreasingScheduleConfig) – Configuration for the polynomial increasing schedule. See
PolynomialIncreasingScheduleConfigfor details.
Example
schedule_config: kind: noether.core.schedules.PolynomialIncreasingSchedule power: 2.0 start_value: 1e-6 max_value: ${model.optim.lr} # reference to the lr defined above
- power¶
- class noether.core.schedules.PolynomialIncreasingScheduleConfig(/, **data)¶
Bases:
noether.core.schedules.schemas.IncreasingProgressScheduleConfig- Parameters:
data (Any)
- kind: Literal['noether.core.schedules.PolynomialIncreasingSchedule'] = 'noether.core.schedules.PolynomialIncreasingSchedule'¶
The fully qualified class name of the scheduler.
- class noether.core.schedules.DecreasingProgressScheduleConfig(/, **data)¶
Bases:
ProgressScheduleConfig- Parameters:
data (Any)
- kind: Literal['noether.core.schedules.DecreasingProgressSchedule'] = 'noether.core.schedules.DecreasingProgressSchedule'¶
The fully qualified class name of the scheduler.
- class noether.core.schedules.IncreasingProgressScheduleConfig(/, **data)¶
Bases:
ProgressScheduleConfig- Parameters:
data (Any)
- kind: Literal['noether.core.schedules.IncreasingProgressSchedule'] = 'noether.core.schedules.IncreasingProgressSchedule'¶
The fully qualified class name of the scheduler.
- class noether.core.schedules.ProgressScheduleConfig(/, **data)¶
Bases:
ScheduleBaseConfig- Parameters:
data (Any)
- kind: Literal['noether.core.schedules.ProgressSchedule'] = 'noether.core.schedules.ProgressSchedule'¶
The fully qualified class name of the scheduler.
- class noether.core.schedules.ScheduleBaseConfig(/, **data)¶
Bases:
pydantic.BaseModel- Parameters:
data (Any)
- overhang_percent: float | None = None¶
The percentage by which the schedule is artificially prolonged. Mutually exclusive with overhang_steps.
- overhang_steps: int | None = None¶
The number of steps by which the schedule is artificially prolonged. Mutually exclusive with overhang_percent.
- interval: Literal['update', 'epoch'] = None¶
Whether the schedule is based on updates or epochs. Interval should be either “update” or “epoch”. Default is “update”. Under the hood steps is always used. However, when “epoch” is selected here, the step count is derived from epochs via the UpdateCounter.
- check_mutual_exclusion()¶
Ensures that ‘overhang_percent’ and ‘overhang_steps’ are mutually exclusive.
- Return type:
- validate_start_end_steps()¶
- Return type:
- validate_start_end_percents()¶
- Return type:
- class noether.core.schedules.SchedulerConfig(/, **data)¶
Bases:
ScheduleBaseConfig- Parameters:
data (Any)
- kind: Literal['noether.core.schedules.scheduler.SchedulerConfig'] = 'noether.core.schedules.scheduler.SchedulerConfig'¶
The fully qualified class name of the scheduler.
- class noether.core.schedules.StepDecreasingSchedule(config)¶
Bases:
noether.core.schedules.base.DecreasingProgressScheduleA scheduler that decreases exponentially from the maximum to minimum value over the total number of steps.
Example
schedule_config: kind: noether.core.schedules.StepDecreasingSchedule factor: 0.1 decreases_interval: 0.01 max_value: ${model.optim.lr}
I.e., after each 1% of the total training steps, the value is multiplied by 0.1.
- Parameters:
config (StepDecreasingScheduleConfig) – The configuration for the scheduler. See
StepDecreasingScheduleConfigfor details.
- factor¶
- decreases_interval¶
- class noether.core.schedules.StepDecreasingScheduleConfig(/, **data)¶
Bases:
noether.core.schedules.schemas.DecreasingProgressScheduleConfig- Parameters:
data (Any)
- kind: Literal['noether.core.schedules.StepDecreasingSchedule'] = 'noether.core.schedules.StepDecreasingSchedule'¶
The fully qualified class name of the scheduler.
- check_interval()¶
Ensures that ‘interval’ is a float in the range (0, 1).
- Return type:
- class noether.core.schedules.StepFixedSchedule(config)¶
Bases:
noether.core.schedules.base.ScheduleBaseA scheduler that progresses at fixed steps and increases or decreases by some factor at these steps.
- Parameters:
config (StepFixedScheduleConfig) – Configuration for the step fixed schedule.
Example:
schedule_config: kind: noether.core.schedules.StepFixedSchedule factor: 0.1 start_value: ${model.optim.lr} steps: - 0.01 - 0.02 - 0.03
Lower LR by factor 0.1 at 1%, 2%, and 3% of total training steps.
- steps¶
- start_value¶
- factor¶
- class noether.core.schedules.StepFixedScheduleConfig(/, **data)¶
Bases:
noether.core.schedules.schemas.ScheduleBaseConfig- Parameters:
data (Any)
- kind: Literal['noether.core.schedules.StepFixedSchedule'] = 'noether.core.schedules.StepFixedSchedule'¶
The fully qualified class name of the scheduler.
- factor: float = None¶
The factor by which the value is multiplied after reaching the next step provided in steps.
- steps: list[float] = None¶
The steps at which the value changes, must be a list of floats in the range (0, 1).
- validate_steps()¶
Ensures that ‘steps’ is a non-empty list of floats in the range (0, 1).
- Return type:
- class noether.core.schedules.StepIntervalSchedule(config)¶
Bases:
noether.core.schedules.base.ScheduleBaseA scheduler that progresses at fixed intervals and increases or decreases by some factor at these intervals.
- Parameters:
config (StepIntervalScheduleConfig) – Configuration for the step interval schedule.
Example:
schedule_config: kind: noether.core.schedules.StepIntervalSchedule start_value: 1.0 factor: 0.5 update_interval: 0.01
- start_value¶
- factor¶
- update_interval¶
- class noether.core.schedules.StepIntervalScheduleConfig(/, **data)¶
Bases:
noether.core.schedules.schemas.ScheduleBaseConfig- Parameters:
data (Any)
- kind: Literal['noether.core.schedules.StepIntervalSchedule'] = 'noether.core.schedules.StepIntervalSchedule'¶
The fully qualified class name of the scheduler.
- noether.core.schedules.AnyScheduleConfig¶