1
0
mirror of https://github.com/gryf/coach.git synced 2025-12-18 11:40:18 +01:00
Files
coach/docs_raw/source/components/agents/policy_optimization/td3.rst
Gal Leibovich 7eb884c5b2 TD3 (#338)
2019-06-16 11:11:21 +03:00

2.7 KiB
Raw Blame History

Actions space: Continuous

References: Addressing Function Approximation Error in Actor-Critic Methods

Network Structure

/_static/img/design_imgs/td3.png

Algorithm Description

Choosing an action

Pass the current states through the actor network, and get an action mean vector μ. While in training phase, use a continuous exploration policy, such as a small zero-meaned gaussian noise, to add exploration noise to the action. When testing, use the mean vector μ as-is.

Training the network

Start by sampling a batch of transitions from the experience replay.

  • To train the two critic networks, use the following targets:

    yt=r(st,at)+γmini=1,2Qi(st+1,μ(st+1)+[N(0,σ2)]MAX_NOISEMIN_NOISE)

    First run the actor target network, using the next states as the inputs, and get μ(st+1). Then, add a clipped gaussian noise to these actions, and clip the resulting actions to the actions space. Next, run the critic target networks using the next states and μ(st+1)+[N(0,σ2)]MAX_NOISEMIN_NOISE, and use the minimum between the two critic networks predictions in order to calculate yt according to the equation above. To train the networks, use the current states and actions as the inputs, and yt as the targets.

  • To train the actor network, use the following equation:

    θμJ ≈ Estρβ[∇aQ1(s,a)|s=st,a=μ(st)⋅∇θμμ(s)|s=st]

    Use the actor's online network to get the action mean values using the current states as the inputs. Then, use the first critic's online network in order to get the gradients of the critic output with respect to the action mean values aQ1(s,a)|s=st,a=μ(st). Using the chain rule, calculate the gradients of the actor's output, with respect to the actor weights, given aQ(s,a). Finally, apply those gradients to the actor network.

    The actor's training is done at a slower frequency than the critic's training, in order to allow the critic to better fit the current policy, before exercising the critic in order to train the actor. Following the same, delayed, actor's training cadence, do a soft update of the critic and actor target networks' weights from the online networks.