本文整理匯總了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