Skip to content

Commit

Permalink
Update to Python 3.8, and use AutoROM in chapter 18
Browse files Browse the repository at this point in the history
  • Loading branch information
ageron committed Oct 17, 2021
1 parent 47208a5 commit 3289b05
Show file tree
Hide file tree
Showing 3 changed files with 112 additions and 88 deletions.
34 changes: 31 additions & 3 deletions 18_reinforcement_learning.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,7 @@
"\n",
"if IS_COLAB or IS_KAGGLE:\n",
" !apt update && apt install -y libpq-dev libsdl2-dev swig xorg-dev xvfb\n",
" %pip install -q -U tf-agents pyvirtualdisplay gym[box2d]\n",
" %pip install -q -U atari_py==0.2.5\n",
" %pip install -q -U tf-agents pyvirtualdisplay gym[box2d,atari,accept-rom-license]\n",
"\n",
"# Scikit-Learn ≥0.20 is required\n",
"import sklearn\n",
Expand Down Expand Up @@ -2181,6 +2180,35 @@
"Let's use TF-Agents to create an agent that will learn to play Breakout. We will use the Deep Q-Learning algorithm, so you can easily compare the components with the previous implementation, but TF-Agents implements many other (and more sophisticated) algorithms!"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"First, we need to download and install the Atari ROMs. This can be done very easily using the `AutoROM` tool, if you accept the license:"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"AutoROM will download the Atari 2600 ROMs.\n",
"They will be installed to:\n",
"\t/Users/ageron/miniconda3/envs/tf2/lib/python3.8/site-packages/AutoROM/roms\n",
"\n",
"Existing ROMs will be overwritten.\n",
"Done! \n"
]
}
],
"source": [
"!{sys.prefix}/bin/AutoROM --quiet --accept-license"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -4387,7 +4415,7 @@
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.10"
"version": "3.8.12"
}
},
"nbformat": 4,
Expand Down
89 changes: 46 additions & 43 deletions environment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,52 +3,55 @@ channels:
- conda-forge
- defaults
dependencies:
- atari_py=0.2.6 # used only in chapter 18
- box2d-py=2.3 # used only in chapter 18
- ftfy=6.0 # used only in chapter 16 by the transformers library
- graphviz # used only in chapter 6 for dot files
- gym=0.19 # used only in chapter 18
- ipython=7.28 # a powerful Python shell
- ipywidgets=7.6 # optionally used only in chapter 12 for tqdm in Jupyter
- joblib=0.14 # used only in chapter 2 to save/load Scikit-Learn models
- jupyter=1.0 # to edit and run Jupyter notebooks
- matplotlib=3.4 # beautiful plots. See tutorial tools_matplotlib.ipynb
- nbdime=3.1 # optional tool to diff Jupyter notebooks
- nltk=3.6 # optionally used in chapter 3, exercise 4
- numexpr=2.7 # used only in the Pandas tutorial for numerical expressions
- numpy=1.19 # Powerful n-dimensional arrays and numerical computing tools
- opencv=4.5 # used only in chapter 18 by TF Agents for image preprocessing
- pandas=1.3 # data analysis and manipulation tool
- pillow=8.3 # image manipulation library, (used by matplotlib.image.imread)
- pip # Python's package-management system
- py-xgboost=1.4 # used only in chapter 7 for optimized Gradient Boosting
- pyglet=1.5 # used only in chapter 18 to render environments
- pyopengl=3.1 # used only in chapter 18 to render environments
- python=3.7 # Python! Not using latest version as some libs lack support
- python-graphviz # used only in chapter 6 for dot files
# - pyvirtualdisplay=2.2 # used only in chapter 18 if on headless server
- requests=2.26 # used only in chapter 19 for REST API queries
- scikit-learn=1.0 # machine learning library
- scipy=1.7 # scientific/technical computing library
- tqdm=4.62 # a progress bar library
- wheel # built-package format for pip
- widgetsnbextension=3.5 # interactive HTML widgets for Jupyter notebooks
- atari_py=0.2 # used only in chapter 18
- box2d-py=2.3 # used only in chapter 18
- ftfy=6.0 # used only in chapter 16 by the transformers library
- graphviz # used only in chapter 6 for dot files
- gym=0.19 # used only in chapter 18
- ipython=7.28 # a powerful Python shell
- ipywidgets=7.6 # optionally used only in chapter 12 for tqdm in Jupyter
- joblib=0.14 # used only in chapter 2 to save/load Scikit-Learn models
- jupyter=1.0 # to edit and run Jupyter notebooks
- matplotlib=3.4 # beautiful plots. See tutorial tools_matplotlib.ipynb
- nbdime=3.1 # optional tool to diff Jupyter notebooks
- nltk=3.6 # optionally used in chapter 3, exercise 4
- numexpr=2.7 # used only in the Pandas tutorial for numerical expressions
- numpy=1.19 # Powerful n-dimensional arrays and numerical computing tools
- opencv=4.5 # used only in chapter 18 by TF Agents for image preprocessing
- pandas=1.3 # data analysis and manipulation tool
- pillow=8.3 # image manipulation library, (used by matplotlib.image.imread)
- pip # Python's package-management system
- py-xgboost=1.4 # used only in chapter 7 for optimized Gradient Boosting
- pyglet=1.5 # used only in chapter 18 to render environments
- pyopengl=3.1 # used only in chapter 18 to render environments
- python=3.8 # Python! Not using latest version as some libs lack support
- python-graphviz # used only in chapter 6 for dot files
#- pyvirtualdisplay=2.2 # used only in chapter 18 if on headless server
- requests=2.26 # used only in chapter 19 for REST API queries
- scikit-learn=1.0 # machine learning library
- scipy=1.7 # scientific/technical computing library
- tqdm=4.62 # a progress bar library
- wheel # built-package format for pip
- widgetsnbextension=3.5 # interactive HTML widgets for Jupyter notebooks
- pip:
- tensorboard-plugin-profile==2.5.0 # profiling plugin for TensorBoard
- tensorboard==2.6.0 # TensorFlow's visualization toolkit
- tensorflow-addons==0.14.0 # used only in chapter 16 for a seq2seq impl.
- tensorflow-datasets==4.4.0 # datasets repository, ready to use
- tensorflow-hub==0.12.0 # trained ML models repository, ready to use
- tensorflow-probability==0.14.1 # Optional. Probability/Stats lib.
- tensorflow-serving-api==2.6.0 # or tensorflow-serving-api-gpu if gpu
- tensorflow==2.6.0 # Deep Learning library
- tf-agents==0.10.0 # Reinforcement Learning lib based on TensorFlow
- tfx==1.3.0 # platform to deploy production ML pipelines
- transformers==4.11.3 # Natural Language Processing lib for TF or PyTorch
- urlextract==1.4.0 # optionally used in chapter 3, exercise 4
- tensorboard-plugin-profile~=2.5.0 # profiling plugin for TensorBoard
- tensorboard~=2.7.0 # TensorFlow's visualization toolkit
- tensorflow-addons~=0.14.0 # used only in chapter 16 for a seq2seq impl.
- tensorflow-datasets~=4.4.0 # datasets repository, ready to use
- tensorflow-hub~=0.12.0 # trained ML models repository, ready to use
- tensorflow-probability~=0.14.1 # Optional. Probability/Stats lib.
- tensorflow-serving-api~=2.6.0 # or tensorflow-serving-api-gpu if gpu
- tensorflow~=2.6.0 # Deep Learning library
- tf-agents~=0.10.0 # Reinforcement Learning lib based on TensorFlow
- tfx~=1.3.0 # platform to deploy production ML pipelines
- transformers~=4.11.3 # Natural Language Processing lib for TF or PyTorch
- urlextract~=1.4.0 # optionally used in chapter 3, exercise 4
- ale-py~=0.7.2 # used only in chapter 18
- AutoROM~=0.4.2 # used only in chapter 18

