Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: dependencies in notebook examples #149

Merged
merged 3 commits into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ mkdocs:
# Optionally declare the Python requirements required to build your docs
python:
install:
- requirements: requirements.txt
- requirements: docs/requirements.txt
- method: pip
path: .
- requirements: requirements.txt
- requirements: docs/requirements.txt
1 change: 0 additions & 1 deletion environment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,5 @@ dependencies:
- conda>=4.9.2
- pip:
- --find-links https://storage.googleapis.com/jax-releases/jax_releases.html
- jaxlib==0.3.15
- -r requirements.txt
- -r requirements-dev.txt
8 changes: 7 additions & 1 deletion examples/cmame.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,13 @@
"except:\n",
" !pip install --no-deps git+https://github.com/deepmind/chex.git@v0.1.3 |tail -n 1\n",
" import chex\n",
" \n",
"\n",
"try:\n",
" import jumanji\n",
"except:\n",
" !pip install \"jumanji==0.2.2\"\n",
" import jumanji\n",
"\n",
"try:\n",
" import qdax\n",
"except:\n",
Expand Down
8 changes: 7 additions & 1 deletion examples/cmamega.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,13 @@
"except:\n",
" !pip install --no-deps git+https://github.com/deepmind/chex.git@v0.1.3 |tail -n 1\n",
" import chex\n",
" \n",
"\n",
"try:\n",
" import jumanji\n",
"except:\n",
" !pip install \"jumanji==0.2.2\"\n",
" import jumanji\n",
"\n",
"try:\n",
" import qdax\n",
"except:\n",
Expand Down
8 changes: 7 additions & 1 deletion examples/dads.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,16 @@
"try:\n",
" import brax\n",
"except:\n",
" !pip install git+https://github.com/google/brax.git@v0.0.15 |tail -n 1\n",
" !pip install git+https://github.com/google/brax.git@v0.1.2 |tail -n 1\n",
" import brax\n",
"\n",
"try:\n",
" import jumanji\n",
"except:\n",
" !pip install \"jumanji==0.2.2\"\n",
" import jumanji\n",
"\n",
"try:\n",
" import haiku\n",
"except:\n",
" !pip install git+https://github.com/deepmind/dm-haiku.git@v0.0.5 |tail -n 1\n",
Expand Down
8 changes: 7 additions & 1 deletion examples/diayn.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -45,10 +45,16 @@
"try:\n",
" import brax\n",
"except:\n",
" !pip install git+https://github.com/google/brax.git@v0.0.15 |tail -n 1\n",
" !pip install git+https://github.com/google/brax.git@v0.1.2 |tail -n 1\n",
" import brax\n",
"\n",
"try:\n",
" import jumanji\n",
"except:\n",
" !pip install \"jumanji==0.2.2\"\n",
" import jumanji\n",
"\n",
"try:\n",
" import haiku\n",
"except:\n",
" !pip install git+https://github.com/deepmind/dm-haiku.git@v0.0.5 |tail -n 1\n",
Expand Down
140 changes: 29 additions & 111 deletions examples/distributed_mapelites.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,14 @@
"cells": [
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"metadata": {},
"source": [
"[![Open In Colab](https://colab.research.google.com/assets/colab-badge.svg)](https://colab.research.google.com/github/adaptive-intelligent-robotics/QDax/blob/main/examples/distributed_mapelites.ipynb)"
]
},
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"metadata": {},
"source": [
"# Optimizing with MAP-Elites in Jax (multi-devices example)\n",
"\n",
Expand All @@ -34,11 +26,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"metadata": {},
"outputs": [],
"source": [
"#@title Installs and Imports\n",
Expand All @@ -61,10 +49,16 @@
"try:\n",
" import brax\n",
"except:\n",
" !pip install git+https://github.com/google/brax.git@v0.0.15 |tail -n 1\n",
" !pip install git+https://github.com/google/brax.git@v0.1.2 |tail -n 1\n",
" import brax\n",
"\n",
"try:\n",
" import jumanji\n",
"except:\n",
" !pip install \"jumanji==0.2.2\"\n",
" import jumanji\n",
"\n",
"try:\n",
" import qdax\n",
"except:\n",
" !pip install --no-deps git+https://github.com/adaptive-intelligent-robotics/QDax@main |tail -n 1\n",
Expand Down Expand Up @@ -93,34 +87,22 @@
},
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"metadata": {},
"source": [
"## Setup and get devices"
]
},
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"metadata": {},
"source": [
"Setup the default platform where the MAP-Elites will be stored and MAP-Elite updates will happen. "
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"metadata": {},
"outputs": [],
"source": [
"default_device = 'cpu'\n",
Expand All @@ -130,11 +112,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"metadata": {},
"outputs": [],
"source": [
"# Get devices (change gpu by tpu if needed)\n",
Expand All @@ -146,23 +124,15 @@
},
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"metadata": {},
"source": [
"## Setup run parameters"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"metadata": {},
"outputs": [],
"source": [
"#@title QD Training Definitions Fields\n",
Expand All @@ -185,11 +155,7 @@
},
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"metadata": {},
"source": [
"## Init environment, policy, population params, init states of the env\n",
"\n",
Expand All @@ -199,11 +165,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"metadata": {},
"outputs": [],
"source": [
"%%time\n",
Expand Down Expand Up @@ -237,11 +199,7 @@
},
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"metadata": {},
"source": [
"## Define the way the policy interacts with the env\n",
"\n",
Expand All @@ -251,11 +209,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"metadata": {},
"outputs": [],
"source": [
"# Define the fonction to play a step with the policy in the environment\n",
Expand Down Expand Up @@ -289,11 +243,7 @@
},
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"metadata": {},
"source": [
"## Define the scoring function and the way metrics are computed\n",
"\n",
Expand All @@ -303,11 +253,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"metadata": {},
"outputs": [],
"source": [
"# Prepare the scoring function\n",
Expand All @@ -332,11 +278,7 @@
},
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"metadata": {},
"source": [
"## Define the emitter\n",
"\n",
Expand All @@ -346,11 +288,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"metadata": {},
"outputs": [],
"source": [
"# Define emitter\n",
Expand All @@ -367,23 +305,15 @@
},
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"metadata": {},
"source": [
"## Instantiate and initialise the MAP Elites algorithm"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"metadata": {},
"outputs": [],
"source": [
"%%time\n",
Expand Down Expand Up @@ -423,23 +353,15 @@
},
{
"cell_type": "markdown",
"metadata": {
"pycharm": {
"name": "#%% md\n"
}
},
"metadata": {},
"source": [
"## Launch MAP-Elites iterations"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"metadata": {},
"outputs": [],
"source": [
"log_period = 10\n",
Expand Down Expand Up @@ -493,11 +415,7 @@
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"pycharm": {
"name": "#%%\n"
}
},
"metadata": {},
"outputs": [],
"source": [
"# Get the repertoire from the first device\n",
Expand Down
Loading
Loading