-
-
Notifications
You must be signed in to change notification settings - Fork 668
Closed
Labels
Description
🐛 Bug description
When scheduling multiple parameters on an engine, a KeyError exception is raised when save_history=True
To reproduce the bug:
engine = Engine(lambda e, b: None)
exp_state_parameter_scheduler1 = ExpStateScheduler(
param_name="exp_scheduled_param1", initial_value=initial_value, gamma=gamma, save_history=True
)
exp_state_parameter_scheduler2 = ExpStateScheduler(
param_name="exp_scheduled_param2", initial_value=initial_value, gamma=gamma, save_history=True
)
exp_state_parameter_scheduler1.attach(engine, Events.EPOCH_COMPLETED)
exp_state_parameter_scheduler2.attach(engine, Events.EPOCH_COMPLETED)
engine.run([0] * 8, max_epochs=max_epochs)A fix should be applied here :
| engine.state.param_history.setdefault(self.param_name, []) # type: ignore[attr-defined] |
if self.save_history:
if not hasattr(engine.state, "param_history") or engine.state.param_history is None: # type: ignore
setattr(engine.state, "param_history", {})
engine.state.param_history.setdefault(self.param_name, []) # type: ignore[attr-defined]Environment
- PyTorch Version (e.g., 1.4):
- Ignite Version (e.g., 0.3.0):
- OS (e.g., Linux):
- How you installed Ignite (
conda,pip, source): - Python version:
- Any other relevant information:
Reactions are currently unavailable