torch.nn.Module.state_dict (Python method, in Module)
state_dict
(destination=None, prefix='', keep_vars=False)[source]
返回一个包含整个模型状态的字典。包含参数和现在的缓冲器(例如,运行平均值)。键对应着参数和缓冲器的名字。
返回值:
a dictionary containing a whole state of the module
例:
>>> module.state_dict().keys()
['bias', 'weight']
state_dict
()[source]
以字典的形式返回优化器的状态。
包含两个词目:
class torch.optim.lr_scheduler.MultiplicativeLR
(optimizer, lr_lambda, last_epoch=-1)[source]
将每个参数组的学习率乘以指定函数中给定的因子。当last_epoch = -1时,设置学习率为初始学习率。
参数:
例:
>>> lmbda = lambda epoch: 0.95
>>> scheduler = MultiplicativeLR(optimizer, lr_lambda=lmbda)
>>> for epoch in range(100):
>>> train(...)
>>> validate(...)
>>> scheduler.step()
load_state_dict
(state_dict)[source]
加载策略状态
参数:
state_dict
()[source]
Returns the state of the scheduler as a 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.__dict__中的实体,这不是优化器。如果它们是可以调用的对象的话,学习率lambda函数就保存,如果他们是函数或者lambdas的话就不保存。