Ejemplo n.º 1
0
def collect_initial_episodes(config):
    if config.source_train_dir:
        tools.copy_directory(config.source_train_dir, config.train_dir,
                             config.source_train_amount)
    if config.source_test_dir:
        tools.copy_directory(config.source_test_dir, config.test_dir,
                             config.source_test_amount)
    items = config.random_collects.items()
    items = sorted(items, key=lambda x: x[0])
    for name, params in items:
        message = 'Collecting {}+ random episodes ({}).'
        tf.logging.info(message.format(params.num_episodes, name))
        control.random_episodes(params.task.env_ctor, params.num_episodes,
                                params.save_episode_dir)
Ejemplo n.º 2
0
def collect_initial_episodes(config):
  items = config.random_collects.items()
  items = sorted(items, key=lambda x: x[0])
  existing = {}
  for name, params in items:
    outdir = params.save_episode_dir
    tf.gfile.MakeDirs(outdir)
    if outdir not in existing:
      existing[outdir] = len(tf.gfile.Glob(os.path.join(outdir, '*.npz')))
    if params.num_episodes <= existing[outdir]:
      existing[outdir] -= params.num_episodes
    else:
      remaining = params.num_episodes - existing[outdir]
      existing[outdir] = 0
      env_ctor = params.task.env_ctor
      print('Collecting {} initial episodes ({}).'.format(remaining, name))
      control.random_episodes(env_ctor, remaining, outdir)