return 2**-6
        elif 2000 <= x < 4000:
            return 2**-6
        elif 4000 <= x < 6000:
            return 2**-8
        elif 6000 <= x < 8000:
            return 2**-8
        elif 8000 <= x:
            return 2**-11

    update_step_size_method = 'schedule'
else:
    raise NotImplementedError

# Set up the data, parameters, model, optimizer, and results objects
data = opt_structures.Data(train_loader, valid_loader, test_loader)
params = opt_structures.Params(num_classes=num_classes,
                               ckn=True,
                               train_w_layers=None,
                               lambda_filters=0,
                               normalize=True,
                               w_last_init=None,
                               update_step_size_method=update_step_size_method,
                               step_size_init=args.step_size,
                               step_size_schedule=step_size_schedule,
                               tau=args.hessian_reg,
                               num_iters=args.num_iters,
                               save_path=save_file + '_params.pickle',
                               eval_test_every=args.eval_test_every,
                               save_every=500)
model = opt_structures.Model(model, save_path=save_file + '_model.pickle')
示例#2
0
params = parse_config.load_config('../../cfg/ckn-gm.cfg')
if args.num_filters > 0:
    nlayers = len(params['num_filters'])
    params['num_filters'] = [args.num_filters] * nlayers
    params['patch_sigma'] = [bw] * nlayers

layers = parse_config.create_layers(params)
model = net.CKN(layers).to(defaults.device)
model.init(train_loader)
print('Done with initialization')

# Set up the data, parameters, model, results, and optimizer objects
if args.num_labeled > 0:
    data = opt_structures.Data(train_labeled_loader,
                               train_unlabeled_loader,
                               valid_loader,
                               train_valid_loader,
                               test_loader,
                               deepcluster_loader=train_loader)
else:
    data = opt_structures.Data(None,
                               train_unlabeled_loader,
                               None,
                               None,
                               test_loader,
                               deepcluster_loader=train_loader)
params = opt_structures.Params(
    nclasses=nclasses,
    min_frac_points_class=min_frac_points_class,
    max_frac_points_class=max_frac_points_class,
    ckn=ckn,
    project=True,