コード例 #1
0
def main(_):
    utility.set_up_logging()
    if not FLAGS.config:
        raise KeyError('You must specify a configuration.')
    if FLAGS.load_from:
        logdir = FLAGS.logdir = FLAGS.load_from
    else:
        if FLAGS.logdir and os.path.exists(FLAGS.logdir):
            run_number = [
                int(f.split("-")[0]) for f in os.listdir(FLAGS.logdir)
                if os.path.isdir(os.path.join(FLAGS.logdir, f))
                and FLAGS.config in f
            ]
            run_number = max(run_number) + 1 if len(run_number) > 0 else 0
        else:
            run_number = 0
        logdir = FLAGS.logdir and os.path.expanduser(
            os.path.join(FLAGS.logdir, '{}-{}'.format(run_number,
                                                      FLAGS.config)))
    try:
        config = utility.load_config(logdir)
    except IOError:
        config = tools.AttrDict(getattr(configs, FLAGS.config)())
        config = utility.save_config(config, logdir)
    train(config, logdir)
コード例 #2
0
def main(_):
    """Load a trained algorithm and render videos."""
    utility.set_up_logging()
    if not FLAGS.logdir or not FLAGS.outdir:
        raise KeyError('You must specify logging and outdirs directories.')
    FLAGS.logdir = os.path.expanduser(FLAGS.logdir)
    FLAGS.outdir = os.path.expanduser(FLAGS.outdir)
    visualize(FLAGS.logdir, FLAGS.outdir, FLAGS.num_agents, FLAGS.num_episodes,
              FLAGS.checkpoint, FLAGS.env_processes)
コード例 #3
0
def main(_):
    """Create or load configuration and launch the trainer."""
    utility.set_up_logging()
    if not FLAGS.config:
        raise KeyError('You must specify a configuration.')
    logdir = FLAGS.logdir and os.path.expanduser(
        os.path.join(FLAGS.logdir, '{}-{}'.format(FLAGS.timestamp,
                                                  FLAGS.config)))
    try:
        config = utility.load_config(logdir)
    except IOError:
        config = tools.AttrDict(getattr(configs, FLAGS.config)())
        config = utility.save_config(config, logdir)
    for score in train(config, FLAGS.env_processes):
        tf.logging.info('Score {}.'.format(score))