ParamGroupScheduler¶
-
class
ignite.contrib.handlers.param_scheduler.
ParamGroupScheduler
(schedulers, names=None, save_history=False)[source]¶ Scheduler helper to group multiple schedulers into one.
- Parameters
schedulers (List[ignite.contrib.handlers.param_scheduler.ParamScheduler]) – list/tuple of parameter schedulers.
names (Optional[List[str]]) – list of names of schedulers.
save_history (bool) – whether to save history or not.
optimizer = SGD( [ {"params": model.base.parameters(), 'lr': 0.001), {"params": model.fc.parameters(), 'lr': 0.01), ] ) scheduler1 = LinearCyclicalScheduler(optimizer, 'lr', 1e-7, 1e-5, len(train_loader), param_group_index=0) scheduler2 = CosineAnnealingScheduler(optimizer, 'lr', 1e-5, 1e-3, len(train_loader), param_group_index=1) lr_schedulers = [scheduler1, scheduler2] names = ["lr (base)", "lr (fc)"] scheduler = ParamGroupScheduler(schedulers=lr_schedulers, names=names) # Attach single scheduler to the trainer trainer.add_event_handler(Events.ITERATION_STARTED, scheduler)
Methods
Copies parameters from
state_dict
into this ParamScheduler.Method to simulate scheduled values during num_events events.
Returns a dictionary containing a whole state of ParamGroupScheduler.
-
load_state_dict
(state_dict)[source]¶ Copies parameters from
state_dict
into this ParamScheduler.- Parameters
state_dict (Mapping) – a dict containing parameters.
- Return type
-
classmethod
simulate_values
(num_events, schedulers, **kwargs)[source]¶ Method to simulate scheduled values during num_events events.
- Parameters
num_events (int) – number of events during the simulation.
schedulers (List[torch.optim.lr_scheduler._LRScheduler]) – lr_scheduler object to wrap.
kwargs (Any) – kwargs passed to construct an instance of
ignite.contrib.handlers.param_scheduler.ParamGroupScheduler
.
- Returns
event_index, value
- Return type
List[List[int]]