本文整理汇总了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)
示例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
示例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
示例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