Shortcuts

PiecewiseLinearStateScheduler#

class ignite.handlers.state_param_scheduler.PiecewiseLinearStateScheduler(milestones_values, param_name, save_history=False)[source]#

Piecewise linear state parameter scheduler.

Parameters
  • milestones_values (List[Tuple[int, float]]) – list of tuples (event index, parameter value) represents milestones and parameter values. Milestones should be increasing integers.

  • param_name (str) – name of parameter to update.

  • save_history (bool) – whether to log the parameter values to engine.state.param_history, (default=False).

Examples

...
engine = Engine(train_step)

param_scheduler = PiecewiseLinearStateScheduler(
    param_name="param",
    milestones_values=[(10, 0.5), (20, 0.45), (21, 0.3), (30, 0.1), (40, 0.1)]
)

param_scheduler.attach(engine, Events.EPOCH_COMPLETED)

# basic handler to print scheduled state parameter
engine.add_event_handler(Events.EPOCH_COMPLETED, lambda _ : print(engine.state.param))

engine.run([0] * 8, max_epochs=40)
#
# Sets the state parameter value to 0.5 over the first 10 iterations, then decreases linearly from 0.5 to
# 0.45 between 10th and 20th iterations. Next there is a jump to 0.3 at the 21st iteration and the state
# parameter value decreases linearly from 0.3 to 0.1 between 21st and 30th iterations and remains 0.1 until
# the end of the iterations.
#

New in version 0.4.7.

Methods

get_param

Method to get current parameter values

get_param()[source]#

Method to get current parameter values

Returns

list of params, or scalar param

Return type

Union[List[float], float]