code stringlengths 66 870k | docstring stringlengths 19 26.7k | func_name stringlengths 1 138 | language stringclasses 1
value | repo stringlengths 7 68 | path stringlengths 5 324 | url stringlengths 46 389 | license stringclasses 7
values |
|---|---|---|---|---|---|---|---|
def te_ppo_mt1_push(ctxt, seed, n_epochs, batch_size_per_task):
"""Train Task Embedding PPO with PointEnv.
Args:
ctxt (ExperimentContext): The experiment configuration used by
:class:`~Trainer` to create the :class:`~Snapshotter`.
seed (int): Used to seed the random number generator... | Train Task Embedding PPO with PointEnv.
Args:
ctxt (ExperimentContext): The experiment configuration used by
:class:`~Trainer` to create the :class:`~Snapshotter`.
seed (int): Used to seed the random number generator to produce
determinism.
n_epochs (int): Total numb... | te_ppo_mt1_push | python | rlworkgroup/garage | src/garage/examples/tf/te_ppo_metaworld_mt1_push.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/tf/te_ppo_metaworld_mt1_push.py | MIT |
def te_ppo_mt50(ctxt, seed, n_epochs, batch_size_per_task, n_tasks):
"""Train Task Embedding PPO with PointEnv.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number genera... | Train Task Embedding PPO with PointEnv.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
n_epochs (int): Total number... | te_ppo_mt50 | python | rlworkgroup/garage | src/garage/examples/tf/te_ppo_metaworld_mt50.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/tf/te_ppo_metaworld_mt50.py | MIT |
def circle(r, n):
"""Generate n points on a circle of radius r.
Args:
r (float): Radius of the circle.
n (int): Number of points to generate.
Yields:
tuple(float, float): Coordinate of a point.
"""
for t in np.arange(0, 2 * np.pi, 2 * np.pi / n):
yield r * np.sin(t... | Generate n points on a circle of radius r.
Args:
r (float): Radius of the circle.
n (int): Number of points to generate.
Yields:
tuple(float, float): Coordinate of a point.
| circle | python | rlworkgroup/garage | src/garage/examples/tf/te_ppo_point.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/tf/te_ppo_point.py | MIT |
def te_ppo_pointenv(ctxt, seed, n_epochs, batch_size_per_task):
"""Train Task Embedding PPO with PointEnv.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator t... | Train Task Embedding PPO with PointEnv.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
n_epochs (int): Total number... | te_ppo_pointenv | python | rlworkgroup/garage | src/garage/examples/tf/te_ppo_point.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/tf/te_ppo_point.py | MIT |
def trpo_cartpole(ctxt=None, seed=1):
"""Train TRPO with CartPole-v1 environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
det... | Train TRPO with CartPole-v1 environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
| trpo_cartpole | python | rlworkgroup/garage | src/garage/examples/tf/trpo_cartpole.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/tf/trpo_cartpole.py | MIT |
def trpo_cartpole_bullet(ctxt=None, seed=1):
"""Train TRPO with Pybullet's CartPoleBulletEnv environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to... | Train TRPO with Pybullet's CartPoleBulletEnv environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
| trpo_cartpole_bullet | python | rlworkgroup/garage | src/garage/examples/tf/trpo_cartpole_bullet.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/tf/trpo_cartpole_bullet.py | MIT |
def trpo_cartpole_recurrent(ctxt, seed, n_epochs, batch_size, plot):
"""Train TRPO with a recurrent policy on CartPole.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
n_epochs (int): Number of epochs for trai... | Train TRPO with a recurrent policy on CartPole.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
n_epochs (int): Number of epochs for training.
seed (int): Used to seed the random number generator to produc... | trpo_cartpole_recurrent | python | rlworkgroup/garage | src/garage/examples/tf/trpo_cartpole_recurrent.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/tf/trpo_cartpole_recurrent.py | MIT |
def trpo_cubecrash(ctxt=None, seed=1, max_episode_length=5, batch_size=4000):
"""Train TRPO with CubeCrash-v0 environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random nu... | Train TRPO with CubeCrash-v0 environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
max_episode_length (int): ... | trpo_cubecrash | python | rlworkgroup/garage | src/garage/examples/tf/trpo_cubecrash.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/tf/trpo_cubecrash.py | MIT |
def trpo_gym_tf_cartpole(ctxt=None, seed=1):
"""Train TRPO with CartPole-v0 environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
... | Train TRPO with CartPole-v0 environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
| trpo_gym_tf_cartpole | python | rlworkgroup/garage | src/garage/examples/tf/trpo_gym_tf_cartpole.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/tf/trpo_gym_tf_cartpole.py | MIT |
def trpo_gym_tf_cartpole(ctxt=None, seed=1):
"""Train TRPO with CartPole-v0 environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
... | Train TRPO with CartPole-v0 environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
| trpo_gym_tf_cartpole | python | rlworkgroup/garage | src/garage/examples/tf/trpo_gym_tf_cartpole_pretrained.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/tf/trpo_gym_tf_cartpole_pretrained.py | MIT |
def pre_trained_trpo_cartpole(
ctxt=None,
snapshot_dir='data/local/experiment/trpo_gym_tf_cartpole',
seed=1):
"""Use pre-trained TRPO and reusume experiment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the ... | Use pre-trained TRPO and reusume experiment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
snapshot_dir (path): directory to snapshot
seed (int): Used to seed the random number generator to produce
... | pre_trained_trpo_cartpole | python | rlworkgroup/garage | src/garage/examples/tf/trpo_gym_tf_cartpole_pretrained.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/tf/trpo_gym_tf_cartpole_pretrained.py | MIT |
def trpo_swimmer(ctxt=None, seed=1, batch_size=4000):
"""Train TRPO with Swimmer-v2 environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
... | Train TRPO with Swimmer-v2 environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
batch_size (int): Number of ... | trpo_swimmer | python | rlworkgroup/garage | src/garage/examples/tf/trpo_swimmer.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/tf/trpo_swimmer.py | MIT |
def trpo_swimmer_ray_sampler(ctxt=None, seed=1):
"""tf_trpo_swimmer.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
... | tf_trpo_swimmer.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
| trpo_swimmer_ray_sampler | python | rlworkgroup/garage | src/garage/examples/tf/trpo_swimmer_ray_sampler.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/tf/trpo_swimmer_ray_sampler.py | MIT |
def init_opt(self):
"""Initialize optimizer and build computation graph."""
observation_dim = self.policy.observation_space.flat_dim
action_dim = self.policy.action_space.flat_dim
with tf.name_scope('inputs'):
self._observation = tf.compat.v1.placeholder(
tf.f... | Initialize optimizer and build computation graph. | init_opt | python | rlworkgroup/garage | src/garage/examples/tf/tutorial_vpg.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/tf/tutorial_vpg.py | MIT |
def train(self, trainer):
"""Obtain samplers and start actual training for each epoch.
Args:
trainer (Trainer): Experiment trainer.
"""
for epoch in trainer.step_epochs():
samples = trainer.obtain_samples(epoch)
log_performance(epoch,
... | Obtain samplers and start actual training for each epoch.
Args:
trainer (Trainer): Experiment trainer.
| train | python | rlworkgroup/garage | src/garage/examples/tf/tutorial_vpg.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/tf/tutorial_vpg.py | MIT |
def _train_once(self, samples):
"""Perform one step of policy optimization given one batch of samples.
Args:
samples (list[dict]): A list of collected samples.
Returns:
numpy.float64: Average return.
"""
obs = np.concatenate([path['observations'] for pa... | Perform one step of policy optimization given one batch of samples.
Args:
samples (list[dict]): A list of collected samples.
Returns:
numpy.float64: Average return.
| _train_once | python | rlworkgroup/garage | src/garage/examples/tf/tutorial_vpg.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/tf/tutorial_vpg.py | MIT |
def __getstate__(self):
"""Parameters to save in snapshot.
Returns:
dict: Parameters to save.
"""
data = self.__dict__.copy()
del data['_observation']
del data['_action']
del data['_returns']
del data['_train_op']
return data | Parameters to save in snapshot.
Returns:
dict: Parameters to save.
| __getstate__ | python | rlworkgroup/garage | src/garage/examples/tf/tutorial_vpg.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/tf/tutorial_vpg.py | MIT |
def tutorial_vpg(ctxt=None):
"""Train VPG with PointEnv environment.
Args:
ctxt (ExperimentContext): The experiment configuration used by
:class:`~Trainer` to create the :class:`~Snapshotter`.
"""
set_seed(100)
with TFTrainer(ctxt) as trainer:
env = PointEnv(max_episode... | Train VPG with PointEnv environment.
Args:
ctxt (ExperimentContext): The experiment configuration used by
:class:`~Trainer` to create the :class:`~Snapshotter`.
| tutorial_vpg | python | rlworkgroup/garage | src/garage/examples/tf/tutorial_vpg.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/tf/tutorial_vpg.py | MIT |
def vpg_cartpole(ctxt=None, seed=1):
"""Train VPG with CartPole-v1 environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
deter... | Train VPG with CartPole-v1 environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
| vpg_cartpole | python | rlworkgroup/garage | src/garage/examples/tf/vpg_cartpole.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/tf/vpg_cartpole.py | MIT |
def get_actions(self, observations):
"""Get actions given observations.
Args:
observations (np.ndarray): Observations from the environment.
Has shape :math:`(B, O)`, where :math:`B` is the batch
dimension and :math:`O` is the observation dimensionality (at
... | Get actions given observations.
Args:
observations (np.ndarray): Observations from the environment.
Has shape :math:`(B, O)`, where :math:`B` is the batch
dimension and :math:`O` is the observation dimensionality (at
least 2).
Returns:
... | get_actions | python | rlworkgroup/garage | src/garage/examples/torch/bc_point.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/bc_point.py | MIT |
def bc_point(ctxt=None, loss='log_prob'):
"""Run Behavioral Cloning on garage.envs.PointEnv.
Args:
ctxt (ExperimentContext): Provided by wrap_experiment.
loss (str): Either 'log_prob' or 'mse'
"""
trainer = Trainer(ctxt)
goal = np.array([1., 1.])
env = PointEnv(goal=goal, max_e... | Run Behavioral Cloning on garage.envs.PointEnv.
Args:
ctxt (ExperimentContext): Provided by wrap_experiment.
loss (str): Either 'log_prob' or 'mse'
| bc_point | python | rlworkgroup/garage | src/garage/examples/torch/bc_point.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/bc_point.py | MIT |
def get_actions(self, observations):
"""Get actions given observations.
Args:
observations (np.ndarray): Observations from the environment.
Has shape :math:`(B, O)`, where :math:`B` is the batch
dimension and :math:`O` is the observation dimensionality (at
... | Get actions given observations.
Args:
observations (np.ndarray): Observations from the environment.
Has shape :math:`(B, O)`, where :math:`B` is the batch
dimension and :math:`O` is the observation dimensionality (at
least 2).
Returns:
... | get_actions | python | rlworkgroup/garage | src/garage/examples/torch/bc_point_deterministic_policy.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/bc_point_deterministic_policy.py | MIT |
def bc_point(ctxt=None):
"""Run Behavioral Cloning on garage.envs.PointEnv.
Args:
ctxt (ExperimentContext): Provided by wrap_experiment.
"""
trainer = Trainer(ctxt)
goal = np.array([1., 1.])
env = PointEnv(goal=goal, max_episode_length=200)
expert = OptimalPolicy(env.spec, goal=goa... | Run Behavioral Cloning on garage.envs.PointEnv.
Args:
ctxt (ExperimentContext): Provided by wrap_experiment.
| bc_point | python | rlworkgroup/garage | src/garage/examples/torch/bc_point_deterministic_policy.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/bc_point_deterministic_policy.py | MIT |
def ddpg_pendulum(ctxt=None, seed=1, lr=1e-4):
"""Train DDPG with InvertedDoublePendulum-v2 environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to ... | Train DDPG with InvertedDoublePendulum-v2 environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
lr (float): L... | ddpg_pendulum | python | rlworkgroup/garage | src/garage/examples/torch/ddpg_pendulum.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/ddpg_pendulum.py | MIT |
def dqn_cartpole(ctxt=None, seed=24):
"""Train DQN with CartPole-v0 environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by LocalRunner to create the snapshotter.
seed (int): Used to seed the random number generator to produce
... | Train DQN with CartPole-v0 environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by LocalRunner to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
| dqn_cartpole | python | rlworkgroup/garage | src/garage/examples/torch/dqn_cartpole.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/dqn_cartpole.py | MIT |
def maml_ppo_half_cheetah_dir(ctxt, seed, epochs, episodes_per_task,
meta_batch_size):
"""Set up environment and algorithm and run the task.
Args:
ctxt (ExperimentContext): The experiment configuration used by
:class:`~Trainer` to create the :class:`~Snapshotte... | Set up environment and algorithm and run the task.
Args:
ctxt (ExperimentContext): The experiment configuration used by
:class:`~Trainer` to create the :class:`~Snapshotter`.
seed (int): Used to seed the random number generator to produce
determinism.
epochs (int): N... | maml_ppo_half_cheetah_dir | python | rlworkgroup/garage | src/garage/examples/torch/maml_ppo_half_cheetah_dir.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/maml_ppo_half_cheetah_dir.py | MIT |
def maml_trpo_half_cheetah_dir(ctxt, seed, epochs, episodes_per_task,
meta_batch_size):
"""Set up environment and algorithm and run the task.
Args:
ctxt (ExperimentContext): The experiment configuration used by
:class:`~Trainer` to create the :class:`~Snapshot... | Set up environment and algorithm and run the task.
Args:
ctxt (ExperimentContext): The experiment configuration used by
:class:`~Trainer` to create the :class:`~Snapshotter`.
seed (int): Used to seed the random number generator to produce
determinism.
epochs (int): N... | maml_trpo_half_cheetah_dir | python | rlworkgroup/garage | src/garage/examples/torch/maml_trpo_half_cheetah_dir.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/maml_trpo_half_cheetah_dir.py | MIT |
def maml_trpo_metaworld_ml10(ctxt, seed, epochs, episodes_per_task,
meta_batch_size):
"""Set up environment and algorithm and run the task.
Args:
ctxt (ExperimentContext): The experiment configuration used by
:class:`~Trainer: to create the :class:`~Snapshotter:... | Set up environment and algorithm and run the task.
Args:
ctxt (ExperimentContext): The experiment configuration used by
:class:`~Trainer: to create the :class:`~Snapshotter:.
seed (int): Used to seed the random number generator to produce
determinism.
epochs (int): N... | maml_trpo_metaworld_ml10 | python | rlworkgroup/garage | src/garage/examples/torch/maml_trpo_metaworld_ml10.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/maml_trpo_metaworld_ml10.py | MIT |
def maml_trpo_metaworld_ml1_push(ctxt, seed, epochs, rollouts_per_task,
meta_batch_size):
"""Set up environment and algorithm and run the task.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snaps... | Set up environment and algorithm and run the task.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
epochs (int): Num... | maml_trpo_metaworld_ml1_push | python | rlworkgroup/garage | src/garage/examples/torch/maml_trpo_metaworld_ml1_push.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/maml_trpo_metaworld_ml1_push.py | MIT |
def maml_trpo_metaworld_ml45(ctxt, seed, epochs, episodes_per_task,
meta_batch_size):
"""Set up environment and algorithm and run the task.
Args:
ctxt (ExperimentContext): The experiment configuration used by
:class:`~Trainer` to create the :class:`~Snapshotter`... | Set up environment and algorithm and run the task.
Args:
ctxt (ExperimentContext): The experiment configuration used by
:class:`~Trainer` to create the :class:`~Snapshotter`.
seed (int): Used to seed the random number generator to produce
determinism.
epochs (int): N... | maml_trpo_metaworld_ml45 | python | rlworkgroup/garage | src/garage/examples/torch/maml_trpo_metaworld_ml45.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/maml_trpo_metaworld_ml45.py | MIT |
def maml_vpg_half_cheetah_dir(ctxt, seed, epochs, episodes_per_task,
meta_batch_size):
"""Set up environment and algorithm and run the task.
Args:
ctxt (ExperimentContext): The experiment configuration used by
:class:`~Trainer` to create the :class:`~Snapshotte... | Set up environment and algorithm and run the task.
Args:
ctxt (ExperimentContext): The experiment configuration used by
:class:`~Trainer` to create the :class:`~Snapshotter`.
seed (int): Used to seed the random number generator to produce
determinism.
epochs (int): N... | maml_vpg_half_cheetah_dir | python | rlworkgroup/garage | src/garage/examples/torch/maml_vpg_half_cheetah_dir.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/maml_vpg_half_cheetah_dir.py | MIT |
def mtppo_metaworld_mt10(ctxt, seed, epochs, batch_size, n_workers, n_tasks):
"""Set up environment and algorithm and run the task.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the ... | Set up environment and algorithm and run the task.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
epochs (int): Num... | mtppo_metaworld_mt10 | python | rlworkgroup/garage | src/garage/examples/torch/mtppo_metaworld_mt10.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/mtppo_metaworld_mt10.py | MIT |
def mtppo_metaworld_mt1_push(ctxt, seed, epochs, batch_size):
"""Set up environment and algorithm and run the task.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number ge... | Set up environment and algorithm and run the task.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
epochs (int): Num... | mtppo_metaworld_mt1_push | python | rlworkgroup/garage | src/garage/examples/torch/mtppo_metaworld_mt1_push.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/mtppo_metaworld_mt1_push.py | MIT |
def mtppo_metaworld_mt50(ctxt, seed, epochs, batch_size, n_workers, n_tasks):
"""Set up environment and algorithm and run the task.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the ... | Set up environment and algorithm and run the task.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
epochs (int): Num... | mtppo_metaworld_mt50 | python | rlworkgroup/garage | src/garage/examples/torch/mtppo_metaworld_mt50.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/mtppo_metaworld_mt50.py | MIT |
def mtsac_metaworld_mt10(ctxt=None, *, seed, _gpu, n_tasks, timesteps):
"""Train MTSAC with MT10 environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generato... | Train MTSAC with MT10 environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
_gpu (int): The ID of the gpu to ... | mtsac_metaworld_mt10 | python | rlworkgroup/garage | src/garage/examples/torch/mtsac_metaworld_mt10.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/mtsac_metaworld_mt10.py | MIT |
def mtsac_metaworld_mt1_pick_place(ctxt=None, *, seed, timesteps, _gpu):
"""Train MTSAC with the MT1 pick-place-v1 environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the rand... | Train MTSAC with the MT1 pick-place-v1 environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
_gpu (int): The ... | mtsac_metaworld_mt1_pick_place | python | rlworkgroup/garage | src/garage/examples/torch/mtsac_metaworld_mt1_pick_place.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/mtsac_metaworld_mt1_pick_place.py | MIT |
def mtsac_metaworld_mt50(ctxt=None,
*,
seed,
use_gpu,
_gpu,
n_tasks,
timesteps):
"""Train MTSAC with MT50 environment.
Args:
ctxt (garage.experiment.Expe... | Train MTSAC with MT50 environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
use_gpu (bool): Used to enable us... | mtsac_metaworld_mt50 | python | rlworkgroup/garage | src/garage/examples/torch/mtsac_metaworld_mt50.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/mtsac_metaworld_mt50.py | MIT |
def mttrpo_metaworld_mt10(ctxt, seed, epochs, batch_size, n_workers, n_tasks):
"""Set up environment and algorithm and run the task.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the... | Set up environment and algorithm and run the task.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
epochs (int): Num... | mttrpo_metaworld_mt10 | python | rlworkgroup/garage | src/garage/examples/torch/mttrpo_metaworld_mt10.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/mttrpo_metaworld_mt10.py | MIT |
def mttrpo_metaworld_mt1_push(ctxt, seed, epochs, batch_size):
"""Set up environment and algorithm and run the task.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number g... | Set up environment and algorithm and run the task.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
epochs (int): Num... | mttrpo_metaworld_mt1_push | python | rlworkgroup/garage | src/garage/examples/torch/mttrpo_metaworld_mt1_push.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/mttrpo_metaworld_mt1_push.py | MIT |
def mttrpo_metaworld_mt50(ctxt, seed, epochs, batch_size, n_workers, n_tasks):
"""Set up environment and algorithm and run the task.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the... | Set up environment and algorithm and run the task.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
epochs (int): Num... | mttrpo_metaworld_mt50 | python | rlworkgroup/garage | src/garage/examples/torch/mttrpo_metaworld_mt50.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/mttrpo_metaworld_mt50.py | MIT |
def pearl_half_cheetah_vel(ctxt=None,
seed=1,
num_epochs=500,
num_train_tasks=100,
num_test_tasks=100,
latent_size=5,
encoder_hidden_size=200,
... | Train PEARL with HalfCheetahVel environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
num_epochs (int): Numbe... | pearl_half_cheetah_vel | python | rlworkgroup/garage | src/garage/examples/torch/pearl_half_cheetah_vel.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/pearl_half_cheetah_vel.py | MIT |
def pearl_metaworld_ml10(ctxt=None,
seed=1,
num_epochs=1000,
num_train_tasks=10,
latent_size=7,
encoder_hidden_size=200,
net_size=300,
meta_batch... | Train PEARL with ML10 environments.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
num_epochs (int): Number of trai... | pearl_metaworld_ml10 | python | rlworkgroup/garage | src/garage/examples/torch/pearl_metaworld_ml10.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/pearl_metaworld_ml10.py | MIT |
def pearl_metaworld_ml1_push(ctxt=None,
seed=1,
num_epochs=1000,
num_train_tasks=50,
latent_size=7,
encoder_hidden_size=200,
net_size=300,
... | Train PEARL with ML1 environments.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
num_epochs (int): Number of train... | pearl_metaworld_ml1_push | python | rlworkgroup/garage | src/garage/examples/torch/pearl_metaworld_ml1_push.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/pearl_metaworld_ml1_push.py | MIT |
def pearl_metaworld_ml45(ctxt=None,
seed=1,
num_epochs=1000,
num_train_tasks=45,
latent_size=7,
encoder_hidden_size=200,
net_size=300,
meta_batch... | Train PEARL with ML45 environments.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
num_epochs (int): Number of trai... | pearl_metaworld_ml45 | python | rlworkgroup/garage | src/garage/examples/torch/pearl_metaworld_ml45.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/pearl_metaworld_ml45.py | MIT |
def ppo_pendulum(ctxt=None, seed=1):
"""Train PPO with InvertedDoublePendulum-v2 environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
... | Train PPO with InvertedDoublePendulum-v2 environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
| ppo_pendulum | python | rlworkgroup/garage | src/garage/examples/torch/ppo_pendulum.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/ppo_pendulum.py | MIT |
def sac_half_cheetah_batch(ctxt=None, seed=1):
"""Set up environment and algorithm and run the task.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to prod... | Set up environment and algorithm and run the task.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
| sac_half_cheetah_batch | python | rlworkgroup/garage | src/garage/examples/torch/sac_half_cheetah_batch.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/sac_half_cheetah_batch.py | MIT |
def td3_half_cheetah(ctxt=None, seed=1):
"""Train TD3 with InvertedDoublePendulum-v2 environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by LocalRunner to create the snapshotter.
seed (int): Used to seed the random number generator to pro... | Train TD3 with InvertedDoublePendulum-v2 environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by LocalRunner to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
| td3_half_cheetah | python | rlworkgroup/garage | src/garage/examples/torch/td3_halfcheetah.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/td3_halfcheetah.py | MIT |
def td3_pendulum(ctxt=None, seed=1):
"""Train TD3 with InvertedDoublePendulum-v2 environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by LocalRunner to create the snapshotter.
seed (int): Used to seed the random number generator to produce... | Train TD3 with InvertedDoublePendulum-v2 environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by LocalRunner to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
| td3_pendulum | python | rlworkgroup/garage | src/garage/examples/torch/td3_pendulum.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/td3_pendulum.py | MIT |
def trpo_pendulum(ctxt=None, seed=1):
"""Train TRPO with InvertedDoublePendulum-v2 environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
... | Train TRPO with InvertedDoublePendulum-v2 environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
| trpo_pendulum | python | rlworkgroup/garage | src/garage/examples/torch/trpo_pendulum.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/trpo_pendulum.py | MIT |
def trpo_pendulum_ray_sampler(ctxt=None, seed=1):
"""Set up environment and algorithm and run the task.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to p... | Set up environment and algorithm and run the task.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
| trpo_pendulum_ray_sampler | python | rlworkgroup/garage | src/garage/examples/torch/trpo_pendulum_ray_sampler.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/trpo_pendulum_ray_sampler.py | MIT |
def train(self, trainer):
"""Obtain samplers and start actual training for each epoch.
Args:
trainer (Trainer): Experiment trainer.
"""
for epoch in trainer.step_epochs():
samples = trainer.obtain_samples(epoch)
log_performance(epoch,
... | Obtain samplers and start actual training for each epoch.
Args:
trainer (Trainer): Experiment trainer.
| train | python | rlworkgroup/garage | src/garage/examples/torch/tutorial_vpg.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/tutorial_vpg.py | MIT |
def _train_once(self, samples):
"""Perform one step of policy optimization given one batch of samples.
Args:
samples (list[dict]): A list of collected paths.
Returns:
numpy.float64: Average return.
"""
losses = []
self._policy_opt.zero_grad()
... | Perform one step of policy optimization given one batch of samples.
Args:
samples (list[dict]): A list of collected paths.
Returns:
numpy.float64: Average return.
| _train_once | python | rlworkgroup/garage | src/garage/examples/torch/tutorial_vpg.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/tutorial_vpg.py | MIT |
def tutorial_vpg(ctxt=None):
"""Train VPG with PointEnv environment.
Args:
ctxt (ExperimentContext): The experiment configuration used by
:class:`~Trainer` to create the :class:`~Snapshotter`.
"""
set_seed(100)
trainer = Trainer(ctxt)
env = PointEnv()
policy = GaussianM... | Train VPG with PointEnv environment.
Args:
ctxt (ExperimentContext): The experiment configuration used by
:class:`~Trainer` to create the :class:`~Snapshotter`.
| tutorial_vpg | python | rlworkgroup/garage | src/garage/examples/torch/tutorial_vpg.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/tutorial_vpg.py | MIT |
def vpg_pendulum(ctxt=None, seed=1):
"""Train PPO with InvertedDoublePendulum-v2 environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
... | Train PPO with InvertedDoublePendulum-v2 environment.
Args:
ctxt (garage.experiment.ExperimentContext): The experiment
configuration used by Trainer to create the snapshotter.
seed (int): Used to seed the random number generator to produce
determinism.
| vpg_pendulum | python | rlworkgroup/garage | src/garage/examples/torch/vpg_pendulum.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/vpg_pendulum.py | MIT |
def watch_atari(saved_dir, env=None, num_episodes=10):
"""Watch a trained agent play an atari game.
Args:
saved_dir (str): Directory containing the pickle file.
env (str): Environment to run episodes on. If None, the pickled
environment is used.
num_episodes (int): Number of... | Watch a trained agent play an atari game.
Args:
saved_dir (str): Directory containing the pickle file.
env (str): Environment to run episodes on. If None, the pickled
environment is used.
num_episodes (int): Number of episodes to play. Note that when using
the Episod... | watch_atari | python | rlworkgroup/garage | src/garage/examples/torch/watch_atari.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/examples/torch/watch_atari.py | MIT |
def set_seed(seed):
"""Set the process-wide random seed.
Args:
seed (int): A positive integer
"""
seed %= 4294967294
# pylint: disable=global-statement
global seed_
global seed_stream_
seed_ = seed
random.seed(seed)
np.random.seed(seed)
if 'tensorflow' in sys.module... | Set the process-wide random seed.
Args:
seed (int): A positive integer
| set_seed | python | rlworkgroup/garage | src/garage/experiment/deterministic.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/experiment/deterministic.py | MIT |
def get_tf_seed_stream():
"""Get the pseudo-random number generator (PRNG) for TensorFlow ops.
Returns:
int: A seed generated by a PRNG with fixed global seed.
"""
if seed_stream_ is None:
set_seed(0)
return seed_stream_() % 4294967294 | Get the pseudo-random number generator (PRNG) for TensorFlow ops.
Returns:
int: A seed generated by a PRNG with fixed global seed.
| get_tf_seed_stream | python | rlworkgroup/garage | src/garage/experiment/deterministic.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/experiment/deterministic.py | MIT |
def _make_sequential_log_dir(log_dir):
"""Creates log_dir, appending a number if necessary.
Attempts to create the directory `log_dir`. If it already exists, appends
"_1". If that already exists, appends "_2" instead, etc.
Args:
log_dir (str): The log directory to attempt to create.
Retur... | Creates log_dir, appending a number if necessary.
Attempts to create the directory `log_dir`. If it already exists, appends
"_1". If that already exists, appends "_2" instead, etc.
Args:
log_dir (str): The log directory to attempt to create.
Returns:
str: The log directory actually cr... | _make_sequential_log_dir | python | rlworkgroup/garage | src/garage/experiment/experiment.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/experiment/experiment.py | MIT |
def _make_experiment_signature(function):
"""Generate an ExperimentTemplate's signature from its function.
Checks that the first parameter is named ctxt and removes it from the
signature. Makes all other parameters keyword only.
Args:
function (callable[ExperimentContext, ...]): The wrapped fu... | Generate an ExperimentTemplate's signature from its function.
Checks that the first parameter is named ctxt and removes it from the
signature. Makes all other parameters keyword only.
Args:
function (callable[ExperimentContext, ...]): The wrapped function.
Returns:
inspect.Signature: ... | _make_experiment_signature | python | rlworkgroup/garage | src/garage/experiment/experiment.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/experiment/experiment.py | MIT |
def _update_wrap_params(self):
"""Update self to "look like" the wrapped funciton.
Mostly, this involves creating a function signature for the
ExperimentTemplate that looks like the wrapped function, but with the
first argument (ctxt) excluded, and all other arguments required to be
... | Update self to "look like" the wrapped funciton.
Mostly, this involves creating a function signature for the
ExperimentTemplate that looks like the wrapped function, but with the
first argument (ctxt) excluded, and all other arguments required to be
keyword only.
| _update_wrap_params | python | rlworkgroup/garage | src/garage/experiment/experiment.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/experiment/experiment.py | MIT |
def _augment_name(cls, options, name, params):
"""Augment the experiment name with parameters.
Args:
options (dict): Options to `wrap_experiment` itself. See the
function documentation for details.
name (str): Name without parameter names.
params (dic... | Augment the experiment name with parameters.
Args:
options (dict): Options to `wrap_experiment` itself. See the
function documentation for details.
name (str): Name without parameter names.
params (dict): Dictionary of parameters.
Raises:
... | _augment_name | python | rlworkgroup/garage | src/garage/experiment/experiment.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/experiment/experiment.py | MIT |
def _get_options(self, *args):
"""Get the options for wrap_experiment.
This method combines options passed to `wrap_experiment` itself and to
the wrapped experiment.
Args:
args (list[dict]): Unnamed arguments to the wrapped experiment. May
be an empty list o... | Get the options for wrap_experiment.
This method combines options passed to `wrap_experiment` itself and to
the wrapped experiment.
Args:
args (list[dict]): Unnamed arguments to the wrapped experiment. May
be an empty list or a list containing a single dictionary.
... | _get_options | python | rlworkgroup/garage | src/garage/experiment/experiment.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/experiment/experiment.py | MIT |
def _make_context(cls, options, **kwargs):
"""Make a context from the template information and variant args.
Currently, all arguments should be keyword arguments.
Args:
options (dict): Options to `wrap_experiment` itself. See the
function documentation for details.
... | Make a context from the template information and variant args.
Currently, all arguments should be keyword arguments.
Args:
options (dict): Options to `wrap_experiment` itself. See the
function documentation for details.
kwargs (dict): Keyword arguments for the w... | _make_context | python | rlworkgroup/garage | src/garage/experiment/experiment.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/experiment/experiment.py | MIT |
def __call__(self, *args, **kwargs):
"""Wrap a function to turn it into an ExperimentTemplate.
Note that this docstring will be overriden to match the function's
docstring on the ExperimentTemplate once a function is passed in.
Args:
args (list): If no function has been set... | Wrap a function to turn it into an ExperimentTemplate.
Note that this docstring will be overriden to match the function's
docstring on the ExperimentTemplate once a function is passed in.
Args:
args (list): If no function has been set yet, must be a list
containing ... | __call__ | python | rlworkgroup/garage | src/garage/experiment/experiment.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/experiment/experiment.py | MIT |
def dump_json(filename, data):
"""Dump a dictionary to a file in JSON format.
Args:
filename(str): Filename for the file.
data(dict): Data to save to file.
"""
pathlib.Path(os.path.dirname(filename)).mkdir(parents=True, exist_ok=True)
with open(filename, 'w') as f:
# We do ... | Dump a dictionary to a file in JSON format.
Args:
filename(str): Filename for the file.
data(dict): Data to save to file.
| dump_json | python | rlworkgroup/garage | src/garage/experiment/experiment.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/experiment/experiment.py | MIT |
def make_launcher_archive(*, git_root_path, log_dir):
"""Saves an archive of the launcher's git repo to the log directory.
Args:
git_root_path (str): Absolute path to git repo to archive.
log_dir (str): Absolute path to the log directory.
"""
git_files = subprocess.check_output(
... | Saves an archive of the launcher's git repo to the log directory.
Args:
git_root_path (str): Absolute path to git repo to archive.
log_dir (str): Absolute path to the log directory.
| make_launcher_archive | python | rlworkgroup/garage | src/garage/experiment/experiment.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/experiment/experiment.py | MIT |
def default(self, o):
"""Perform JSON encoding.
Args:
o (object): Object to encode.
Raises:
TypeError: If `o` cannot be turned into JSON even using `repr(o)`.
Returns:
dict or str or float or bool: Object encoded in JSON.
"""
# Why ... | Perform JSON encoding.
Args:
o (object): Object to encode.
Raises:
TypeError: If `o` cannot be turned into JSON even using `repr(o)`.
Returns:
dict or str or float or bool: Object encoded in JSON.
| default | python | rlworkgroup/garage | src/garage/experiment/experiment.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/experiment/experiment.py | MIT |
def _default_inner(self, o):
"""Perform JSON encoding.
Args:
o (object): Object to encode.
Raises:
TypeError: If `o` cannot be turned into JSON even using `repr(o)`.
ValueError: If raised by calling repr on an object.
Returns:
dict or st... | Perform JSON encoding.
Args:
o (object): Object to encode.
Raises:
TypeError: If `o` cannot be turned into JSON even using `repr(o)`.
ValueError: If raised by calling repr on an object.
Returns:
dict or str or float or bool: Object encoded in JS... | _default_inner | python | rlworkgroup/garage | src/garage/experiment/experiment.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/experiment/experiment.py | MIT |
def evaluate(self, algo, test_episodes_per_task=None):
"""Evaluate the Meta-RL algorithm on the test tasks.
Args:
algo (MetaRLAlgorithm): The algorithm to evaluate.
test_episodes_per_task (int or None): Number of episodes per task.
"""
if test_episodes_per_task ... | Evaluate the Meta-RL algorithm on the test tasks.
Args:
algo (MetaRLAlgorithm): The algorithm to evaluate.
test_episodes_per_task (int or None): Number of episodes per task.
| evaluate | python | rlworkgroup/garage | src/garage/experiment/meta_evaluator.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/experiment/meta_evaluator.py | MIT |
def save_itr_params(self, itr, params):
"""Save the parameters if at the right iteration.
Args:
itr (int): Number of iterations. Used as the index of snapshot.
params (obj): Content of snapshot to be saved.
Raises:
ValueError: If snapshot_mode is not one of ... | Save the parameters if at the right iteration.
Args:
itr (int): Number of iterations. Used as the index of snapshot.
params (obj): Content of snapshot to be saved.
Raises:
ValueError: If snapshot_mode is not one of "all", "last", "gap",
"gap_overwrit... | save_itr_params | python | rlworkgroup/garage | src/garage/experiment/snapshotter.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/experiment/snapshotter.py | MIT |
def load(self, load_dir, itr='last'):
# pylint: disable=no-self-use
"""Load one snapshot of parameters from disk.
Args:
load_dir (str): Directory of the cloudpickle file
to resume experiment from.
itr (int or string): Iteration to load.
Ca... | Load one snapshot of parameters from disk.
Args:
load_dir (str): Directory of the cloudpickle file
to resume experiment from.
itr (int or string): Iteration to load.
Can be an integer, 'last' or 'first'.
Returns:
dict: Loaded snapshot... | load | python | rlworkgroup/garage | src/garage/experiment/snapshotter.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/experiment/snapshotter.py | MIT |
def _extract_snapshot_itr(filename: str) -> int:
"""Extracts the integer itr from a filename.
Args:
filename(str): The snapshot filename.
Returns:
int: The snapshot as an integer.
"""
base = os.path.splitext(filename)[0]
digits = base.split('itr_')[1]
return int(digits) | Extracts the integer itr from a filename.
Args:
filename(str): The snapshot filename.
Returns:
int: The snapshot as an integer.
| _extract_snapshot_itr | python | rlworkgroup/garage | src/garage/experiment/snapshotter.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/experiment/snapshotter.py | MIT |
def _sample_indices(n_to_sample, n_available_tasks, with_replacement):
"""Select indices of tasks to sample.
Args:
n_to_sample (int): Number of environments to sample. May be greater
than n_available_tasks.
n_available_tasks (int): Number of available tasks. Task indices will
... | Select indices of tasks to sample.
Args:
n_to_sample (int): Number of environments to sample. May be greater
than n_available_tasks.
n_available_tasks (int): Number of available tasks. Task indices will
be selected in the range [0, n_available_tasks).
with_replacemen... | _sample_indices | python | rlworkgroup/garage | src/garage/experiment/task_sampler.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/experiment/task_sampler.py | MIT |
def sample(self, n_tasks, with_replacement=False):
"""Sample a list of environment updates.
Args:
n_tasks (int): Number of updates to sample.
with_replacement (bool): Whether tasks can repeat when sampled.
Note that if more tasks are sampled than exist, then task... | Sample a list of environment updates.
Args:
n_tasks (int): Number of updates to sample.
with_replacement (bool): Whether tasks can repeat when sampled.
Note that if more tasks are sampled than exist, then tasks may
repeat, but only after every environment... | sample | python | rlworkgroup/garage | src/garage/experiment/task_sampler.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/experiment/task_sampler.py | MIT |
def sample(self, n_tasks, with_replacement=False):
"""Sample a list of environment updates.
Args:
n_tasks (int): Number of updates to sample.
with_replacement (bool): Whether tasks can repeat when sampled.
Note that if more tasks are sampled than exist, then task... | Sample a list of environment updates.
Args:
n_tasks (int): Number of updates to sample.
with_replacement (bool): Whether tasks can repeat when sampled.
Note that if more tasks are sampled than exist, then tasks may
repeat, but only after every environment... | sample | python | rlworkgroup/garage | src/garage/experiment/task_sampler.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/experiment/task_sampler.py | MIT |
def sample(self, n_tasks, with_replacement=False):
"""Sample a list of environment updates.
Args:
n_tasks (int): Number of updates to sample.
with_replacement (bool): Whether tasks can repeat when sampled.
Note that if more tasks are sampled than exist, then task... | Sample a list of environment updates.
Args:
n_tasks (int): Number of updates to sample.
with_replacement (bool): Whether tasks can repeat when sampled.
Note that if more tasks are sampled than exist, then tasks may
repeat, but only after every environment... | sample | python | rlworkgroup/garage | src/garage/experiment/task_sampler.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/experiment/task_sampler.py | MIT |
def sample(self, n_tasks, with_replacement=False):
"""Sample a list of environment updates.
Args:
n_tasks (int): Number of updates to sample.
with_replacement (bool): Whether tasks can repeat when sampled.
Since this cannot be easily implemented for an object poo... | Sample a list of environment updates.
Args:
n_tasks (int): Number of updates to sample.
with_replacement (bool): Whether tasks can repeat when sampled.
Since this cannot be easily implemented for an object pool,
setting this to True results in ValueError.... | sample | python | rlworkgroup/garage | src/garage/experiment/task_sampler.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/experiment/task_sampler.py | MIT |
def grow_pool(self, new_size):
"""Increase the size of the pool by copying random tasks in it.
Note that this only copies the tasks already in the pool, and cannot
create new original tasks in any way.
Args:
new_size (int): Size the pool should be after growning.
"... | Increase the size of the pool by copying random tasks in it.
Note that this only copies the tasks already in the pool, and cannot
create new original tasks in any way.
Args:
new_size (int): Size the pool should be after growning.
| grow_pool | python | rlworkgroup/garage | src/garage/experiment/task_sampler.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/experiment/task_sampler.py | MIT |
def sample(self, n_tasks, with_replacement=False):
"""Sample a list of environment updates.
Note that this will always return environments in the same order, to
make parallel sampling across workers efficient. If randomizing the
environment order is required, shuffle the result of this ... | Sample a list of environment updates.
Note that this will always return environments in the same order, to
make parallel sampling across workers efficient. If randomizing the
environment order is required, shuffle the result of this method.
Args:
n_tasks (int): Number of up... | sample | python | rlworkgroup/garage | src/garage/experiment/task_sampler.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/experiment/task_sampler.py | MIT |
def wrap(env, task):
"""Wrap an environment in a metaworld benchmark.
Args:
env (gym.Env): A metaworld / gym environment.
task (metaworld.Task): A metaworld task.
Returns:
garage.Env: The wrapped environment.
"""
... | Wrap an environment in a metaworld benchmark.
Args:
env (gym.Env): A metaworld / gym environment.
task (metaworld.Task): A metaworld task.
Returns:
garage.Env: The wrapped environment.
| wrap | python | rlworkgroup/garage | src/garage/experiment/task_sampler.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/experiment/task_sampler.py | MIT |
def explained_variance_1d(ypred, y, valids=None):
"""Explained variation for 1D inputs.
It is the proportion of the variance in one variable that is explained or
predicted from another variable.
Args:
ypred (np.ndarray): Sample data from the first variable.
Shape: :math:`(N, max_ep... | Explained variation for 1D inputs.
It is the proportion of the variance in one variable that is explained or
predicted from another variable.
Args:
ypred (np.ndarray): Sample data from the first variable.
Shape: :math:`(N, max_episode_length)`.
y (np.ndarray): Sample data from ... | explained_variance_1d | python | rlworkgroup/garage | src/garage/np/_functions.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/np/_functions.py | MIT |
def rrse(actual, predicted):
"""Root Relative Squared Error.
Args:
actual (np.ndarray): The actual value.
predicted (np.ndarray): The predicted value.
Returns:
float: The root relative square error between the actual and the
predicted value.
"""
return np.sqrt(... | Root Relative Squared Error.
Args:
actual (np.ndarray): The actual value.
predicted (np.ndarray): The predicted value.
Returns:
float: The root relative square error between the actual and the
predicted value.
| rrse | python | rlworkgroup/garage | src/garage/np/_functions.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/np/_functions.py | MIT |
def sliding_window(t, window, smear=False):
"""Create a sliding window over a tensor.
Args:
t (np.ndarray): A tensor to create sliding window from,
with shape :math:`(N, D)`, where N is the length of a trajectory,
D is the dimension of each step in trajectory.
window (in... | Create a sliding window over a tensor.
Args:
t (np.ndarray): A tensor to create sliding window from,
with shape :math:`(N, D)`, where N is the length of a trajectory,
D is the dimension of each step in trajectory.
window (int): Window size, mush be less than N.
smear... | sliding_window | python | rlworkgroup/garage | src/garage/np/_functions.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/np/_functions.py | MIT |
def flatten_tensors(tensors):
"""Flatten a list of tensors.
Args:
tensors (list[numpy.ndarray]): List of tensors to be flattened.
Returns:
numpy.ndarray: Flattened tensors.
Example:
.. testsetup::
from garage.np import flatten_tensors
>>> flatten_tensors([np.ndarray... | Flatten a list of tensors.
Args:
tensors (list[numpy.ndarray]): List of tensors to be flattened.
Returns:
numpy.ndarray: Flattened tensors.
Example:
.. testsetup::
from garage.np import flatten_tensors
>>> flatten_tensors([np.ndarray([1]), np.ndarray([1])])
array(..... | flatten_tensors | python | rlworkgroup/garage | src/garage/np/_functions.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/np/_functions.py | MIT |
def unflatten_tensors(flattened, tensor_shapes):
"""Unflatten a flattened tensors into a list of tensors.
Args:
flattened (numpy.ndarray): Flattened tensors.
tensor_shapes (tuple): Tensor shapes.
Returns:
list[numpy.ndarray]: Unflattened list of tensors.
"""
tensor_sizes =... | Unflatten a flattened tensors into a list of tensors.
Args:
flattened (numpy.ndarray): Flattened tensors.
tensor_shapes (tuple): Tensor shapes.
Returns:
list[numpy.ndarray]: Unflattened list of tensors.
| unflatten_tensors | python | rlworkgroup/garage | src/garage/np/_functions.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/np/_functions.py | MIT |
def pad_tensor(x, max_len, mode='zero'):
"""Pad tensors.
Args:
x (numpy.ndarray): Tensors to be padded.
max_len (int): Maximum length.
mode (str): If 'last', pad with the last element, otherwise pad with 0.
Returns:
numpy.ndarray: Padded tensor.
"""
padding = np.ze... | Pad tensors.
Args:
x (numpy.ndarray): Tensors to be padded.
max_len (int): Maximum length.
mode (str): If 'last', pad with the last element, otherwise pad with 0.
Returns:
numpy.ndarray: Padded tensor.
| pad_tensor | python | rlworkgroup/garage | src/garage/np/_functions.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/np/_functions.py | MIT |
def pad_tensor_n(xs, max_len):
"""Pad array of tensors.
Args:
xs (numpy.ndarray): Tensors to be padded.
max_len (int): Maximum length.
Returns:
numpy.ndarray: Padded tensor.
"""
ret = np.zeros((len(xs), max_len) + xs[0].shape[1:], dtype=xs[0].dtype)
for idx, x in enume... | Pad array of tensors.
Args:
xs (numpy.ndarray): Tensors to be padded.
max_len (int): Maximum length.
Returns:
numpy.ndarray: Padded tensor.
| pad_tensor_n | python | rlworkgroup/garage | src/garage/np/_functions.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/np/_functions.py | MIT |
def pad_tensor_dict(tensor_dict, max_len, mode='zero'):
"""Pad dictionary of tensors.
Args:
tensor_dict (dict[numpy.ndarray]): Tensors to be padded.
max_len (int): Maximum length.
mode (str): If 'last', pad with the last element, otherwise pad with 0.
Returns:
dict[numpy.nd... | Pad dictionary of tensors.
Args:
tensor_dict (dict[numpy.ndarray]): Tensors to be padded.
max_len (int): Maximum length.
mode (str): If 'last', pad with the last element, otherwise pad with 0.
Returns:
dict[numpy.ndarray]: Padded tensor.
| pad_tensor_dict | python | rlworkgroup/garage | src/garage/np/_functions.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/np/_functions.py | MIT |
def stack_tensor_dict_list(tensor_dict_list):
"""Stack a list of dictionaries of {tensors or dictionary of tensors}.
Args:
tensor_dict_list (dict[list]): a list of dictionaries of {tensors or
dictionary of tensors}.
Return:
dict: a dictionary of {stacked tensors or dictionary o... | Stack a list of dictionaries of {tensors or dictionary of tensors}.
Args:
tensor_dict_list (dict[list]): a list of dictionaries of {tensors or
dictionary of tensors}.
Return:
dict: a dictionary of {stacked tensors or dictionary of
stacked tensors}
| stack_tensor_dict_list | python | rlworkgroup/garage | src/garage/np/_functions.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/np/_functions.py | MIT |
def stack_and_pad_tensor_dict_list(tensor_dict_list, max_len):
"""Stack and pad array of list of tensors.
Input paths are a list of N dicts, each with values of shape
:math:`(D, S^*)`. This function stack and pad the values with the input
key with max_len, so output will be shape :math:`(N, D, S^*)`.
... | Stack and pad array of list of tensors.
Input paths are a list of N dicts, each with values of shape
:math:`(D, S^*)`. This function stack and pad the values with the input
key with max_len, so output will be shape :math:`(N, D, S^*)`.
Args:
tensor_dict_list (list[dict]): List of dict to be st... | stack_and_pad_tensor_dict_list | python | rlworkgroup/garage | src/garage/np/_functions.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/np/_functions.py | MIT |
def concat_tensor_dict_list(tensor_dict_list):
"""Concatenate dictionary of list of tensor.
Args:
tensor_dict_list (dict[list]): a list of dictionaries of {tensors or
dictionary of tensors}.
Return:
dict: a dictionary of {stacked tensors or dictionary of
stacked ten... | Concatenate dictionary of list of tensor.
Args:
tensor_dict_list (dict[list]): a list of dictionaries of {tensors or
dictionary of tensors}.
Return:
dict: a dictionary of {stacked tensors or dictionary of
stacked tensors}
| concat_tensor_dict_list | python | rlworkgroup/garage | src/garage/np/_functions.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/np/_functions.py | MIT |
def truncate_tensor_dict(tensor_dict, truncated_len):
"""Truncate dictionary of list of tensor.
Args:
tensor_dict (dict[numpy.ndarray]): a dictionary of {tensors or
dictionary of tensors}.
truncated_len (int): Length to truncate.
Return:
dict: a dictionary of {stacked t... | Truncate dictionary of list of tensor.
Args:
tensor_dict (dict[numpy.ndarray]): a dictionary of {tensors or
dictionary of tensors}.
truncated_len (int): Length to truncate.
Return:
dict: a dictionary of {stacked tensors or dictionary of
stacked tensors}
| truncate_tensor_dict | python | rlworkgroup/garage | src/garage/np/_functions.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/np/_functions.py | MIT |
def slice_nested_dict(dict_or_array, start, stop):
"""Slice a dictionary containing arrays (or dictionaries).
This function is primarily intended for un-batching env_infos and
action_infos.
Args:
dict_or_array (dict[str, dict or np.ndarray] or np.ndarray): A nested
dictionary shoul... | Slice a dictionary containing arrays (or dictionaries).
This function is primarily intended for un-batching env_infos and
action_infos.
Args:
dict_or_array (dict[str, dict or np.ndarray] or np.ndarray): A nested
dictionary should only contain dictionaries and numpy arrays
(... | slice_nested_dict | python | rlworkgroup/garage | src/garage/np/_functions.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/np/_functions.py | MIT |
def pad_batch_array(array, lengths, max_length=None):
r"""Convert a packed into a padded array with one more dimension.
Args:
array (np.ndarray): Array of length :math:`(N \bullet [T], X^*)`
lengths (list[int]): List of length :math:`N` containing the length
of each episode in the b... | Convert a packed into a padded array with one more dimension.
Args:
array (np.ndarray): Array of length :math:`(N \bullet [T], X^*)`
lengths (list[int]): List of length :math:`N` containing the length
of each episode in the batch array.
max_length (int): Defaults to max(lengths)... | pad_batch_array | python | rlworkgroup/garage | src/garage/np/_functions.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/np/_functions.py | MIT |
def _sample_params(self, epoch):
"""Return sample parameters.
Args:
epoch (int): Epoch number.
Returns:
np.ndarray: A numpy array of parameter values.
"""
extra_var_mult = max(1.0 - epoch / self._extra_decay_time, 0)
sample_std = np.sqrt(
... | Return sample parameters.
Args:
epoch (int): Epoch number.
Returns:
np.ndarray: A numpy array of parameter values.
| _sample_params | python | rlworkgroup/garage | src/garage/np/algos/cem.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/np/algos/cem.py | MIT |
def train(self, trainer):
"""Initialize variables and start training.
Args:
trainer (Trainer): Experiment trainer, which provides services
such as snapshotting and sampler control.
Returns:
float: The average return in last epoch cycle.
"""
... | Initialize variables and start training.
Args:
trainer (Trainer): Experiment trainer, which provides services
such as snapshotting and sampler control.
Returns:
float: The average return in last epoch cycle.
| train | python | rlworkgroup/garage | src/garage/np/algos/cem.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/np/algos/cem.py | MIT |
def _train_once(self, itr, episodes):
"""Perform one step of policy optimization given one batch of samples.
Args:
itr (int): Iteration number.
episodes (garage.EpisodeBatch): Episodes collected using the
current policy.
Returns:
float: The a... | Perform one step of policy optimization given one batch of samples.
Args:
itr (int): Iteration number.
episodes (garage.EpisodeBatch): Episodes collected using the
current policy.
Returns:
float: The average return of epoch cycle.
| _train_once | python | rlworkgroup/garage | src/garage/np/algos/cem.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/np/algos/cem.py | MIT |
def train(self, trainer):
"""Initialize variables and start training.
Args:
trainer (Trainer): Trainer is passed to give algorithm
the access to trainer.step_epochs(), which provides services
such as snapshotting and sampler control.
Returns:
... | Initialize variables and start training.
Args:
trainer (Trainer): Trainer is passed to give algorithm
the access to trainer.step_epochs(), which provides services
such as snapshotting and sampler control.
Returns:
float: The average return in las... | train | python | rlworkgroup/garage | src/garage/np/algos/cma_es.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/np/algos/cma_es.py | MIT |
def _train_once(self, itr, episodes):
"""Perform one step of policy optimization given one batch of samples.
Args:
itr (int): Iteration number.
episodes (garage.EpisodeBatch): Episodes collected using the
current policy.
Returns:
float: The a... | Perform one step of policy optimization given one batch of samples.
Args:
itr (int): Iteration number.
episodes (garage.EpisodeBatch): Episodes collected using the
current policy.
Returns:
float: The average return of epoch cycle.
| _train_once | python | rlworkgroup/garage | src/garage/np/algos/cma_es.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/np/algos/cma_es.py | MIT |
def get_exploration_policy(self):
"""Return a policy used before adaptation to a specific task.
Each time it is retrieved, this policy should only be evaluated in one
task.
Returns:
Policy: The policy used to obtain samples, which are later used for
meta-RL ... | Return a policy used before adaptation to a specific task.
Each time it is retrieved, this policy should only be evaluated in one
task.
Returns:
Policy: The policy used to obtain samples, which are later used for
meta-RL adaptation.
| get_exploration_policy | python | rlworkgroup/garage | src/garage/np/algos/meta_rl_algorithm.py | https://github.com/rlworkgroup/garage/blob/master/src/garage/np/algos/meta_rl_algorithm.py | MIT |
Subsets and Splits
Django Code with Docstrings
Filters Python code examples from Django repository that contain Django-related code, helping identify relevant code snippets for understanding Django framework usage patterns.
SQL Console for Shuu12121/python-treesitter-filtered-datasetsV2
Retrieves Python code examples from Django repository that contain 'django' in the code, which helps identify Django-specific code snippets but provides limited analytical insights beyond basic filtering.
SQL Console for Shuu12121/python-treesitter-filtered-datasetsV2
Retrieves specific code examples from the Flask repository but doesn't provide meaningful analysis or patterns beyond basic data retrieval.
HTTPX Repo Code and Docstrings
Retrieves specific code examples from the httpx repository, which is useful for understanding how particular libraries are used but doesn't provide broader analytical insights about the dataset.
Requests Repo Docstrings & Code
Retrieves code examples with their docstrings and file paths from the requests repository, providing basic filtering but limited analytical value beyond finding specific code samples.
Quart Repo Docstrings & Code
Retrieves code examples with their docstrings from the Quart repository, providing basic code samples but offering limited analytical value for understanding broader patterns or relationships in the dataset.