updater_creator.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:chainercmd 作者: mitmul 项目源码 文件源码
def updater_creator(iterator, optimizer, devices, **kwargs):
    """A sample updater creator.

    An updater creator method should return an Updater object.
    Once an updter creator method is specified in the config YAML, the method
    will take iterator object, optimizer object, device dictionary, and "args"
    dictionary defined in the config YAML. You can make a custom Updater with
    those objects and return it.

    """
    if HAVE_NCCL and len(devices) > 1:
        updater = training.updaters.MultiprocessParallelUpdater(
            iterator, optimizer, devices=devices)
    elif len(devices) > 1:
        optimizer.lr /= len(devices)
        updater = training.ParallelUpdater(
            iterator, optimizer, devices=devices)
    else:
        updater = training.StandardUpdater(
            iterator, optimizer, device=devices['main'])
    return updater
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号