Skip to content

A personal and educational deep reinforcement learning project in Python using TensorFlow and Keras. Includes a custom DQN agent library and notebooks covering Q-Learning and DQN.

License

Notifications You must be signed in to change notification settings

pabloramesc/dqn-lab

Repository files navigation

dqn-lab

A personal deep reinforcement learning project in Python using TensorFlow and Keras. Includes a custom DQN library and 4 examples demonstrating Q-Learning and DQN in various Gymnasium environments.

Description

The dqn package is a custom implementation of a Deep Q-Network (DQN) agent with utilities for:

  • Experience replay (uniform and prioritized)
  • Exploration policies (epsilon-greedy and boltzman)
  • Atari frame preprocessing and staking
  • Optimized DQN operations using TensorFlow compiled function: experiences are fetched from replay buffer in RAM, while processing, mini-batch formation and training is perform on GPU. Requires GPU with CUDA support and proper NVIDIA drivers. Follow this guide for installing TensorFlow with CUDA: https://www.tensorflow.org/install/pip

Examples

Taxi Q-Learning

Classic tabular Q-Learning for Taxi-v3 using NumPy. View example

CartPole DQN

DQN for CartPole-v1 using TensorFlow and Keras. View example

Key features:

  • Uses a simple feedforward neural network to approximate Q-values.
  • Utilizes DQNAgent class with an esilon-greedy policy.
  • Implements experience replay through ReplayBuffer class for stable learning.
  • Contains raw step-by-step DQN training loop.

Atari Vanilla DQN

DQN agent for Atari, based on the original Google DeepMind implementation. View example

Key features:

  • Employs Double-DQN for more stable learning.
  • Process game frames using convolutional neural networks (CNNs).
  • Utilizes frame stacking of 4 frames to capture movement.

Atari Rainbow DQN

Rainbow DQN agent for Atari that combines multiple enhancements to improve learning performance. View example

Key features:

  • Dueling Q-Networks to separately estimate state values and advantages.
  • Prioritized Experience Replay (PER) for more efficient learning.
  • N-step learning to propagate rewards faster.
  • Vectorized environments to accelerate training.

Installation

Clone the repository and install the dqn package and its dependencies:

git clone https://github.com/pabloramesc/dqn-lab.git
cd dqn-lab
pip install -e .
pip install -r requirements.txt

Running Examples

Run any example script from the project root:

python examples/taxi-qlearning.py

Make sure dqn package and all dependencies in requirements.txt are installed.

Note: To avoid using pre-trained models, delete or move the corresponding model files in the model folders.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

A personal and educational deep reinforcement learning project in Python using TensorFlow and Keras. Includes a custom DQN agent library and notebooks covering Q-Learning and DQN.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages