parser.add_argument('--num_train_samples',
                        type=int,
                        default=50000,
                        metavar='M',
                        help='number of training samples (default: 3000)')
    parser.add_argument('--num_test_samples',
                        type=int,
                        default=10000,
                        metavar='M',
                        help='number of test samples (default: 1000)')

    parser.add_argument(
        '--train_log_step',
        type=int,
        default=100,
        metavar='M',
        help='Number of iterations after which to log the loss')

    global args, device
    args = parser.parse_args()
    args.cuda = args.cuda and torch.cuda.is_available()
    cfg_from_file("config/test.yaml")

    if args.cuda:
        device = 'cuda'
        if args.gpu_devices is None:
            args.gpu_devices = [0]
    else:
        device = 'cpu'
    main()
Exemplo n.º 2
0
    if len(sys.argv) == 1:
        parser.print_help()
        sys.exit(1)

    opts = parser.parse_args()
    return opts


if __name__ == '__main__':
    opts = parse_args()

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

    if opts.cfg_file is not None:
        cfg_from_file(opts.cfg_file)
    print_cfg()

    if opts.test_net is None:
        qdic_dir = cfg.QUERY_DIR  #osp.join(cfg.DATA_DIR, cfg.IMDB_NAME, 'query_dict')
        qdic = Dictionary(qdic_dir)
        qdic.load()
        vocab_size = qdic.size()
        test_model = models.net(opts.test_split, vocab_size, opts)
        test_net_path = osp.join(get_models_dir(), 'test.prototxt')
        with open(test_net_path, 'w') as f:
            f.write(str(test_model))
    else:
        test_net_path = opts.test_net

    caffe.set_mode_gpu()
Exemplo n.º 3
0
from solvers.ddqn_solver import DDQNSolver
from solvers.a2c_solver import A2CSolver
from solvers.async_solver import AsyncSolver


CUR = os.path.abspath(os.path.dirname(__file__))

###################################
# Name of cfg used for experiment #
###################################
cfg_name = 'a2c.yaml'

# Parse new config into default one
if cfg_name is not None:
    cfg_path = join(*[CUR, 'config', cfg_name])
    cfg_from_file(cfg_path)

# Instantiate the solver
if cfg.ASYNC.USE:
    solver = AsyncSolver(cfg)
else:
    if cfg.TYPE == 'dqn':
        solver = DQNSolver(cfg)
    elif cfg.TYPE == 'ddqn':
        solver = DDQNSolver(cfg)
    elif cfg.TYPE == 'a2c':
        solver = A2CSolver(cfg)
    else:
        raise NotImplementedError('TODO')

# Train