コード例 #1
0
ファイル: run_trpo.py プロジェクト: rlew631/ros2learn
from baselines.trpo_mpi import defaults
from baselines.common import set_global_seeds, tf_util as U
from baselines.common.input import observation_placeholder
from baselines.common.models import mlp
from baselines.common.policies import build_policy
from baselines.common.vec_env.dummy_vec_env import DummyVecEnv

U.get_session( config=tf.ConfigProto(
    allow_soft_placement = True,
    inter_op_parallelism_threads = 1,
    intra_op_parallelism_threads = 1) )

U.initialize()

# Get dictionary from baselines/trpo_mpi/defaults
defaults = defaults.mara_mlp()

# Create needed folders
try:
    logdir = defaults['trained_path'].split('checkpoints')[0] + 'results' + defaults['trained_path'].split('checkpoints')[1]
except:
    logdir = '/tmp/ros2learn/' + defaults['env_name'] + '/trpo_mpi_results/'
finally:
    logger.configure( os.path.abspath(logdir) )
    csvdir = logdir + "csv/"

csv_files = [csvdir + "det_obs.csv", csvdir + "det_acs.csv", csvdir + "det_rew.csv"]
if not os.path.exists(csvdir):
    os.makedirs(csvdir)
else:
    for f in csv_files:
コード例 #2
0
from baselines.common.models import mlp
from baselines.common.vec_env.dummy_vec_env import DummyVecEnv


def make_env():
    env = gym.make(alg_kwargs['env_name'])
    env.set_episode_size(alg_kwargs['timesteps_per_batch'])
    env = bench.Monitor(env,
                        logger.get_dir() and os.path.join(logger.get_dir()),
                        allow_early_resets=True)

    return env


# Get dictionary from baselines/trpo_mpi/defaults
alg_kwargs = defaults.mara_mlp()

# Create needed folders
timedate = datetime.now().strftime('%Y-%m-%d_%Hh%Mmin')
logdir = '/tmp/ros2learn/' + alg_kwargs['env_name'] + '/trpo_mpi/' + timedate

# Generate tensorboard file
format_strs = os.getenv('MARA_LOG_FORMAT',
                        'stdout,log,csv,tensorboard').split(',')
logger.configure(os.path.abspath(logdir), format_strs)

with open(logger.get_dir() + "/parameters.txt", 'w') as out:
    out.write('num_layers = ' + str(alg_kwargs['num_layers']) + '\n' +
              'num_hidden = ' + str(alg_kwargs['num_hidden']) + '\n' +
              'layer_norm = ' + str(alg_kwargs['layer_norm']) + '\n' +
              'timesteps_per_batch = ' +