当前位置: 首页>>代码示例>>Python>>正文


Python chainer.optimizer方法代码示例

本文整理汇总了Python中chainer.optimizer方法的典型用法代码示例。如果您正苦于以下问题:Python chainer.optimizer方法的具体用法?Python chainer.optimizer怎么用?Python chainer.optimizer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在chainer的用法示例。


在下文中一共展示了chainer.optimizer方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: create_updater

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import optimizer [as 别名]
def create_updater(train_iter, optimizer, config, devices):
    if "MultiprocessParallelUpdater" in config['name']:
        Updater = chainer.training.updaters.MultiprocessParallelUpdater
        return Updater(train_iter, optimizer, devices=devices,
                       converter=voxelnet_concat)

    Updater = getattr(chainer.training, config['name'])
    if "Standard" in config['name']:
        device = None if devices is None else devices['main']
        return Updater(train_iter, optimizer, device=device,
                       converter=voxelnet_concat)
    else:
        return Updater(train_iter, optimizer, devices=devices,
                       converter=voxelnet_concat) 
开发者ID:yukitsuji,项目名称:voxelnet_chainer,代码行数:16,代码来源:config_utils.py

示例2: create_optimizer

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import optimizer [as 别名]
def create_optimizer(config, model):
    Optimizer = getattr(chainer.optimizers, config['name'])
    opt = Optimizer(**config['args'])
    opt.setup(model)
    if 'hook' in config.keys():
        for key, value in config['hook'].items():
            hook = getattr(chainer.optimizer, key)
            opt.add_hook(hook(value))
    return opt 
开发者ID:yukitsuji,项目名称:voxelnet_chainer,代码行数:11,代码来源:config_utils.py

示例3: SetupOptimizer

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import optimizer [as 别名]
def SetupOptimizer(model):
    opt = optimizers.NesterovAG(
        lr=args.optimizer['lr'], momentum=0.9)
    opt.setup(model)
    return opt 
开发者ID:emrahbasaran,项目名称:SPReID,代码行数:7,代码来源:main.py

示例4: parse_args

# 需要导入模块: import chainer [as 别名]
# 或者: from chainer import optimizer [as 别名]
def parse_args():
    # set extract_features to 0 for training or 1 for feature extraction
    def_extract_features = 0
    # batch size
    def_minibatch = 16
    # image size for semantic segmentation
    def_scales_tr = '512,512'
    # image size for re-identification
    def_scales_reid = '512,170'  # '778,255'
    # learning rates for fresh and pretrained layers
    def_optimizer = 'lr:0.01--lr_pretrained:0.01'
    # GPU ids
    def_GPUs = '0'
    # set checkpoint bigger than zero to load saved model from checkpoints folder
    def_checkpoint = 0
    # set pre-trained model path for finetuning using evaluation datasets
    def_model_path_for_ft = ''

    # label for the dataset
    def_dataset = 'ReID10Dx'
    # number of different ids in training data
    def_label_dim = '16803'
    def_label_dim_ft = '16803'
    # the image list for feature extraction
    def_eval_split = 'cuhk03_gallery'
    # the image list for training
    def_train_set = 'train_10d'

    # number of workers to load images parallel
    def_nb_processes = 4
    # maximum number of iterations
    def_max_iter = 200000
    # loss report interval
    def_report_interval = 50
    # number of iterations for checkpoints
    def_save_interval = 20000

    def_project_folder = '.'
    def_dataset_folder = ''
    p = ArgumentParser()
    p.add_argument('--extract_features', default=def_extract_features, type=int)
    p.add_argument('--minibatch', default=def_minibatch, type=int)
    p.add_argument('--scales_tr', default=def_scales_tr, type=str)
    p.add_argument('--scales_reid', default=def_scales_reid, type=str)
    p.add_argument('--optimizer', default=def_optimizer, type=str)
    p.add_argument('--GPUs', default=def_GPUs, type=str)
    p.add_argument('--dataset', default=def_dataset, type=str)
    p.add_argument('--eval_split', default=def_eval_split, type=str)
    p.add_argument('--train_set', default=def_train_set, type=str)
    p.add_argument('--checkpoint', default=def_checkpoint, type=int)
    p.add_argument('--model_path_for_ft', default=def_model_path_for_ft, type=str)
    p.add_argument('--label_dim', default=def_label_dim, type=str)
    p.add_argument('--label_dim_ft', default=def_label_dim_ft, type=int)
    p.add_argument('--nb_processes', default=def_nb_processes, type=int)
    p.add_argument('--max_iter', default=def_max_iter, type=int)
    p.add_argument('--report_interval', default=def_report_interval, type=int)
    p.add_argument('--save_interval', default=def_save_interval, type=int)
    p.add_argument('--project_folder', default=def_project_folder, type=str)
    p.add_argument('--dataset_folder', default=def_dataset_folder, type=str)
    args = p.parse_args()
    return args 
开发者ID:emrahbasaran,项目名称:SPReID,代码行数:63,代码来源:main.py


注:本文中的chainer.optimizer方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。