Keras reinforcement learning agents you can train in Google Colab, starting with DQN.
Notebooks ready to run in the cloud
Need something like this? Let's talk →
About · Features · Notebooks · Contributing · To do · Contact
Train a deep reinforcement learning agent on your own task, using Keras code that is ready to run in Google Colab.
Note
Looking for the modern Keras 3 RL benchmark? Visit the active successor voaneves/snake-arena — comparing 14 RL algorithms in one vectorized NumPy simulator with 1,383 automated tests and 25 Colab/Kaggle notebooks. This repository remains preserved as the 2018–2023 TensorFlow/Keras notebook archive.
The project provides a Keras implementation of Deep Q-Networks that researchers and practitioners can use to train and evaluate agents on different environments. PPO and A2C are not implemented here yet; the only related code is the CartPole actor-critic notebook below.
- DQN in Keras:
models/dqn.py, with prioritized experience replay (sum tree), noisy dense layers and benchmarked variants undermodels/benchmarking_models/. - Google Colab ready: notebooks run in Colab, so you can experiment and train with cloud resources.
- Customizable and extensible: the code is designed to be modified and adapted to your own tasks.
actor_critic_cartpole.ipynb: an actor-critic agent on the CartPole environment, ready to open in Colab.snake-with-dqn-agent.ipynb: an introduction to the Snake game with a DQN agent. It points to the old SnakeAI repository, which became snake-on-pygame.
The notebooks/ folder also holds experiments from other projects. To train DQN locally on Snake, run python run_dqn.py (see the snake-on-pygame README).
Contributions are welcome. If you would like to add algorithms, improve existing implementations or help in any other way:
- Fork the repository.
- Create a new branch:
git checkout -b my-branch. - Make your changes and commit them:
git commit -m 'Add some feature'. - Push the changes to your fork:
git push origin my-branch. - Open a pull request and describe the changes you made.
- Improve the "Notebooks" section of this README.
- Review all notebooks to check which ones still work.
Released under the MIT License.