未验证 提交 7d9bf244 编写于 作者: F Feiyu Chan 提交者: GitHub

exclude lr scheduler's state from accumulators_holder (#33984)

* exclude lr scheduler's state from accumulators_holder

* fix when there is no learning rate scheduler

* make a copy of the loaded state dict to avoid modifying it
上级 46879ff5
......@@ -286,6 +286,11 @@ class Optimizer(object):
if isinstance(self._learning_rate, LRScheduler):
self._learning_rate.set_state_dict(state_dict["LR_Scheduler"])
# NOTE: exclude learning rate scheduler's state from
# _accumulators_holder.
state_dict = state_dict.copy()
if "LR_Scheduler" in state_dict:
state_dict.pop("LR_Scheduler")
self._accumulators_holder = state_dict
for k, v in self._accumulators.items():
for para_name, var_tmp in v.items():
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册