StateParamScheduler#
- class ignite.handlers.state_param_scheduler.StateParamScheduler(param_name, save_history=False, create_new=False)[source]#
An abstract class for updating an engine state parameter values during training.
- Parameters
param_name (str) – name of parameter to update.
save_history (bool) – whether to log the parameter values to
engine.state.param_history, (default=False).create_new (bool) – whether to create
param_nameonengine.statetaking into account whetherparam_nameattribute already exists or not. Overrides existing attribute by default, (default=False).
Note
Parameter scheduler works independently of the internal state of the attached engine. More precisely, whatever the state of the engine (newly created or used by another scheduler) the scheduler sets defined absolute values.
New in version 0.5.0.
Methods
Attach the handler to the engine.
Method to simulate scheduled engine state parameter values during num_events events.
- attach(engine, event=Events.ITERATION_COMPLETED)[source]#
Attach the handler to the engine. Once the handler is attached, the
Engine.statewill have a new attribute with the nameparam_name. Then the current value of the parameter can be retrieved fromEngine.statewhen the engine is running.- Parameters
engine (ignite.engine.engine.Engine) – trainer to which the handler will be attached.
event (Union[str, ignite.engine.events.Events, ignite.engine.events.CallableEventWithFilter, ignite.engine.events.EventsList]) – trigger
param_namevalue update.
- Return type
- classmethod simulate_values(num_events, **scheduler_kwargs)[source]#
Method to simulate scheduled engine state parameter values during num_events events.
- Parameters
num_events (int) – number of events during the simulation.
scheduler_kwargs (Any) – parameter scheduler configuration kwargs.
- Returns
event_index, value
- Return type
List[List[int]]
Examples:
import matplotlib.pyplot as plt import numpy as np step_state_param_values = np.array( StepStateScheduler.simulate_values( num_events=20, param_name="step_scheduled_param", initial_value=10, gamma=0.99, step_size=5 ) ) plt.plot(step_state_param_values[:, 0], step_state_param_values[:, 1], label="learning rate") plt.xlabel("events") plt.ylabel("values") plt.legend()