當前位置: 首頁>>代碼示例>>Python>>正文


Python extension.Extension方法代碼示例

本文整理匯總了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 
開發者ID:espnet,項目名稱:espnet,代碼行數:18,代碼來源:asr_utils.py

示例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 
開發者ID:espnet,項目名稱:espnet,代碼行數:18,代碼來源:asr_utils.py

示例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 
開發者ID:espnet,項目名稱:espnet,代碼行數:15,代碼來源:asr_utils.py

示例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 
開發者ID:espnet,項目名稱:espnet,代碼行數:15,代碼來源:asr_utils.py


注:本文中的chainer.training.extension.Extension方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。