Exemple #1
0
    data_provider = datasets.ImagenetDataProvider(
        save_path=args.data_path,
        train_batch_size=args.train_batch_size,
        test_batch_size=args.test_batch_size,
        valid_size=None,
        n_worker=args.n_worker,
        resize_scale=args.resize_scale,
        distort_color=args.distort_color)
    logger.info('Creating data provider done')

    if args.no_decay_keys:
        keys = args.no_decay_keys
        momentum, nesterov = 0.9, True
        optimizer = torch.optim.SGD([
            {
                'params': get_parameters(model, keys, mode='exclude'),
                'weight_decay': 4e-5
            },
            {
                'params': get_parameters(model, keys, mode='include'),
                'weight_decay': 0
            },
        ],
                                    lr=0.05,
                                    momentum=momentum,
                                    nesterov=nesterov)
    else:
        optimizer = torch.optim.SGD(get_parameters(model),
                                    lr=0.05,
                                    momentum=momentum,
                                    nesterov=nesterov,
Exemple #2
0
    logger.info('Creating data provider...')
    data_provider = datasets.ImagenetDataProvider(save_path=args.data_path,
                                                  train_batch_size=args.train_batch_size,
                                                  test_batch_size=args.test_batch_size,
                                                  valid_size=None,
                                                  n_worker=args.n_worker,
                                                  resize_scale=args.resize_scale,
                                                  distort_color=args.distort_color)
    logger.info('Creating data provider done')

    if args.no_decay_keys:
        keys = args.no_decay_keys
        momentum, nesterov = 0.9, True
        optimizer = torch.optim.SGD([
            {'params': get_parameters(model, keys, mode='exclude'), 'weight_decay': 4e-5},
            {'params': get_parameters(model, keys, mode='include'), 'weight_decay': 0},
        ], lr=0.05, momentum=momentum, nesterov=nesterov)
    else:
        optimizer = torch.optim.SGD(get_parameters(model), lr=0.05, momentum=momentum, nesterov=nesterov, weight_decay=4e-5)

    if args.train_mode == 'search':
        # this is architecture search
        logger.info('Creating ProxylessNasTrainer...')
        trainer = ProxylessNasTrainer(model,
                                      model_optim=optimizer,
                                      train_loader=data_provider.train,
                                      valid_loader=data_provider.valid,
                                      device=device,
                                      warmup=args.warmup,
                                      ckpt_path=args.checkpoint_path,