本文整理汇总了Python中chainer.training.extension.Extension方法的典型用法代码示例。如果您正苦于以下问题:Python extension.Extension方法的具体用法?Python extension.Extension怎么用?Python extension.Extension使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类chainer.training.extension
的用法示例。
在下文中一共展示了extension.Extension方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: adadelta_eps_decay
# 需要导入模块: from chainer.training import extension [as 别名]
# 或者: from chainer.training.extension import Extension [as 别名]
def adadelta_eps_decay(eps_decay):
"""Extension to perform adadelta eps decay.
Args:
eps_decay (float): Decay rate of eps.
Returns:
An extension function.
"""
@training.make_extension(trigger=(1, "epoch"))
def adadelta_eps_decay(trainer):
_adadelta_eps_decay(trainer, eps_decay)
return adadelta_eps_decay
示例2: adam_lr_decay
# 需要导入模块: from chainer.training import extension [as 别名]
# 或者: from chainer.training.extension import Extension [as 别名]
def adam_lr_decay(eps_decay):
"""Extension to perform adam lr decay.
Args:
eps_decay (float): Decay rate of lr.
Returns:
An extension function.
"""
@training.make_extension(trigger=(1, "epoch"))
def adam_lr_decay(trainer):
_adam_lr_decay(trainer, eps_decay)
return adam_lr_decay
示例3: restore_snapshot
# 需要导入模块: from chainer.training import extension [as 别名]
# 或者: from chainer.training.extension import Extension [as 别名]
def restore_snapshot(model, snapshot, load_fn=chainer.serializers.load_npz):
"""Extension to restore snapshot.
Returns:
An extension function.
"""
@training.make_extension(trigger=(1, "epoch"))
def restore_snapshot(trainer):
_restore_snapshot(model, snapshot, load_fn)
return restore_snapshot
示例4: torch_snapshot
# 需要导入模块: from chainer.training import extension [as 别名]
# 或者: from chainer.training.extension import Extension [as 别名]
def torch_snapshot(savefun=torch.save, filename="snapshot.ep.{.updater.epoch}"):
"""Extension to take snapshot of the trainer for pytorch.
Returns:
An extension function.
"""
@extension.make_extension(trigger=(1, "epoch"), priority=-100)
def torch_snapshot(trainer):
_torch_snapshot_object(trainer, trainer, filename.format(trainer), savefun)
return torch_snapshot