Guide · Open source
How to use deep-learning-with-python-notebooks: run the book's code
Updated · written with AI from the project's own documentation and checked against our catalogue data
deep-learning-with-python-notebooks is an open-source repository by François Chollet of Jupyter notebooks that implement the code samples from the book Deep Learning with Python. It is meant for readers who want to run the book's examples hands-on. This guide shows you how to open the notebooks, choose a runtime and backend, handle Kaggle data, and read the chapter list so you can work through the book's code.
Quick start
- 1Open a chapter on Colab. Pick a chapter from the README table of contents and open its notebook link in Colab. The README recommends Colab because it provides a hosted runtime with the dependencies.
- 2Select a runtime. Use Runtime -> Change runtime type to choose a GPU. The default free tier GPU is sufficient for all code in the book, according to the README.
- 3Set the Keras backend. In the top cell, set os.environ["KERAS_BACKEND"] to jax, tensorflow or torch before importing Keras.
- 4Add Kaggle credentials if needed. For chapters that use Kaggle data, log in with kagglehub.login() or save KAGGLE_USERNAME and KAGGLE_KEY as Colab secrets.
- 5Run the cells in order. Run the notebook top to bottom. If you change the backend, restart the session with Runtime -> Restart Session and rerun the cells.
- 6Read alongside the book. Follow the explanations in your copy of Deep Learning with Python, since the notebooks omit all text, figures and pseudocode.
What the repository contains
The repository holds Jupyter notebooks for the code samples in Deep Learning with Python, third edition (2025) by Francois Chollet and Matthew Watson. Legacy notebooks for the second and first editions are also included.
To keep the notebooks readable, they contain only runnable code blocks and section titles. Text paragraphs, figures and pseudocode from the book are left out, so the book is needed to understand what the code does.
- Third edition notebooks: the current code samples, one notebook per chapter
- Legacy notebooks: second edition (2021) and first edition (2017)
- Licence: MIT
Run the notebooks on Colab or locally
The README recommends running the notebooks on Colab, which provides a hosted runtime with the dependencies you need. You can also run them locally, either by setting up your own Jupyter environment or by following Colab's instructions for running locally.
By default the notebooks run on Colab's free tier GPU runtime, which the README says is sufficient for all code in the book. Chapters 8 to 18 benefit from a faster GPU if you have a Colab Pro subscription. To change the runtime type, use Runtime -> Change runtime type in Colab's menus.
git clone https://github.com/fchollet/deep-learning-with-python-notebooksChoose a Keras 3 backend
The third edition code is written with Keras 3, which can run on JAX, TensorFlow or PyTorch. To pick one, edit the cell at the top of the Colab notebook that sets the backend environment variable.
The backend must be set once per session, before Keras is imported. If you change it mid-session, restart the session with Runtime -> Restart Session and rerun the relevant cells.
import os
os.environ["KERAS_BACKEND"] = "jax"Set up Kaggle access for chapters that need it
Some chapters use datasets and model weights from Kaggle. The README says you need a Kaggle login for these; instructions are given in Chapter 8. You can log in once per session when you reach the cell with kagglehub.login(), or store your credentials once as Colab secrets.
For the secrets route, sign in at kaggle.com, generate a Kaggle API key from the settings page, open the secrets tab in Colab with the key icon, and add two secrets named KAGGLE_USERNAME and KAGGLE_KEY. You then need to allow each notebook to access those secrets when running Kaggle code.
Find the chapter you need
The README table of contents links each chapter to its notebook on Colab. Chapters cover the mathematical building blocks of neural networks, frameworks, classification and regression, machine learning fundamentals, a deep dive on Keras, image classification and segmentation, object detection, time series, text classification, transformers, text and image generation, and best practices.
Work through the chapters alongside your copy of the book, since the notebooks do not contain its explanations.
- Chapter 2: The mathematical building blocks of neural networks
- Chapter 3: Introduction to TensorFlow, PyTorch, JAX, and Keras
- Chapter 8: Image Classification
- Chapter 13: Timeseries Forecasting
- Chapter 14: Text Classification
- Chapter 18: Best practices for the real world
What people use it for
- Running the third edition code samples chapter by chapter alongside the book
- Comparing the same model code under the JAX, TensorFlow and PyTorch backends in Keras 3
- Training image classification or segmentation models using the notebooks for chapters 8 to 12
- Working through time-series forecasting or text classification notebooks as coursework
Frequently asked questions
Is deep-learning-with-python-notebooks free to use?
The repository is released under the MIT licence, as listed on its page. The README says the notebooks run on Colab's free tier GPU, though a Colab Pro subscription may speed up chapters 8 to 18.
Do I need to buy the book to use these notebooks?
The README says to read the notebooks side by side with your copy of the book. The notebooks contain only code and section titles, so the book's text and explanations are needed to follow along.
How do I install deep-learning-with-python-notebooks?
The README lists a git clone command for the repository. It also recommends Colab, which needs no local setup, and points to Colab's instructions for running locally. The README does not list other prerequisites.
Why does my notebook say the Kaggle login failed?
Chapters that use Kaggle data require a Kaggle login. Log in with kagglehub.login() in the notebook cell, or add KAGGLE_USERNAME and KAGGLE_KEY as Colab secrets and allow the notebook to access them. The README points to Chapter 8 for instructions.
Can I switch between JAX, TensorFlow and PyTorch?
Yes. The third edition code uses Keras 3, which supports these backends. Set KERAS_BACKEND in the top cell before importing Keras, and restart the session if you change it later.
How does this compare to the Keras examples or d2l.ai?
This repository is companion code for one book, so it follows that book's chapter order. Keras examples, fast.ai course notebooks and d2l.ai (Dive into Deep Learning) are other options that are also built around notebooks, and you can pick based on whether you want a book companion or a standalone course.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
Choose this repository if you own Deep Learning with Python and want to run its code in order, or if you want hands-on Keras 3 notebooks on your choice of backend. Pick a standalone course such as fast.ai or d2l.ai if you need explanations inside the notebooks themselves, since these notebooks omit the text.
Install options & downloads