コード例 #1
0
def main():
    args = parse_args()

    print('Called with args:')
    print(args)

    # Set main gpu
    # theano.sandbox.cuda.use(args.gpu_id)

    if args.cfg_files is not None:
        for cfg_file in args.cfg_files:
            cfg_from_file(cfg_file)
    if args.set_cfgs is not None:
        cfg_from_list(args.set_cfgs)
    if not args.randomize:
        np.random.seed(cfg.CONST.RNG_SEED)

    if args.batch_size is not None:
        cfg_from_list(['CONST.BATCH_SIZE', args.batch_size])
    if args.iter is not None:
        cfg_from_list(['TRAIN.NUM_ITERATION', args.iter])
    if args.save_freq is not None:
        cfg_from_list(['TRAIN.SAVE_FREQ', args.save_freq])
    if args.valid_freq is not None:
        cfg_from_list(['TRAIN.VALIDATION_FREQ', args.valid_freq])
    if args.nan_check_freq is not None:
        cfg_from_list(['TRAIN.NAN_CHECK_FREQ', args.nan_check_freq])
    if args.net_name is not None:
        cfg_from_list(['NET_NAME', args.net_name])
    if args.model_name is not None:
        cfg_from_list(['CONST.NETWORK_CLASS', args.model_name])
    if args.dataset is not None:
        cfg_from_list(['DATASET', args.dataset])
    if args.exp is not None:
        cfg_from_list(['TEST.EXP_NAME', args.exp])
    if args.out_path is not None:
        cfg_from_list(['DIR.OUT_PATH', args.out_path])
    if args.weights is not None:
        cfg_from_list([
            'CONST.WEIGHTS', args.weights, 'TRAIN.RESUME_TRAIN', True,
            'TRAIN.INITIAL_ITERATION',
            int(args.init_iter)
        ])

    print('Using config:')
    pprint.pprint(cfg)

    if not args.test:
        train_net()
    else:
        test_net()
コード例 #2
0
def main():
    args = parse_args()

    print('Called with args:')
    print(args)

    # Set main gpu
    #theano.sandbox.cuda.use(args.gpu_id)
    #theano.gpuarray.use(args.gpu_id)

    if args.cfg_files is not None:
        for cfg_file in args.cfg_files:
            cfg_from_file(cfg_file)
    if args.set_cfgs is not None:
        cfg_from_list(args.set_cfgs)
    if not args.randomize:
        np.random.seed(cfg.CONST.RNG_SEED)

    if args.batch_size is not None:
        cfg_from_list(['CONST.BATCH_SIZE', args.batch_size])
    if args.iter is not None:
        cfg_from_list(['TRAIN.NUM_ITERATION', args.iter])
    if args.net_name is not None:
        cfg_from_list(['NET_NAME', args.net_name])
    if args.model_name is not None:
        cfg_from_list(['CONST.NETWORK_CLASS', args.model_name])
    if args.dataset is not None:
        cfg_from_list(['DATASET', args.dataset])
    if args.exp is not None:
        cfg_from_list(['TEST.EXP_NAME', args.exp])
    if args.out_path is not None:
        cfg_from_list(['DIR.OUT_PATH', args.out_path])
    if args.tb_path is not None:
        cfg_from_list(['DIR.TB_PATH', args.tb_path])
    if args.dyna_dict is not None:
        cfg_from_list(['CONST.dynamic_dict', args.dyna_dict])
    if args.learn_rate is not None:
        cfg_from_list(['TRAIN.DEFAULT_LEARNING_RATE', args.learn_rate])
    if args.weights is not None:
        cfg_from_list(['CONST.WEIGHTS', args.weights, 'TRAIN.RESUME_TRAIN', True,
                       'TRAIN.INITIAL_ITERATION', int(args.init_iter)])

    print('Using config:')
    pprint.pprint(cfg)

    if not args.test:
        train_net()
    else:
        test_net()