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_name
onengine.state
taking into account whetherparam_name
attribute 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.4.7.
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.state
will have a new attribute with the nameparam_name
. Then the current value of the parameter can be retrieved fromEngine.state
when the engine is running.- Parameters
engine (Engine) – trainer to which the handler will be attached.
event (Union[str, Events, CallableEventWithFilter, EventsList]) – trigger
param_name
value update.
- Return type
None
- classmethod simulate_values(num_events, **scheduler_kwargs)[source]#
Method to simulate scheduled engine state parameter values during num_events events.
- Parameters
- Returns
event_index, value
- Return type
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()