StateParamScheduler#
- class ignite.handlers.state_param_scheduler.StateParamScheduler(param_name, save_history=False)[source]#
An abstract class for updating an engine state parameter values during training.
- Parameters
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()