From 4ef9d15315baa338771215636a8ba077255a2271 Mon Sep 17 00:00:00 2001 From: Eric Liang Date: Sun, 8 Jul 2018 18:46:52 -0700 Subject: [PATCH] [rllib] Add concepts section of docs (#2373) This fills in the rllib concepts documentation. --- doc/source/index.rst | 1 + doc/source/rllib-concepts.rst | 27 +++++++++++++++++++++++++++ doc/source/rllib-env.rst | 2 +- doc/source/rllib.rst | 14 +++++++------- 4 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 doc/source/rllib-concepts.rst diff --git a/doc/source/index.rst b/doc/source/index.rst index f1b205f6c..14865b002 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -83,6 +83,7 @@ Ray comes with libraries that accelerate deep learning and reinforcement learnin rllib-env.rst rllib-algorithms.rst rllib-models.rst + rllib-concepts.rst rllib-package-ref.rst .. toctree:: diff --git a/doc/source/rllib-concepts.rst b/doc/source/rllib-concepts.rst new file mode 100644 index 000000000..9e9937c83 --- /dev/null +++ b/doc/source/rllib-concepts.rst @@ -0,0 +1,27 @@ +RLlib Concepts +============== + +.. note:: + + To learn more about these concepts, see also the `ICML paper `__. + +Policy Graphs +------------- + +Policy graph classes encapsulate the core numerical components of RL algorithms. This typically includes the policy model that determines actions to take, a trajectory postprocessor for experiences, and a loss function to improve the policy given postprocessed experiences. For a simple example, see the policy gradients `graph definition `__. + +Most interaction with deep learning frameworks is isolated to the `PolicyGraph interface `__, allowing RLlib to support multiple frameworks. To simplify the definition of policy graphs, RLlib includes `Tensorflow `__ and `PyTorch-specific `__ templates. + +Policy Evaluation +----------------- + +Given an environment and policy graph, policy evaluation produces `batches `__ of experiences. This is your classic "environment interaction loop". Efficient policy evaluation can be burdensome to get right, especially when leveraging vectorization, RNNs, or when operating in a multi-agent environment. RLlib provides a `PolicyEvaluator `__ class that manages all of this, and this class is used in most RLlib algorithm. + +You can also use policy evaluation standalone to produce batches of experiences. This can be done by calling ``ev.sample()`` on an evaluator instance, or ``ev.sample.remote()`` in parallel on evaluator instances created as Ray actors (see ``PolicyEvalutor.as_remote()``). + +Policy Optimization +------------------- + +Similar to how a `gradient-descent optimizer `__ can be used to improve a model, RLlib's `policy optimizers `__ implement different strategies for improving a policy graph. + +For example, in A3C you'd want to compute gradient asynchronously on different workers, and apply them to a central policy graph replica. This strategy is implemented by the `AsyncGradientsOptimizer `__. Another alternative is to gather experiences synchronously in parallel and optimize the model centrally, as in `SyncSamplesOptimizer `__. Policy optimizers abstract these strategies away into reusable modules. diff --git a/doc/source/rllib-env.rst b/doc/source/rllib-env.rst index 20e6eed3b..95f6b088e 100644 --- a/doc/source/rllib-env.rst +++ b/doc/source/rllib-env.rst @@ -19,7 +19,7 @@ In the high-level agent APIs, environments are identified with string names. By register_env("my_env", env_creator) ray.init() - trainer = ppo.PPOAgent(env="my-env", config={ + trainer = ppo.PPOAgent(env="my_env", config={ "env_config": {}, # config to pass to env creator }) diff --git a/doc/source/rllib.rst b/doc/source/rllib.rst index 7316fc127..1e1d0d915 100644 --- a/doc/source/rllib.rst +++ b/doc/source/rllib.rst @@ -34,7 +34,7 @@ Environments ------------ * `RLlib Environments Overview `__ * `OpenAI Gym `__ -* `Vectorized (Batch) `__ +* `Vectorized `__ * `Multi-Agent `__ * `Serving (Agent-oriented) `__ * `Offline Data Ingest `__ @@ -51,17 +51,17 @@ Algorithms * `Proximal Policy Optimization `__ Models and Preprocessors -------------------------------- +------------------------ * `RLlib Models and Preprocessors Overview `__ * `Built-in Models and Preprocessors `__ * `Custom Models `__ * `Custom Preprocessors `__ -RL Building Blocks ------------------- -* Policy Models, Losses, Postprocessing -* Policy Evaluation -* Policy Optimization +RLlib Concepts +-------------- +* `Policy Graphs `__ +* `Policy Evaluation `__ +* `Policy Optimization `__ Package Reference -----------------