Shortcuts

ConcatScheduler#

class ignite.handlers.param_scheduler.ConcatScheduler(schedulers, durations, save_history=False)[source]#

Concat a list of parameter schedulers.

The ConcatScheduler goes through a list of schedulers given by schedulers. Duration of each scheduler is defined by durations list of integers.

Parameters
  • schedulers (List[ParamScheduler]) – list of parameter schedulers.

  • durations (List[int]) – list of number of events that lasts a parameter scheduler from schedulers.

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

Examples

from ignite.handlers.param_scheduler import ConcatScheduler
from ignite.handlers.param_scheduler import LinearCyclicalScheduler
from ignite.handlers.param_scheduler import CosineAnnealingScheduler

scheduler_1 = LinearCyclicalScheduler(optimizer, "lr", start_value=0.1, end_value=0.5, cycle_size=60)
scheduler_2 = CosineAnnealingScheduler(optimizer, "lr", start_value=0.5, end_value=0.01, cycle_size=60)

combined_scheduler = ConcatScheduler(schedulers=[scheduler_1, scheduler_2], durations=[30, ])
trainer.add_event_handler(Events.ITERATION_STARTED, combined_scheduler)
#
# Sets the Learning rate linearly from 0.1 to 0.5 over 30 iterations. Then
# starts an annealing schedule from 0.5 to 0.01 over 60 iterations.
# The annealing cycles are repeated indefinitely.

New in version 0.4.5.

Methods

get_param

Method to get current parameter values

load_state_dict

Copies parameters from state_dict into this ConcatScheduler.

simulate_values

Method to simulate scheduled values during num_events events.

state_dict

Returns a dictionary containing a whole state of ConcatScheduler.

get_param()[source]#

Method to get current parameter values

Returns

list of params, or scalar param

Return type

Union[List[float], float]

load_state_dict(state_dict)[source]#

Copies parameters from state_dict into this ConcatScheduler.

Parameters

state_dict (Mapping) – a dict containing parameters.

Return type

None

classmethod simulate_values(num_events, schedulers, durations, param_names=None)[source]#

Method to simulate scheduled values during num_events events.

Parameters
  • num_events (int) – number of events during the simulation.

  • schedulers (List[ParamScheduler]) – list of parameter schedulers.

  • durations (List[int]) – list of number of events that lasts a parameter scheduler from schedulers.

  • param_names (Optional[Union[List[str], Tuple[str]]]) – parameter name or list of parameter names to simulate values. By default, the first scheduler’s parameter name is taken.

Returns

list of [event_index, value_0, value_1, …], where values correspond to param_names.

Return type

List[List[int]]

state_dict()[source]#

Returns a dictionary containing a whole state of ConcatScheduler.

Returns

a dictionary containing a whole state of ConcatScheduler

Return type

dict