Search is not available for this dataset
repo
stringlengths
2
152
file
stringlengths
15
239
code
stringlengths
0
58.4M
file_length
int64
0
58.4M
avg_line_length
float64
0
1.81M
max_line_length
int64
0
12.7M
extension_type
stringclasses
364 values
CSD-locomotion
CSD-locomotion-master/garaged/examples/tf/ppo_pendulum.py
#!/usr/bin/env python3 """This is an example to train a task with PPO algorithm. Here it creates InvertedDoublePendulum using gym. And uses a PPO with 1M steps. Results: AverageDiscountedReturn: 500 RiseTime: itr 40 """ import gym import tensorflow as tf from garage import wrap_experiment from garage.envs i...
2,296
27.358025
73
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/tf/reps_gym_cartpole.py
#!/usr/bin/env python3 """This is an example to train a task with REPS algorithm. Here it runs gym CartPole env with 100 iterations. Results: AverageReturn: 100 +/- 40 RiseTime: itr 10 +/- 5 """ import gym from garage import wrap_experiment from garage.envs import GarageEnv from garage.experiment import Lo...
1,465
26.660377
79
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/tf/resume_training.py
#!/usr/bin/env python3 """This is an example to resume training programmatically.""" # pylint: disable=no-value-for-parameter import click from garage import wrap_experiment from garage.experiment import LocalTFRunner @click.command() @click.option('--saved_dir', required=True, help='Path...
808
25.966667
72
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/tf/rl2_ppo_halfcheetah.py
#!/usr/bin/env python3 """Example script to run RL2 in HalfCheetah.""" # pylint: disable=no-value-for-parameter import click from garage import wrap_experiment from garage.envs.mujoco.half_cheetah_vel_env import HalfCheetahVelEnv from garage.experiment import LocalTFRunner from garage.experiment import task_sampler fr...
3,326
37.686047
79
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/tf/rl2_ppo_halfcheetah_meta_test.py
#!/usr/bin/env python3 """Example script to run RL2PPO meta test in HalfCheetah.""" # pylint: disable=no-value-for-parameter import click from garage import wrap_experiment from garage.envs.mujoco.half_cheetah_vel_env import HalfCheetahVelEnv from garage.experiment import LocalTFRunner from garage.experiment import ta...
3,859
39.631579
79
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/tf/rl2_ppo_metaworld_ml10.py
#!/usr/bin/env python3 """Example script to run RL2 in ML10.""" # pylint: disable=no-value-for-parameter import click import metaworld.benchmarks as mwb from garage import wrap_experiment from garage.experiment import LocalTFRunner from garage.experiment import task_sampler from garage.experiment.deterministic import ...
3,437
37.2
74
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/tf/rl2_ppo_metaworld_ml10_meta_test.py
#!/usr/bin/env python3 """Example script to run RL2 in ML10 with meta-test.""" # pylint: disable=no-value-for-parameter import click import metaworld.benchmarks as mwb from garage import wrap_experiment from garage.experiment import LocalTFRunner from garage.experiment import task_sampler from garage.experiment.determ...
4,231
38.924528
74
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/tf/rl2_ppo_metaworld_ml1_push.py
#!/usr/bin/env python3 """Example script to run RL2 in ML1.""" # pylint: disable=no-value-for-parameter import click import metaworld.benchmarks as mwb from garage import wrap_experiment from garage.experiment import LocalTFRunner from garage.experiment import task_sampler from garage.experiment.deterministic import s...
3,327
37.697674
76
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/tf/rl2_ppo_metaworld_ml45.py
#!/usr/bin/env python3 """Example script to run RL2 in ML45.""" # pylint: disable=no-value-for-parameter, wrong-import-order import click import metaworld.benchmarks as mwb from garage import wrap_experiment from garage.experiment import LocalTFRunner from garage.experiment import task_sampler from garage.experiment.d...
3,502
37.076087
74
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/tf/rl2_trpo_halfcheetah.py
#!/usr/bin/env python3 """Example script to run RL2 in HalfCheetah.""" # pylint: disable=no-value-for-parameter import click from garage import wrap_experiment from garage.envs.mujoco.half_cheetah_vel_env import HalfCheetahVelEnv from garage.experiment import LocalTFRunner from garage.experiment import task_sampler fr...
3,266
38.841463
76
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/tf/td3_pendulum.py
#!/usr/bin/env python3 """This is an example to train a task with TD3 algorithm. Here, we create a gym environment InvertedDoublePendulum and use a TD3 with 1M steps. Results: AverageReturn: 250 RiseTime: epoch 499 """ import gym import tensorflow as tf from garage import wrap_experiment from garage.envs imp...
3,172
35.471264
72
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/tf/te_ppo_metaworld_ml1_push.py
#!/usr/bin/env python3 """This is an example to train Task Embedding PPO with PointEnv.""" # pylint: disable=no-value-for-parameter import click from metaworld.benchmarks import ML1 import tensorflow as tf from garage import wrap_experiment from garage.envs import GarageEnv, normalize from garage.envs.multi_env_wrappe...
4,620
33.744361
77
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/tf/te_ppo_metaworld_mt10.py
#!/usr/bin/env python3 """This is an example to train Task Embedding PPO with PointEnv.""" # pylint: disable=no-value-for-parameter import click from metaworld.benchmarks import MT10 import tensorflow as tf from garage import wrap_experiment from garage.envs import GarageEnv, normalize from garage.envs.multi_env_wrapp...
4,837
34.313869
77
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/tf/te_ppo_metaworld_mt50.py
#!/usr/bin/env python3 """This is an example to train Task Embedding PPO with PointEnv.""" # pylint: disable=no-value-for-parameter import click from metaworld.benchmarks import MT50 import tensorflow as tf from garage import wrap_experiment from garage.envs import GarageEnv, normalize from garage.envs.multi_env_wrapp...
4,837
34.313869
77
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/tf/te_ppo_point.py
#!/usr/bin/env python3 """This is an example to train Task Embedding PPO with PointEnv.""" # pylint: disable=no-value-for-parameter import click import numpy as np import tensorflow as tf from garage import wrap_experiment from garage.envs import GarageEnv, PointEnv from garage.envs.multi_env_wrapper import MultiEnvWr...
5,676
31.44
78
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/tf/trpo_cartpole.py
#!/usr/bin/env python3 """This is an example to train a task with TRPO algorithm. Here it runs CartPole-v1 environment with 100 iterations. Results: AverageReturn: 100 RiseTime: itr 13 """ from garage import wrap_experiment from garage.envs import GarageEnv from garage.experiment import LocalTFRunner from gar...
1,537
28.576923
72
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/tf/trpo_cartpole_batch_sampler.py
#!/usr/bin/env python3 """This is an example to train a task with parallel sampling.""" import click from garage import wrap_experiment from garage.envs import GarageEnv from garage.experiment import LocalTFRunner from garage.experiment.deterministic import set_seed from garage.np.baselines import LinearFeatureBaselin...
2,140
34.098361
75
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/tf/trpo_cartpole_recurrent.py
#!/usr/bin/env python3 """This is an example to train a task with TRPO algorithm. It uses an LSTM-based recurrent policy. Here it runs CartPole-v1 environment with 100 iterations. Results: AverageReturn: 100 RiseTime: itr 13 """ # pylint: disable=no-value-for-parameter import click from garage import wrap_e...
2,240
31.955882
73
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/tf/trpo_cubecrash.py
#!/usr/bin/env python3 """This is an example to train a task with TRPO algorithm. Here it runs CubeCrash-v0 environment with 100 iterations. """ import click import gym from garage import wrap_experiment from garage.envs import GarageEnv, normalize from garage.experiment import LocalTFRunner from garage.experiment.de...
2,245
34.09375
75
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/tf/trpo_gym_tf_cartpole.py
#!/usr/bin/env python3 """An example to train a task with TRPO algorithm.""" import gym from garage import wrap_experiment from garage.envs import GarageEnv from garage.experiment import LocalTFRunner from garage.experiment.deterministic import set_seed from garage.np.baselines import LinearFeatureBaseline from garage...
1,441
28.428571
72
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/tf/trpo_swimmer.py
#!/usr/bin/env python3 """An example to train a task with TRPO algorithm.""" import gym from garage import wrap_experiment from garage.envs import GarageEnv from garage.experiment import LocalTFRunner from garage.experiment.deterministic import set_seed from garage.np.baselines import LinearFeatureBaseline from garage...
1,425
30
76
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/tf/trpo_swimmer_ray_sampler.py
#!/usr/bin/env python3 """This is an example to train a task with TRPO algorithm. Uses Ray sampler instead of on_policy vectorized sampler. Here it runs Swimmer-v2 environment with 40 iterations. """ import gym import ray from garage import wrap_experiment from garage.envs import GarageEnv from garage.experiment impo...
1,969
30.269841
76
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/tf/trpois_inverted_pendulum.py
#!/usr/bin/env python3 """Example using TRPO with ISSampler. Iterations alternate between live and importance sampled iterations. """ import gym from garage import wrap_experiment from garage.envs import GarageEnv, normalize from garage.experiment import LocalTFRunner from garage.experiment.deterministic import set_s...
1,617
30.115385
76
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/tf/vpg_cartpole.py
#!/usr/bin/env python3 """This is an example to train a task with VPG algorithm. Here it runs CartPole-v1 environment with 100 iterations. Results: AverageReturn: 100 RiseTime: itr 16 """ from garage import wrap_experiment from garage.envs import GarageEnv from garage.experiment import LocalTFRunner from gara...
1,568
29.173077
72
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/tf/vpgis_inverted_pendulum.py
#!/usr/bin/env python3 """Example using VPG with ISSampler. Iterations alternate between live and importance sampled iterations. """ import gym from garage import wrap_experiment from garage.envs import GarageEnv, normalize from garage.experiment import LocalTFRunner from garage.experiment.deterministic import set_se...
1,583
28.333333
76
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/torch/ddpg_pendulum.py
#!/usr/bin/env python3 """This is an example to train a task with DDPG algorithm written in PyTorch. Here it creates a gym environment InvertedDoublePendulum. And uses a DDPG with 1M steps. """ import gym import torch from torch.nn import functional as F from garage import wrap_experiment from garage.envs import Gar...
2,496
33.205479
79
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/torch/maml_ppo_half_cheetah_dir.py
#!/usr/bin/env python3 """This is an example to train MAML-VPG on HalfCheetahDirEnv environment.""" # pylint: disable=no-value-for-parameter import click import torch from garage import wrap_experiment from garage.envs import GarageEnv, normalize from garage.envs.mujoco import HalfCheetahDirEnv from garage.experiment ...
3,034
36.012195
78
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/torch/maml_trpo_half_cheetah_dir.py
#!/usr/bin/env python3 """This is an example to train MAML-VPG on HalfCheetahDirEnv environment.""" # pylint: disable=no-value-for-parameter import click import torch from garage import wrap_experiment from garage.envs import GarageEnv, normalize from garage.envs.mujoco import HalfCheetahDirEnv from garage.experiment ...
3,048
36.182927
78
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/torch/maml_trpo_metaworld_ml10.py
#!/usr/bin/env python3 """This is an example to train MAML-TRPO on ML10 environment.""" # pylint: disable=no-value-for-parameter import click import metaworld.benchmarks as mwb import torch from garage import wrap_experiment from garage.envs import GarageEnv, normalize from garage.experiment import LocalRunner, MetaEv...
3,142
35.126437
77
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/torch/maml_trpo_metaworld_ml1_push.py
#!/usr/bin/env python3 """This is an example to train MAML-TRPO on ML1 Push environment.""" # pylint: disable=no-value-for-parameter import click import metaworld.benchmarks as mwb import torch from garage import wrap_experiment from garage.envs import GarageEnv, normalize from garage.experiment import LocalRunner, Me...
2,957
35.073171
77
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/torch/maml_trpo_metaworld_ml45.py
#!/usr/bin/env python3 """This is an example to train MAML-TRPO on ML45 environment.""" # pylint: disable=no-value-for-parameter import click import metaworld.benchmarks as mwb import torch from garage import wrap_experiment from garage.envs import GarageEnv, normalize from garage.experiment import LocalRunner, MetaEv...
2,908
33.630952
75
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/torch/maml_vpg_half_cheetah_dir.py
#!/usr/bin/env python3 """This is an example to train MAML-VPG on HalfCheetahDirEnv environment.""" # pylint: disable=no-value-for-parameter import click import torch from garage import wrap_experiment from garage.envs import GarageEnv, normalize from garage.envs.mujoco import HalfCheetahDirEnv from garage.experiment ...
3,034
36.012195
78
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/torch/mtppo_metaworld_ml1_push.py
#!/usr/bin/env python3 """This is an example to train PPO on ML1 Push environment.""" # pylint: disable=no-value-for-parameter import click import metaworld.benchmarks as mwb import torch from garage import wrap_experiment from garage.envs import GarageEnv, normalize from garage.experiment import LocalRunner from gara...
2,049
32.064516
77
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/torch/mtppo_metaworld_mt10.py
#!/usr/bin/env python3 """This is an example to train PPO on MT10 environment.""" # pylint: disable=no-value-for-parameter import click import metaworld.benchmarks as mwb import psutil import torch from garage import wrap_experiment from garage.envs import GarageEnv, MultiEnvWrapper, normalize from garage.envs.multi_e...
2,630
34.554054
77
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/torch/mtppo_metaworld_mt50.py
#!/usr/bin/env python3 """This is an example to train PPO on MT50 environment.""" # pylint: disable=no-value-for-parameter import click import metaworld.benchmarks as mwb import psutil import torch from garage import wrap_experiment from garage.envs import GarageEnv, MultiEnvWrapper, normalize from garage.envs.multi_e...
2,630
34.554054
77
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/torch/mtsac_metaworld_ml1_pick_place.py
#!/usr/bin/env python3 """MTSAC implementation based on Metaworld. Benchmarked on ML1. This experiment shows how MTSAC adapts to 50 environents of the same type but each environment has a goal variation. https://arxiv.org/pdf/1910.10897.pdf """ import pickle import click import metaworld.benchmarks as mwb import num...
4,154
35.769912
78
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/torch/mtsac_metaworld_mt10.py
#!/usr/bin/env python3 """MTSAC implementation based on Metaworld. Benchmarked on MT10. https://arxiv.org/pdf/1910.10897.pdf """ import click import metaworld.benchmarks as mwb import numpy as np from torch import nn from torch.nn import functional as F from garage import wrap_experiment from garage.envs import Garag...
3,899
36.5
78
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/torch/mtsac_metaworld_mt50.py
#!/usr/bin/env python3 """MTSAC implementation based on Metaworld. Benchmarked on MT50. https://arxiv.org/pdf/1910.10897.pdf """ import click import metaworld.benchmarks as mwb import numpy as np from torch import nn from torch.nn import functional as F from garage import wrap_experiment from garage.envs import Garag...
4,087
36.851852
75
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/torch/mttrpo_metaworld_ml1_push.py
#!/usr/bin/env python3 """This is an example to train TRPO on ML1 Push environment.""" # pylint: disable=no-value-for-parameter import click import metaworld.benchmarks as mwb import torch from garage import wrap_experiment from garage.envs import GarageEnv, normalize from garage.experiment import LocalRunner from gar...
2,093
32.774194
77
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/torch/mttrpo_metaworld_mt10.py
#!/usr/bin/env python3 """This is an example to train TRPO on MT10 environment.""" # pylint: disable=no-value-for-parameter import click import metaworld.benchmarks as mwb import psutil import torch from garage import wrap_experiment from garage.envs import GarageEnv, MultiEnvWrapper, normalize from garage.envs.multi_...
2,574
34.763889
77
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/torch/mttrpo_metaworld_mt50.py
#!/usr/bin/env python3 """This is an example to train TRPO on MT50 environment.""" # pylint: disable=no-value-for-parameter import click import metaworld.benchmarks as mwb import psutil import torch from garage import wrap_experiment from garage.envs import GarageEnv, MultiEnvWrapper, normalize from garage.envs.multi_...
2,574
34.763889
77
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/torch/pearl_half_cheetah_vel.py
#!/usr/bin/env python3 """PEARL HalfCheetahVel example.""" import click from garage import wrap_experiment from garage.envs import GarageEnv, normalize from garage.envs.mujoco import HalfCheetahVelEnv from garage.experiment import LocalRunner from garage.experiment.deterministic import set_seed from garage.experiment....
6,501
40.679487
79
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/torch/pearl_metaworld_ml10.py
#!/usr/bin/env python3 """PEARL ML10 example.""" import click import metaworld.benchmarks as mwb from garage import wrap_experiment from garage.envs import GarageEnv, normalize from garage.experiment import LocalRunner from garage.experiment.deterministic import set_seed from garage.experiment.task_sampler import Env...
6,732
39.317365
79
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/torch/pearl_metaworld_ml1_push.py
#!/usr/bin/env python3 """PEARL ML1 example.""" import click import metaworld.benchmarks as mwb from garage import wrap_experiment from garage.envs import GarageEnv, normalize from garage.experiment import LocalRunner from garage.experiment.deterministic import set_seed from garage.experiment.task_sampler import SetTa...
6,536
40.636943
79
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/torch/pearl_metaworld_ml45.py
#!/usr/bin/env python3 """PEARL ML45 example.""" import click import metaworld.benchmarks as mwb from garage import wrap_experiment from garage.envs import GarageEnv, normalize from garage.experiment import LocalRunner from garage.experiment.deterministic import set_seed from garage.experiment.task_sampler import Env...
6,740
39.365269
79
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/torch/ppo_pendulum.py
#!/usr/bin/env python3 """This is an example to train a task with PPO algorithm (PyTorch). Here it runs InvertedDoublePendulum-v2 environment with 100 iterations. """ import torch from garage import wrap_experiment from garage.envs import GarageEnv from garage.experiment import LocalRunner from garage.experiment.dete...
1,794
31.636364
77
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/torch/resume_training.py
#!/usr/bin/env python3 """This is an example to resume training programmatically.""" # pylint: disable=no-value-for-parameter import click from garage import wrap_experiment from garage.experiment import LocalRunner @click.command() @click.option('--saved_dir', required=True, help='Path w...
786
25.233333
72
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/torch/sac_half_cheetah_batch.py
#!/usr/bin/env python3 """This is an example to train a task with SAC algorithm written in PyTorch.""" import gym import numpy as np import torch from torch import nn from torch.nn import functional as F from garage import wrap_experiment from garage.envs import GarageEnv, normalize from garage.experiment import deter...
2,564
31.0625
79
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/torch/trpo_pendulum.py
#!/usr/bin/env python3 """This is an example to train a task with TRPO algorithm (PyTorch). Here it runs InvertedDoublePendulum-v2 environment with 100 iterations. """ import torch from garage import wrap_experiment from garage.envs import GarageEnv from garage.experiment import LocalRunner from garage.experiment.det...
1,804
31.818182
77
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/torch/trpo_pendulum_ray_sampler.py
#!/usr/bin/env python3 """This is an example to train a task with TRPO algorithm (PyTorch). Uses Ray sampler instead of OnPolicyVectorizedSampler. Here it runs InvertedDoublePendulum-v2 environment with 100 iterations. """ import numpy as np import ray import torch from garage import wrap_experiment from garage.envs ...
2,324
34.227273
77
py
CSD-locomotion
CSD-locomotion-master/garaged/examples/torch/vpg_pendulum.py
#!/usr/bin/env python3 """This is an example to train a task with VPG algorithm (PyTorch). Here it runs InvertedDoublePendulum-v2 environment with 100 iterations. Results: AverageReturn: 450 - 650 """ import torch from garage import wrap_experiment from garage.envs import GarageEnv from garage.experiment import ...
1,827
30.517241
77
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/__init__.py
"""Garage Base.""" from garage._dtypes import InOutSpec from garage._dtypes import TimeStep from garage._dtypes import TimeStepBatch from garage._dtypes import TrajectoryBatch from garage._functions import _Default from garage._functions import log_multitask_performance from garage._functions import log_performance fro...
603
34.529412
70
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/_dtypes.py
"""Data types for agent-based learning.""" import collections import akro import numpy as np from garage.misc import tensor_utils class TrajectoryBatch( collections.namedtuple('TrajectoryBatch', [ 'env_spec', 'observations', 'last_observations', 'actions', ...
43,670
45.458511
116
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/_functions.py
"""Functions exposed directly in the garage namespace.""" from collections import defaultdict from dowel import tabular import numpy as np import garage from garage.misc.tensor_utils import discount_cumsum class _Default: # pylint: disable=too-few-public-methods """A wrapper class to represent default argument...
6,267
37.691358
79
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/envs/__init__.py
"""Garage wrappers for gym environments.""" from garage.envs.env_spec import EnvSpec from garage.envs.garage_env import GarageEnv from garage.envs.grid_world_env import GridWorldEnv from garage.envs.multi_env_wrapper import MultiEnvWrapper from garage.envs.normalized_env import normalize from garage.envs.point_env imp...
589
25.818182
61
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/envs/env_spec.py
"""EnvSpec class.""" from garage import InOutSpec class EnvSpec(InOutSpec): """Describes the action and observation spaces of an environment. Args: observation_space (akro.Space): The observation space of the env. action_space (akro.Space): The action space of the env. """ def __in...
1,679
23
73
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/envs/garage_env.py
"""Wrapper class that converts gym.Env into GarageEnv.""" import copy import akro import gym from garage.envs.env_spec import EnvSpec # The gym environments using one of the packages in the following lists as # entry points don't close their viewer windows. KNOWN_GYM_NOT_CLOSE_VIEWER = [ # Please keep alphabeti...
7,503
35.784314
79
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/envs/grid_world_env.py
import gym import numpy as np from garage.envs.step import Step MAPS = { 'chain': ['GFFFFFFFFFFFFFSFFFFFFFFFFFFFG'], '4x4_safe': [ 'SFFF', 'FWFW', 'FFFW', 'WFFG' ], '4x4': [ 'SFFF', 'FHFH', 'FFFH', 'HFFG' ], '8x8': [ 'SFFF...
4,028
26.979167
77
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/envs/multi_env_wrapper.py
"""A wrapper env that handles multiple tasks from different envs. Useful while training multi-task reinforcement learning algorithms. It provides observations augmented with one-hot representation of tasks. """ import random import akro import gym import numpy as np from garage.envs.garage_env import GarageEnv de...
7,899
31.113821
79
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/envs/normalized_env.py
"""An environment wrapper that normalizes action, observation and reward.""" import akro import gym import gym.spaces import gym.spaces.utils import numpy as np from garage.envs import EnvSpec from garagei.envs.akro_wrapper import AkroWrapperTrait class NormalizedEnv(AkroWrapperTrait, gym.Wrapper): """An environ...
6,471
34.756906
79
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/envs/point_env.py
"""Simple 2D environment containing a point and a goal location.""" import gym import numpy as np from garage.envs.step import Step class PointEnv(gym.Env): """A simple 2D point environment. Attributes: observation_space (gym.spaces.Box): The observation space action_space (gym.spaces.Box): ...
4,375
29.601399
78
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/envs/step.py
"""Environment step data type.""" import collections def Step(observation, reward, done, **kwargs): # noqa: N802 """Create a namedtuple from the results of environment.step(action). Provides the option to put extra diagnostic info in the kwargs (if it exists) without demanding an explicit positional arg...
900
32.37037
76
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/envs/task_onehot_wrapper.py
"""Wrapper for appending one-hot task encodings to individual task envs. See `~TaskOnehotWrapper.wrap_env_list` for the main way of using this module. """ import akro import gym import numpy as np from garage.envs.env_spec import EnvSpec class TaskOnehotWrapper(gym.Wrapper): """Append a one-hot task representa...
5,737
32.952663
79
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/envs/dm_control/__init__.py
""" Wrappers for the DeepMind Control Suite. See https://github.com/deepmind/dm_control """ try: import dm_control # noqa: F401 except ImportError: raise ImportError("To use garage's dm_control wrappers, please install " 'garage[dm_control].') from garage.envs.dm_control.dm_control_view...
470
28.4375
76
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/envs/dm_control/dm_control_env.py
from dm_control import suite from dm_control.rl.control import flatten_observation from dm_env import StepType import gym import numpy as np from garage.envs import Step from garage.envs.dm_control.dm_control_viewer import DmControlViewer class DmControlEnv(gym.Env): """ Binding for `dm_control <https://arxi...
2,773
32.02381
79
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/envs/dm_control/dm_control_viewer.py
""" Wrapper for the dm_control viewer which allows single-stepping """ import dm_control.viewer.application as dm_viewer_app import glfw class DmControlViewer(dm_viewer_app.Application): def render(self): # Don't try to render into closed windows if not self._window._context: return ...
2,059
35.785714
151
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/envs/mujoco/__init__.py
"""Garage wrappers for mujoco based gym environments.""" try: import mujoco_py # noqa: F401 except Exception as e: raise e from garage.envs.mujoco.half_cheetah_dir_env import HalfCheetahDirEnv from garage.envs.mujoco.half_cheetah_vel_env import HalfCheetahVelEnv __all__ = [ 'HalfCheetahDirEnv', 'Half...
338
23.214286
69
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/envs/mujoco/half_cheetah_dir_env.py
"""Variant of the HalfCheetahEnv with different target directions.""" import numpy as np from garage.envs.mujoco.half_cheetah_env_meta_base import HalfCheetahEnvMetaBase # noqa: E501 class HalfCheetahDirEnv(HalfCheetahEnvMetaBase): """Half-cheetah environment with target direction, as described in [1]. The...
3,802
37.03
132
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/envs/mujoco/half_cheetah_env_meta_base.py
"""Base class of HalfCheetah meta-environments.""" from gym.envs.mujoco import HalfCheetahEnv as HalfCheetahEnv_ import numpy as np class HalfCheetahEnvMetaBase(HalfCheetahEnv_): """Base class of HalfCheetah meta-environments. Code is adapted from https://github.com/tristandeleu/pytorch-maml-rl/blob/493e...
2,020
29.164179
133
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/envs/mujoco/half_cheetah_vel_env.py
"""Variant of the HalfCheetahEnv with different target velocity.""" import numpy as np from garage.envs.mujoco.half_cheetah_env_meta_base import HalfCheetahEnvMetaBase # noqa: E501 class HalfCheetahVelEnv(HalfCheetahEnvMetaBase): """Half-cheetah environment with target velocity, as described in [1]. The co...
3,771
37.10101
126
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/envs/wrappers/__init__.py
"""gym.Env wrappers. Used to transform an environment in a modular way. It is also possible to apply multiple wrappers at the same time. Example: StackFrames(GrayScale(gym.make('env'))) """ from garage.envs.wrappers.atari_env import AtariEnv from garage.envs.wrappers.clip_reward import ClipReward from garage.env...
814
31.6
71
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/envs/wrappers/atari_env.py
"""Episodic life wrapper for gym.Env.""" import gym import numpy as np class AtariEnv(gym.Wrapper): """Atari environment wrapper for gym.Env. This wrapper convert the observations returned from baselines wrapped environment, which is a LazyFrames object into numpy arrays. Args: env (gym.Env)...
708
25.259259
73
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/envs/wrappers/clip_reward.py
"""Clip reward for gym.Env.""" import gym import numpy as np class ClipReward(gym.Wrapper): """Clip the reward by its sign.""" def step(self, ac): """gym.Env step function.""" obs, reward, done, info = self.env.step(ac) return obs, np.sign(reward), done, info def reset(self): ...
378
21.294118
51
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/envs/wrappers/episodic_life.py
"""Episodic life wrapper for gym.Env.""" import gym class EpisodicLife(gym.Wrapper): """Episodic life wrapper for gym.Env. This wrapper makes episode end when a life is lost, but only reset when all lives are lost. Args: env: The environment to be wrapped. """ def __init__(self, env...
1,112
24.883721
70
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/envs/wrappers/fire_reset.py
"""Fire reset wrapper for gym.Env.""" import gym class FireReset(gym.Wrapper): """Fire reset wrapper for gym.Env. Take action "fire" on reset. Args: env (gym.Env): The environment to be wrapped. """ def __init__(self, env): super().__init__(env) assert env.unwrapped.get_...
884
26.65625
68
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/envs/wrappers/grayscale.py
"""Grayscale wrapper for gym.Env.""" import warnings import gym import gym.spaces import numpy as np from skimage import color from skimage import img_as_ubyte class Grayscale(gym.Wrapper): """Grayscale wrapper for gym.Env, converting frames to grayscale. Only works with gym.spaces.Box environment with 2D R...
2,319
28.367089
78
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/envs/wrappers/max_and_skip.py
"""Max and Skip wrapper for gym.Env.""" import gym import numpy as np class MaxAndSkip(gym.Wrapper): """Max and skip wrapper for gym.Env. It returns only every `skip`-th frame. Action are repeated and rewards are sum for the skipped frames. It also takes element-wise maximum over the last two consec...
1,515
28.72549
79
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/envs/wrappers/noop.py
"""Noop wrapper for gym.Env.""" import gym import numpy as np class Noop(gym.Wrapper): """Noop wrapper for gym.Env. It samples initial states by taking random number of no-ops on reset. No-op is assumed to be action 0. Args: env (gym.Env): The environment to be wrapped. noop_max (int...
1,172
29.868421
78
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/envs/wrappers/resize.py
"""Resize wrapper for gym.Env.""" import warnings import gym import gym.spaces import numpy as np from skimage import img_as_ubyte from skimage.transform import resize class Resize(gym.Wrapper): """gym.Env wrapper for resizing frame to (width, height). Only works with gym.spaces.Box environment with 2D sing...
2,671
31.192771
79
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/envs/wrappers/stack_frames.py
"""Stack frames wrapper for gym.Env.""" from collections import deque import gym import gym.spaces import numpy as np class StackFrames(gym.Wrapper): """gym.Env wrapper to stack multiple frames. Useful for training feed-forward agents on dynamic games. Only works with gym.spaces.Box environment with 2D ...
2,228
28.72
77
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/experiment/__init__.py
"""Experiment functions.""" from garage.experiment.experiment import run_experiment from garage.experiment.experiment import to_local_command from garage.experiment.local_runner import LocalRunner from garage.experiment.local_tf_runner import LocalTFRunner from garage.experiment.meta_evaluator import MetaEvaluator from...
623
30.2
69
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/experiment/deterministic.py
"""Utilities for ensuring that experiments are deterministic.""" import random import sys import warnings import numpy as np seed_ = None seed_stream_ = None def set_seed(seed): """Set the process-wide random seed. Args: seed (int): A positive integer """ seed %= 4294967294 # pylint: d...
1,613
23.830769
77
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/experiment/experiment.py
"""Tools for running experiments with Garage.""" import base64 import collections import datetime import enum import functools import gc import inspect import json import os import os.path as osp import pathlib import pickle import re import subprocess import warnings import cloudpickle import dateutil.tz import dowel...
30,140
36.582294
113
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/experiment/experiment_wrapper.py
#!/usr/bin/env python3 """Run an experiment triggered by `run_experiment()` in `experiment.py`.""" import argparse import ast import base64 import datetime import gc import json import os import pathlib import sys import uuid import cloudpickle import dateutil.tz import dowel from dowel import logger import psutil im...
8,231
34.482759
79
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/experiment/local_runner.py
"""Provides algorithms with access to most of garage's features.""" import copy import os import time import cloudpickle from dowel import logger, tabular import psutil from garage.experiment.deterministic import get_seed, set_seed from garage.experiment.snapshotter import Snapshotter from garage.sampler import paral...
21,957
34.879085
79
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/experiment/local_tf_runner.py
"""The local runner for TensorFlow algorithms. A runner setup context for algorithms during initialization and pipelines data between sampler and algorithm during training. """ from dowel import logger import psutil from garage.experiment import LocalRunner from garage.sampler import DefaultWorker tf = False TFWorke...
8,263
36.058296
104
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/experiment/meta_evaluator.py
"""Evaluator which tests Meta-RL algorithms on test environments.""" from dowel import logger, tabular from garage import log_multitask_performance, TrajectoryBatch from garage.experiment.deterministic import get_seed from garage.sampler import DefaultWorker from garage.sampler import LocalSampler from garage.sampler...
5,196
42.672269
79
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/experiment/snapshotter.py
"""Defines SnapshotConfig and Snapshotter.""" import collections import errno import os import pathlib import cloudpickle import joblib SnapshotConfig = collections.namedtuple( 'SnapshotConfig', ['snapshot_dir', 'snapshot_mode', 'snapshot_gap']) class Snapshotter: """Snapshotter snapshots training data. ...
5,388
33.107595
79
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/experiment/task_sampler.py
"""Efficient and general interfaces for sampling tasks for Meta-RL.""" import abc import copy import math import numpy as np from garage.sampler.env_update import (ExistingEnvUpdate, NewEnvUpdate, SetTaskUpdate) def _sample_indices(n_to_sample, n_available_tasks, with_replacem...
7,992
34.683036
79
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/misc/__init__.py
0
0
0
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/misc/tensor_utils.py
"""Utiliy functions for tensors.""" import numpy as np import scipy.signal def discount_cumsum(x, discount): """Discounted cumulative sum. See https://docs.scipy.org/doc/scipy/reference/tutorial/signal.html#difference-equation-filtering # noqa: E501 Here, we have y[t] - discount*y[t+1] = x[t] or rev...
11,535
28.808786
115
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/np/__init__.py
"""Reinforcement Learning Algorithms which use NumPy as a numerical backend.""" from garage.np._functions import obtain_evaluation_samples from garage.np._functions import paths_to_tensors from garage.np._functions import samples_to_tensors __all__ = [ 'obtain_evaluation_samples', 'paths_to_tensors', 'samples_to_t...
330
35.777778
79
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/np/_functions.py
"""Utility functions for NumPy-based Reinforcement learning algorithms.""" import numpy as np from garage._dtypes import TrajectoryBatch from garage.misc import tensor_utils from garage.sampler.utils import rollout def samples_to_tensors(paths): """Return processed sample data based on the collected paths. ...
4,795
34.791045
79
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/np/algos/__init__.py
"""Reinforcement learning algorithms which use NumPy as a numerical backend.""" from garage.np.algos.cem import CEM from garage.np.algos.cma_es import CMAES from garage.np.algos.meta_rl_algorithm import MetaRLAlgorithm from garage.np.algos.nop import NOP from garage.np.algos.rl_algorithm import RLAlgorithm __all__ = [...
400
25.733333
79
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/np/algos/cem.py
"""Cross Entropy Method.""" import collections from dowel import logger, tabular import numpy as np from garage import log_performance, TrajectoryBatch from garage.np import paths_to_tensors from garage.np.algos.rl_algorithm import RLAlgorithm from garage.tf.samplers import BatchSampler class CEM(RLAlgorithm): ...
6,825
34.73822
78
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/np/algos/cma_es.py
"""Covariance Matrix Adaptation Evolution Strategy.""" import collections import cma from dowel import logger, tabular import numpy as np from garage import log_performance, TrajectoryBatch from garage.np import paths_to_tensors from garage.np.algos.rl_algorithm import RLAlgorithm from garage.tf.samplers import Batch...
5,339
33.230769
78
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/np/algos/meta_rl_algorithm.py
"""Interface of Meta-RL ALgorithms.""" import abc from garage.np.algos.rl_algorithm import RLAlgorithm class MetaRLAlgorithm(RLAlgorithm, abc.ABC): """Base class for Meta-RL Algorithms.""" @abc.abstractmethod def get_exploration_policy(self): """Return a policy used before adaptation to a specif...
1,387
32.047619
78
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/np/algos/nop.py
"""NOP (no optimization performed) policy search algorithm.""" from garage.np.algos.rl_algorithm import RLAlgorithm class NOP(RLAlgorithm): """NOP (no optimization performed) policy search algorithm.""" def init_opt(self): """Initialize the optimization procedure.""" def optimize_policy(self, pa...
798
27.535714
75
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/np/algos/rl_algorithm.py
"""Interface of RLAlgorithm.""" import abc class RLAlgorithm(abc.ABC): """Base class for all the algorithms. Note: If the field sampler_cls exists, it will be by LocalRunner.setup to initialize a sampler. """ # pylint: disable=too-few-public-methods @abc.abstractmethod def ...
646
23.884615
75
py
CSD-locomotion
CSD-locomotion-master/garaged/src/garage/np/baselines/__init__.py
"""Baselines (value functions) which use NumPy as a numerical backend.""" from garage.np.baselines.baseline import Baseline from garage.np.baselines.linear_feature_baseline import LinearFeatureBaseline from garage.np.baselines.linear_multi_feature_baseline import ( LinearMultiFeatureBaseline) from garage.np.baselin...
462
37.583333
77
py