Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
Vashisht Madhavan committed Jan 12, 2018
0 parents commit 65ed224
Show file tree
Hide file tree
Showing 34 changed files with 6,322 additions and 0 deletions.
8 changes: 8 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
*.DS_Store
__pycache__/
env/
*.pyc
*.pkl
*.p
mujoco/mjpro131
*.h5
43 changes: 43 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
deep-neuroevolution
Copyright (c) 2018 Uber Technologies, Inc.

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.

deep-neuroevolution includes:

evolution-strategies-starter
Copyright (c) 2016 OpenAI (http://openai.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
78 changes: 78 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
## AI Labs Neuroevolution Algorithms

This repo contains distributed implementations of the algorithms described in:

[1] [Deep Neuroevolution: Genetic Algorithms Are a Competitive Alternative for Training Deep Neural Networks for Reinforcement Learning](https://arxiv.org/abs/1712.06567)

[2] [Improving Exploration in Evolution Strategies for Deep Reinforcement Learning via a Population of Novelty-Seeking Agents](https://arxiv.org/abs/1712.06560)

Our code is based off of code from OpenAI, who we thank. The original code and related paper from OpenAI can be found here. The repo has been modified to run both ES and our algorithms, including our Deep Genetic Algorithm (DeepGA) locally and on AWS.

Note: The Humanoid experiment depends on [Mujoco](http://www.mujoco.org/). Please provide your own Mujoco license and binary

The blog post describing these papers can be found [here](https://eng.uber.com/deep-neuroevolution/)

## How to run locally

clone repo

```
git clone https://github.com/uber-common/deep-neuroevolution.git
```

create python3 virtual env

```
python3 -m venv env
. env/bin/activate
```

install requirements
```
pip install -r requirements.txt
```
If you plan to use the mujoco env, make sure to follow [mujoco-py](https://github.com/openai/mujoco-py)'s readme about how to install mujoco correctly

launch redis
```
. scripts/local_run_redis.sh
```

launch sample ES experiment
```
. scripts/local_run_exp.sh es configurations/frostbite_es.json # For the Atari game Frostbite
. scripts/local_run_exp.sh es configurations/humanoid.json # For the MuJoCo Humanoid-v1 environment
```

launch sample NS-ES experiment
```
. scripts/local_run_exp.sh ns-es configurations/frostbite_nses.json
. scripts/local_run_exp.sh ns-es configurations/humanoid_nses.json
```

launch sample NSR-ES experiment
```
. scripts/local_run_exp.sh nsr-es configurations/frostbite_nsres.json
. scripts/local_run_exp.sh nsr-es configurations/humanoid_nsres.json
```

launch sample GA experiment
```
. scripts/local_run_exp.sh ga configurations/frostbite_ga.json # For the Atari game Frostbite
```

launch sample Random Search experiment
```
. scripts/local_run_exp.sh rs configurations/frostbite_ga.json # For the Atari game Frostbite
```


visualize results by running a policy file
```
python -m scripts.viz 'FrostbiteNoFrameskip-v4' <YOUR_H5_FILE>
python -m scripts.viz 'Humanoid-v1' <YOUR_H5_FILE>
```

### extra folder
The extra folder holds the XML specification file for the Humanoid
Locomotion with Deceptive Trap domain used in https://arxiv.org/abs/1712.06560. Use this XML file in gym to recreate the environment.
24 changes: 24 additions & 0 deletions configurations/frostbite_es.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
{
"config": {
"calc_obstat_prob": 0.0,
"episodes_per_batch": 5000,
"eval_prob": 0.01,
"l2coeff": 0.005,
"noise_stdev": 0.005,
"snapshot_freq": 20,
"timesteps_per_batch": 10000,
"return_proc_mode": "centered_rank",
"episode_cutoff_mode": 5000
},
"env_id": "FrostbiteNoFrameskip-v4",
"optimizer": {
"args": {
"stepsize": 0.01
},
"type": "adam"
},
"policy": {
"args" : {},
"type": "ESAtariPolicy"
}
}
22 changes: 22 additions & 0 deletions configurations/frostbite_ga.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{
"config": {
"calc_obstat_prob": 0.0,
"episodes_per_batch": 5000,
"eval_prob": 0.01,
"l2coeff": 0.005,
"noise_stdev": 0.005,
"snapshot_freq": 20,
"timesteps_per_batch": 10000,
"return_proc_mode": "centered_rank",
"episode_cutoff_mode": 5000
},
"population_size": 10,
"num_elites": 1,
"env_id": "FrostbiteNoFrameskip-v4",
"policy": {
"args" : {
"nonlin_type": "relu"
},
"type": "GAAtariPolicy"
}
}
31 changes: 31 additions & 0 deletions configurations/frostbite_nses.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"config": {
"calc_obstat_prob": 0.0,
"episodes_per_batch": 100,
"eval_prob": 0.03,
"l2coeff": 0.005,
"noise_stdev": 0.02,
"snapshot_freq": 10,
"timesteps_per_batch": 1000,
"return_proc_mode": "centered_sign_rank",
"episode_cutoff_mode": 5000
},
"env_id": "FrostbiteNoFrameskip-v4",
"algo_type": "ns",
"novelty_search": {
"k": 10,
"population_size": 3,
"num_rollouts": 1,
"selection_method": "novelty_prob"
},
"optimizer": {
"args": {
"stepsize": 0.01
},
"type": "adam"
},
"policy": {
"args": {},
"type": "ESAtariPolicy"
}
}
31 changes: 31 additions & 0 deletions configurations/frostbite_nsres.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
{
"config": {
"calc_obstat_prob": 0.0,
"episodes_per_batch": 1000,
"eval_prob": 0.1,
"l2coeff": 0.005,
"noise_stdev": 0.02,
"snapshot_freq": 10,
"timesteps_per_batch": 10000,
"return_proc_mode": "centered_sign_rank",
"episode_cutoff_mode": 5000
},
"env_id": "FrostbiteNoFrameskip-v4",
"algo_type": "nsr",
"novelty_search": {
"k": 10,
"population_size": 3,
"num_rollouts": 1,
"selection_method": "novelty_prob"
},
"optimizer": {
"args": {
"stepsize": 0.01
},
"type": "adam"
},
"policy": {
"args": {},
"type": "ESAtariPolicy"
}
}
34 changes: 34 additions & 0 deletions configurations/humanoid.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
{
"config": {
"calc_obstat_prob": 0.01,
"episodes_per_batch": 1000,
"eval_prob": 0.03,
"l2coeff": 0.005,
"noise_stdev": 0.02,
"snapshot_freq": 10,
"timesteps_per_batch": 100000,
"return_proc_mode": "centered_rank",
"episode_cutoff_mode": "env_default"
},
"env_id": "Humanoid-v1",
"exp_prefix": "humanoid",
"optimizer": {
"args": {
"stepsize": 0.01
},
"type": "adam"
},
"policy": {
"args": {
"ac_bins": "continuous:",
"ac_noise_std": 0.01,
"connection_type": "ff",
"hidden_dims": [
256,
256
],
"nonlin_type": "tanh"
},
"type": "MujocoPolicy"
}
}
41 changes: 41 additions & 0 deletions configurations/humanoid_nses.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"config": {
"calc_obstat_prob": 0.01,
"episodes_per_batch": 1000,
"eval_prob": 0.03,
"l2coeff": 0.005,
"noise_stdev": 0.02,
"snapshot_freq": 10,
"timesteps_per_batch": 100000,
"return_proc_mode": "centered_sign_rank",
"episode_cutoff_mode": "env_default"
},
"env_id": "Humanoid-v1",
"algo_type": "ns",
"exp_prefix": "humanoid",
"novelty_search": {
"k": 10,
"population_size": 5,
"num_rollouts": 5,
"selection_method": "novelty_prob"
},
"optimizer": {
"args": {
"stepsize": 0.01
},
"type": "adam"
},
"policy": {
"args": {
"ac_bins": "continuous:",
"ac_noise_std": 0.01,
"connection_type": "ff",
"hidden_dims": [
256,
256
],
"nonlin_type": "tanh"
},
"type": "MujocoPolicy"
}
}
41 changes: 41 additions & 0 deletions configurations/humanoid_nsres.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
{
"config": {
"calc_obstat_prob": 0.01,
"episodes_per_batch": 1000,
"eval_prob": 0.03,
"l2coeff": 0.005,
"noise_stdev": 0.02,
"snapshot_freq": 10,
"timesteps_per_batch": 100000,
"return_proc_mode": "centered_sign_rank",
"episode_cutoff_mode": "env_default"
},
"env_id": "Humanoid-v1",
"algo_type": "nsr",
"exp_prefix": "humanoid",
"novelty_search": {
"k": 10,
"population_size": 5,
"num_rollouts": 5,
"selection_method": "novelty_prob"
},
"optimizer": {
"args": {
"stepsize": 0.01
},
"type": "adam"
},
"policy": {
"args": {
"ac_bins": "continuous:",
"ac_noise_std": 0.01,
"connection_type": "ff",
"hidden_dims": [
256,
256
],
"nonlin_type": "tanh"
},
"type": "MujocoPolicy"
}
}
Empty file added es_distributed/__init__.py
Empty file.
Loading

0 comments on commit 65ed224

Please sign in to comment.