LinearSchedule#

class empulse.optimizers.LinearSchedule(start_value, end_value, n_steps)[source]#

Linear interpolation from start_value to end_value over n_steps epochs.

After n_steps epochs the schedule stays at end_value.

\[v_t = v_0 + \frac{\min(t,\, n-1)}{n-1} \, (v_{\text{end}} - v_0)\]
Parameters:
start_valuefloat

Value at epoch 0.

end_valuefloat

Value at epoch n_steps - 1 and beyond.

n_stepsint

Number of epochs to interpolate over. Must be ≥ 2.

Examples

from empulse.optimizers import LinearSchedule, Adam

schedule = LinearSchedule(start_value=0.5, end_value=20.0, n_steps=100)
# alpha grows linearly from 0.5 to 20.0 over 100 epochs
optimizer = Adam(lr=1e-3, alpha_schedule=schedule)
__call__(epoch)[source]#

Return the scheduled value at epoch (0-based).

Parameters:
epochint

Current epoch index, starting from 0.

Returns:
float

Scheduled parameter value.