Python chainer.optimizer() Examples
The following are 4
code examples of chainer.optimizer().
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example.
You may also want to check out all available functions/classes of the module
chainer
, or try the search function
.
Example #1
Source File: config_utils.py From voxelnet_chainer with MIT License | 5 votes |
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)
Example #2
Source File: config_utils.py From voxelnet_chainer with MIT License | 5 votes |
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
Example #3
Source File: main.py From SPReID with MIT License | 5 votes |
def SetupOptimizer(model): opt = optimizers.NesterovAG( lr=args.optimizer['lr'], momentum=0.9) opt.setup(model) return opt
Example #4
Source File: main.py From SPReID with MIT License | 4 votes |
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