# Specific lib versions to avoid conflicts
- attrs=20.3
- click=7.1
- packaging=20.9
- six=1.15
- typing-extensions=3.7

77 changes: 35 additions & 42 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@


##### Core scientific packages
jupyter==1.0.0
matplotlib==3.4.3
numpy==1.19.5
pandas==1.3.3
scipy==1.7.1
jupyter~=1.0.0
matplotlib~=3.4.3
numpy~=1.19.5
pandas~=1.3.3
scipy~=1.7.1

##### Machine Learning packages
scikit-learn==1.0
scikit-learn~=1.0

# Optional: the XGBoost library is only used in chapter 7
xgboost==1.4.2
xgboost~=1.4.2

# Optional: the transformers library is only using in chapter 16
transformers==4.11.3
transformers~=4.11.3

##### TensorFlow-related packages

Expand All @@ -27,70 +27,63 @@ transformers==4.11.3
# you must install CUDA, cuDNN and more: see tensorflow.org for the detailed
# installation instructions.

tensorflow==2.6.0
tensorflow~=2.6.0
# Optional: the TF Serving API library is just needed for chapter 19.
tensorflow-serving-api==2.6.0 # or tensorflow-serving-api-gpu if gpu
tensorflow-serving-api~=2.6.0 # or tensorflow-serving-api-gpu if gpu

