Ejemplo n.º 1
0
        '-e',
        '--env_name',
        type=str,
        help=
        'Name of the environment. Can be either a any gym environment or a custom one defined in rl.environments'
    )
    parser.add_argument(
        '-s',
        '--subdir',
        type=str,
        help=
        'Subdirectory where the model is stored: e.g. -> ../trained_models/env_type/env/[SUBDIR]/model_num/*'
    )
    parser.add_argument(
        '-n',
        '--num',
        type=int,
        help=
        'Unique identifier of the model, e.g. -> ../trained_models/env_type/env/subdir/[NUM]_/*'
    )
    parser.add_argument('-t',
                        '--tensorboard',
                        action='store_true',
                        help='Launch tensorboard in the current subdirectory.')
    args = parser.parse_args()

    model = Trainer(args.env_name, args.subdir).load_model(args.num)
    if args.tensorboard:
        model._tensorboard()
    model.train()
Ejemplo n.º 2
0
    parser.add_argument('-c', '--config', type=str, default=None, help='Adusted configuration file located in config/custom folder')
    parser.print_help()
    args = parser.parse_args()
    path = pathlib.Path().absolute()

    trainer = Trainer(args.environment, args.subdir)

    if args.config is not None:
        try:
            config_path = join(path, 'rl', 'config', 'custom', '{}.yml'.format(args.config))
            with open(config_path) as f:
                config = yaml.safe_load(f)
            print('\nLoaded config file from: {}\n'.format(config_path))

        except:
            print('specified config is not in path, getting original config: {}.yml...'.format(args.environment))
            # load config and variables needed
            config = get_parameters(args.environment)
    else:
        config = get_parameters(args.environment)

    if args.model is not None:
        config['main']['model'] = args.model
    trainer.create_model(name=args.name, config_file=config)
    trainer._tensorboard()
    t0 = time.time()
    trainer.train()
    ts = time.time()
    print('Running time for training: {} minutes.'.format((ts-t0)/60))
    #trainer.run(1000)
    trainer._save()