Skip to content

lit_sb3.utils.schedule

source module lit_sb3.utils.schedule

Learning rate and clip-range schedule helpers.

Classes

  • FloatSchedule — Wrapper that ensures the output of a Schedule is cast to float.

  • LinearSchedule — LinearSchedule interpolates linearly between start and end.

  • ConstantSchedule — Constant schedule that always returns the same value.

  • SimpleLinearSchedule — Linear schedule from initial_value down to 0 as training progresses.

Functions

source class FloatSchedule(value_schedule: Schedule | float)

Wrapper that ensures the output of a Schedule is cast to float.

Can wrap either a constant value or an existing callable Schedule.

Parameters

  • value_schedule : Schedule | float — Constant value or callable schedule (e.g. LinearSchedule, ConstantSchedule)

source class LinearSchedule(start: float, end: float, end_fraction: float)

LinearSchedule interpolates linearly between start and end.

between progress_remaining = 1 and progress_remaining = end_fraction. This is used in DQN for linearly annealing the exploration fraction (epsilon for the epsilon-greedy strategy).

Parameters

  • start : float — value to start with if progress_remaining = 1

  • end : float — value to end with if progress_remaining = 0

  • end_fraction : float — fraction of progress_remaining where end is reached e.g 0.1 then end is reached after 10% of the complete training process.

source class ConstantSchedule(val: float)

Constant schedule that always returns the same value.

Useful for fixed learning rates or clip ranges.

Parameters

  • val : float — constant value

source class SimpleLinearSchedule(initial_value: float | str)

Linear schedule from initial_value down to 0 as training progresses.

Parameters

  • initial_value : float | str — Starting value (must be positive).

source linear_schedule(initial_value: float | str) → SimpleLinearSchedule

Return a :class:SimpleLinearSchedule for initial_value.

source get_schedule_fn(value_schedule: Schedule | float) → Schedule

Transform (if needed) learning rate and clip range (for PPO).

to callable.

Parameters

  • value_schedule : Schedule | float — Constant value of schedule function

Returns

  • Schedule — Schedule function (can return constant value)

source get_linear_fn(start: float, end: float, end_fraction: float) → Schedule

Create a function that interpolates linearly between start and end.

between progress_remaining = 1 and progress_remaining = end_fraction. This is used in DQN for linearly annealing the exploration fraction (epsilon for the epsilon-greedy strategy).

:params start: value to start with if progress_remaining = 1 :params end: value to end with if progress_remaining = 0 :params end_fraction: fraction of progress_remaining where end is reached e.g 0.1 then end is reached after 10% of the complete training process.

Returns

  • Schedule — Linear schedule function.

source constant_fn(val: float) → Schedule

Create a function that returns a constant.

It is useful for learning rate schedule (to avoid code duplication).

Parameters

  • val : float — constant value

Returns

  • Schedule — Constant schedule function.