TensorFlow Agents

Reinforcement Learning with TensorFlow

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 tutorials.

Installation

TF-Agents publishes nightly and stable builds. For a list of releases read the Releases section. The commands below cover installing TF-Agents stable and nightly from pypi.org as well as from a GitHub clone.

:warning: If using Reverb (replay buffer), which is very common, TF-Agents will only work with Linux.

Stable

Run the commands below to install the most recent stable release. API documentation for the release is on tensorflow.org.

$pipinstall--usertf-agents[reverb]
# Use keras-2
$exportTF_USE_LEGACY_KERAS=1
# Use this tag get the matching examples and colabs.
$gitclonehttps://github.com/tensorflow/agents.git
$cdagents
$gitcheckoutv0.19.0

If you want to install TF-Agents with versions of Tensorflow or Reverb that are flagged as not compatible by the pip dependency check, use the following pattern below at your own risk.

$pipinstall--usertensorflow
$pipinstall--usertf-keras
$pipinstall--userdm-reverb
$pipinstall--usertf-agents

If you want to use TF-Agents with TensorFlow 1.15 or 2.0, install version 0.3.0:

# Newer versions of tensorflow-probability require newer versions of TensorFlow.
$pipinstalltensorflow-probability==0.8.0
$pipinstalltf-agents==0.3.0

Nightly

Nightly builds include newer features, but may be less stable than the versioned releases. The nightly build is pushed as tf-agents-nightly. We suggest installing nightly versions of TensorFlow (tf-nightly) and TensorFlow Probability (tfp-nightly) as those are the versions TF-Agents nightly are tested against.

To install the nightly build version, run the following:

# Use keras-2
$exportTF_USE_LEGACY_KERAS=1
# `--force-reinstall helps guarantee the right versions.
$pipinstall--user--force-reinstalltf-nightly
$pipinstall--user--force-reinstalltf-keras-nightly
$pipinstall--user--force-reinstalltfp-nightly
$pipinstall--user--force-reinstalldm-reverb-nightly
# Installing with the `--upgrade` flag ensures you'll get the latest version.
$pipinstall--user--upgradetf-agents-nightly

From GitHub

After cloning the repository, the dependencies can be installed by running pip install -e .[tests]. TensorFlow needs to be installed independently: pip install --user tf-nightly.

Contributing

We're eager to collaborate with you! See CONTRIBUTING.md 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.

Releases

TF Agents has stable and nightly releases. The nightly releases are often fine but can have issues due to upstream libraries being in flux. The table below lists the version(s) of TensorFlow that align with each TF Agents' release. Release versions of interest:

  • 0.19.0 supports tensorflow-2.15.0.
  • 0.18.0 dropped Python 3.8 support.
  • 0.16.0 is the first version to support Python 3.11.
  • 0.15.0 is the last release compatible with Python 3.7.
  • If using numpy < 1.19, then use TF-Agents 0.15.0 or earlier.
  • 0.9.0 is the last release compatible with Python 3.6.
  • 0.3.0 is the last release compatible with Python 2.x.
Release Branch / Tag TensorFlow Version dm-reverb Version
Nightly master tf-nightly dm-reverb-nightly
0.19.0 v0.19.0 2.15.0 0.14.0
0.18.0 v0.18.0 2.14.0 0.13.0
0.17.0 v0.17.0 2.13.0 0.12.0
0.16.0 v0.16.0 2.12.0 0.11.0
0.15.0 v0.15.0 2.11.0 0.10.0
0.14.0 v0.14.0 2.10.0 0.9.0
0.13.0 v0.13.0 2.9.0 0.8.0
0.12.0 v0.12.0 2.8.0 0.7.0
0.11.0 v0.11.0 2.7.0 0.6.0
0.10.0 v0.10.0 2.6.0
0.9.0 v0.9.0 2.6.0
0.8.0 v0.8.0 2.5.0
0.7.1 v0.7.1 2.4.0
0.6.0 v0.6.0 2.3.0
0.5.0 v0.5.0 2.2.0
0.4.0 v0.4.0 2.1.0
0.3.0 v0.3.0 1.15.0 and 2.0.0.

Principles

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

Citation

If you use this code, please cite it as:

@misc{TFAgents,
title={{TF-Agents}:AlibraryforReinforcementLearninginTensorFlow},
author={SergioGuadarramaandAnoopKorattikaraandOscarRamirezand
PabloCastroandEthanHollyandSamFishmanandKeWangand
EkaterinaGoninaandNealWuandEfiKokiopoulouandLucianoSbaizand
JamieSmithandGáborBartókandJesseBerentandChrisHarrisand
VincentVanhouckeandEugeneBrevdo},
howpublished={\url{https://github.com/tensorflow/agents} },
url="https://github.com/tensorflow/agents",
year=2018,
note="[Online; accessed 25-June-2019]"
}

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2023年12月21日 UTC.