當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。