tensorboard==2.6.0
tensorboard-plugin-profile==2.5.0
tensorflow-datasets==4.4.0
tensorflow-hub==0.12.0
tensorflow-probability==0.14.1
tensorboard~=2.7.0
tensorboard-plugin-profile~=2.5.0
tensorflow-datasets~=4.4.0
tensorflow-hub~=0.12.0
tensorflow-probability~=0.14.1

# Optional: only used in chapter 13.
# NOT AVAILABLE ON WINDOWS
tfx==1.3.0
tfx~=1.3.0

# Optional: only used in chapter 16.
# NOT AVAILABLE ON WINDOWS
tensorflow-addons==0.14.0
tensorflow-addons~=0.14.0

##### Reinforcement Learning library (chapter 18)

# There are a few dependencies you need to install first, check out:
# https://github.com/openai/gym#installing-everything
gym[Box2D]==0.21.0
atari-py==0.2.5
gym[Box2D,atari,accept-rom-license]~=0.21.0

# On Windows, install atari_py using:
# pip install --no-index -f https://github.com/Kojoley/atari-py/releases atari_py

tf-agents==0.10.0
tf-agents~=0.10.0
ale-py~=0.7.2

##### Image manipulation
Pillow==8.3.2
graphviz==0.17
opencv-python==4.5.3.56
pyglet==1.5.21
Pillow~=8.4.0
graphviz~=0.17
opencv-python~=4.5.3.56
pyglet~=1.5.21

#pyvirtualdisplay # needed in chapter 16, if on a headless server
#pyvirtualdisplay # needed in chapter 18, if on a headless server
# (i.e., without screen, e.g., Colab or VM)


##### Additional utilities

# Efficient jobs (caching, parallelism, persistence)
joblib==0.14.1
joblib~=0.14.1

# Easy http requests
requests==2.26.0
requests~=2.26.0

# Nice utility to diff Jupyter Notebooks.
nbdime==3.1.0
nbdime~=3.1.0

# May be useful with Pandas for complex "where" clauses (e.g., Pandas
# tutorial).
numexpr==2.7.3
numexpr~=2.7.3

# Optional: these libraries can be useful in the classification chapter,
# exercise 4.
nltk==3.6.3
urlextract==1.4.0
# Optional: these libraries can be useful in the chapter 3, exercise 4.
nltk~=3.6.5
urlextract~=1.4.0

# Optional: these libraries are only used in chapter 16
ftfy==6.0.3
ftfy~=6.0.3

# Optional: tqdm displays nice progress bars, ipywidgets for tqdm's notebook support
tqdm==4.62.3
ipywidgets==7.6.5

tqdm~=4.62.3
ipywidgets~=7.6.5

0 comments on commit 3289b05

Please sign in to comment.