Skip to main content

TF-Agents: A Reinforcement Learning Library for TensorFlow

Project description

TF-Agents: A reliable, scalable and easy to use Reinforcement Learning library for TensorFlow.

TF-Agents makes designing, implementing and testing new RL algorithms easier, by providing well tested modular components that can be modified and extended. It enables fast code iteration, with good test integration and benchmarking.

To get started, we recommend checking out one of our Colab tutorials. If you need an intro to RL (or a quick recap), start here. Otherwise, check out our DQN tutorial to get an agent up and running in the Cartpole environment.

RELEASE: New 0.3.0rc0 release available.

NOTE: Current TF-Agents pre-release is under active development and interfaces may change at any time. Feel free to provide feedback and comments.

Table of contents

Multi-Armed Bandits


In TF-Agents, the core elements of RL algorithms are implemented as Agents. An agent encompasses two main responsibilities: defining a Policy to interact with the Environment, and how to learn/train that Policy from collected experience.

Currently the following algorithms are available under TF-Agents:


See tf_agents/colabs/ for tutorials on the major components provided.

Multi-Armed Bandits

The TF-Agents library contains also a Multi-Armed Bandits suite with a few environments and agents. RL agents can also be used on Bandit environments. For a tutorial, see tf_agents/bandits/colabs/bandits_tutorial.ipynb. For examples ready to run, see tf_agents/bandits/agents/examples/.


End-to-end examples training agents can be found under each agent directory. e.g.:


To install the latest version, use nightly builds of TF-Agents under the pip package tf-agents-nightly, which requires you install on one of tf-nightly and tf-nightly-gpu and also tfp-nightly. Nightly builds include newer features, but may be less stable than the versioned releases.

To install the nightly build version, run the following:

# Installing with the `--upgrade` flag ensures you'll get the latest version.
pip install --user --upgrade tf-agents-nightly  # depends on tf-nightly

If you clone the repository you will still need a tf-nightly installation. You can then run pip install -e .[tests] from the agents directory to get dependencies to run tests.


We're eager to collaborate with you! See for a guide on how to contribute. This project adheres to TensorFlow's code of conduct. By participating, you are expected to uphold this code.


This project adheres to Google's AI principles. By participating, using or contributing to this project you are expected to adhere to these principles.


If you use this code please cite it as:

  title = {{TF-Agents}: A library for Reinforcement Learning in TensorFlow},
  author = "{Sergio Guadarrama, Anoop Korattikara, Oscar Ramirez,
    Pablo Castro, Ethan Holly, Sam Fishman, Ke Wang, Ekaterina Gonina, Neal Wu,
    Efi Kokiopoulou, Luciano Sbaiz, Jamie Smith, Gábor Bartók, Jesse Berent,
    Chris Harris, Vincent Vanhoucke, Eugene Brevdo}",
  howpublished = {\url{}},
  url = "",
  year = 2018,
  note = "[Online; accessed 25-June-2019]"


This is not an official Google product.

Release history Release notifications | RSS feed

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for tf-agents-nightly, version 0.4.0.dev20191218
Filename, size File type Python version Upload date Hashes
Filename, size tf_agents_nightly-0.4.0.dev20191218-py2.py3-none-any.whl (849.0 kB) File type Wheel Python version py2.py3 Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page