MCPcopy Create free account
hub / github.com/AtlasAnalyticsLab/AdaFisher / state_dict

Method state_dict

optimizers/lr_scheduler.py:263–280  ·  view source on GitHub ↗

Returns the state of the scheduler as a :class:`dict`. It contains an entry for every variable in self.__dict__ which is not the optimizer. The learning rate lambda functions will only be saved if they are callable objects and not if they are functions or lambdas.

(self)

Source from the content-addressed store, hash-verified

261 super(LambdaLR, self).__init__(optimizer, last_epoch)
262
263 def state_dict(self):
264 """Returns the state of the scheduler as a :class:`dict`.
265
266 It contains an entry for every variable in self.__dict__ which
267 is not the optimizer.
268 The learning rate lambda functions will only be saved if they are callable objects
269 and not if they are functions or lambdas.
270 """
271
272 warnings.warn(SAVE_STATE_WARNING, UserWarning)
273 state_dict = {key: value for key, value in self.__dict__.items() if key not in ('optimizer', 'lr_lambdas')}
274 state_dict['lr_lambdas'] = [None] * len(self.lr_lambdas)
275
276 for idx, fn in enumerate(self.lr_lambdas):
277 if not isinstance(fn, types.FunctionType):
278 state_dict['lr_lambdas'][idx] = fn.__dict__.copy()
279
280 return state_dict
281
282 def load_state_dict(self, state_dict):
283 """Loads the schedulers state.

Callers 2

get_pretrained_modelMethod · 0.45
run_epochsMethod · 0.45

Calls

no outgoing calls

Tested by

no test coverage detected