Papers · Reinforcement learning and alignment · 2018

Soft Actor-Critic: Off-Policy Maximum Entropy Deep Reinforcement Learning with a Stochastic Actor

Tuomas Haarnoja, Aurick Zhou, Pieter Abbeel and others

The notation of the SAC paper, explained: its 21 displayed equations, then every symbol it uses, grouped by category and shown the way the paper writes it.

Read the paper on arXiv

Reading this paper

Soft actor-critic: an off-policy reinforcement-learning method that maximizes reward plus the entropy of the policy, which keeps exploration going and makes training stable.

α\alpha is the temperature, weighing the entropy H(π(⋅∣st))\mathcal{H}(\pi(\cdot \mid \mathbf{s}_t)) against the reward. ρπ\rho_\pi is the distribution of states and actions the policy visits, and D\mathcal{D} the replay buffer. Subscripts name the parameters of each network: VψV_\psi, QθQ_\theta, πϕ\pi_\phi; the barred ψˉ\bar{\psi} is a slowly updated copy of ψ\psi, the target network.

Read from arXiv's HTML version: 21 displayed equations and 91 pieces of inline math. 58 symbols and constructs from the catalog, read as reinforcement learning.

The paper's displayed equations

Open any of them in the decoder for a symbol-by-symbol reading.

  1. (1)
    J(π)=∑t=0TE⁡(st,at)∼ρπ[r(st,at)+αH(π( ⋅ ∣st))].J(\pi)=\sum_{t=0}^{T}\operatorname{\mathbb{E}}_{({\mathbf{s}_{t}},{\mathbf{a}_{t}})\sim\rho_{\pi}}\left[r({\mathbf{s}_{t}},{\mathbf{a}_{t}})+\alpha\mathcal{H}(\pi({\,\cdot\,}|{\mathbf{s}_{t}}))\right].
    Decode →
  2. (2)
    TπQ(st,at)≜r(st,at)+γE⁡st+1∼p[V(st+1)],\mathcal{T}^{\pi}Q({\mathbf{s}_{t}},{\mathbf{a}_{t}})\triangleq r({\mathbf{s}_{t}},{\mathbf{a}_{t}})+\gamma\operatorname{\mathbb{E}}_{{\mathbf{s}_{t+1}}\sim p}\left[V({\mathbf{s}_{t+1}})\right],
    Decode →
  3. (3)
    V(st)=E⁡at∼π[Q(st,at)−log⁡π(at∣st)]V({\mathbf{s}_{t}})=\operatorname{\mathbb{E}}_{{\mathbf{a}_{t}}\sim\pi}\left[Q({\mathbf{s}_{t}},{\mathbf{a}_{t}})-\log\pi({\mathbf{a}_{t}}|{\mathbf{s}_{t}})\right]
    Decode →
  4. (4)
    πnew=arg⁡min⁡π′∈ΠDKL(π′( ⋅ ∣st)  ∥  exp⁡(Qπold(st, ⋅ ))Zπold(st)).\pi_{\mathrm{new}}=\arg\underset{\pi^{\prime}\in\Pi}{\min}\mathrm{D_{KL}}\left(\pi^{\prime}({\,\cdot\,}|{\mathbf{s}_{t}})\;\middle\|\;\frac{\exp\left(Q^{\pi_{\mathrm{old}}}({\mathbf{s}_{t}},{\,\cdot\,})\right)}{Z^{\pi_{\mathrm{old}}}({\mathbf{s}_{t}})}\right).
    Decode →
  5. (5)
    JV(ψ)=E⁡st∼D[12(Vψ(st)−E⁡at∼πϕ[Qθ(st,at)−log⁡πϕ(at∣st)])2] J_{V}({\psi})=\operatorname{\mathbb{E}}_{{\mathbf{s}_{t}}\sim\mathcal{D}}\left[\frac{1}{2}\left(V_{\psi}({\mathbf{s}_{t}})-\operatorname{\mathbb{E}}_{{\mathbf{a}_{t}}\sim\pi_{\phi}}\left[Q_{\theta}({\mathbf{s}_{t}},{\mathbf{a}_{t}})-\log\pi_{\phi}({\mathbf{a}_{t}}|{\mathbf{s}_{t}})\right]\right)^{2}\right]\,
    Decode →
  6. (6)
    ∇^ψJV(ψ)=∇ψVψ(st)(Vψ(st)−Qθ(st,at)+log⁡πϕ(at∣st)),\hat{\nabla}_{\psi}J_{V}({\psi})=\nabla_{\psi}V_{\psi}({\mathbf{s}_{t}})\left(V_{\psi}({\mathbf{s}_{t}})-Q_{\theta}({\mathbf{s}_{t}},{\mathbf{a}_{t}})+\log\pi_{\phi}({\mathbf{a}_{t}}|{\mathbf{s}_{t}})\right),
    Decode →
  7. (7)
    JQ(θ)=E⁡(st,at)∼D[12(Qθ(st,at)−Q^(st,at))2],J_{Q}(\theta)=\operatorname{\mathbb{E}}_{({\mathbf{s}_{t}},{\mathbf{a}_{t}})\sim\mathcal{D}}\left[\frac{1}{2}\left(Q_{\theta}({\mathbf{s}_{t}},{\mathbf{a}_{t}})-\hat{Q}({\mathbf{s}_{t}},{\mathbf{a}_{t}})\right)^{2}\right],
    Decode →
  8. (8)
    Q^(st,at)=r(st,at)+γE⁡st+1∼p[Vψˉ(st+1)],\hat{Q}({\mathbf{s}_{t}},{\mathbf{a}_{t}})=r({\mathbf{s}_{t}},{\mathbf{a}_{t}})+\gamma\operatorname{\mathbb{E}}_{{\mathbf{s}_{t+1}}\sim p}\left[V_{\bar{\psi}}({\mathbf{s}_{t+1}})\right],
    Decode →
  9. (9)
    ∇^θJQ(θ)=∇θQθ(at,st)(Qθ(st,at)−r(st,at)−γVψˉ(st+1)).\hat{\nabla}_{\theta}J_{Q}(\theta)=\nabla_{\theta}Q_{\theta}({\mathbf{a}_{t}},{\mathbf{s}_{t}})\left(Q_{\theta}({\mathbf{s}_{t}},{\mathbf{a}_{t}})-r({\mathbf{s}_{t}},{\mathbf{a}_{t}})-\gamma V_{\bar{\psi}}({\mathbf{s}_{t+1}})\right).
    Decode →
  10. (10)
    Jπ(ϕ)=E⁡st∼D[DKL(πϕ( ⋅ ∣st)  ∥  exp⁡(Qθ(st, ⋅ ))Zθ(st))].J_{\pi}({\phi})=\operatorname{\mathbb{E}}_{{\mathbf{s}_{t}}\sim\mathcal{D}}\left[\mathrm{D_{KL}}\left(\pi_{\phi}({\,\cdot\,}|{\mathbf{s}_{t}})\;\middle\|\;\frac{\exp\left(Q_{\theta}({\mathbf{s}_{t}},{\,\cdot\,})\right)}{Z_{\theta}({\mathbf{s}_{t}})}\right)\right].
    Decode →
  11. (11)
    at=fϕ(ϵt;st),{\mathbf{a}_{t}}=f_{\phi}(\epsilon_{t};{\mathbf{s}_{t}}),
    Decode →
  12. (12)
    Jπ(ϕ)=E⁡st∼D,ϵt∼N[log⁡πϕ(fϕ(ϵt;st)∣st)−Qθ(st,fϕ(ϵt;st))],J_{\pi}({\phi})=\operatorname{\mathbb{E}}_{{\mathbf{s}_{t}}\sim\mathcal{D},\epsilon_{t}\sim\mathcal{N}}\left[\log\pi_{\phi}(f_{\phi}(\epsilon_{t};{\mathbf{s}_{t}})|{\mathbf{s}_{t}})-Q_{\theta}({\mathbf{s}_{t}},f_{\phi}(\epsilon_{t};{\mathbf{s}_{t}}))\right],
    Decode →

Famous equations in this paper

Symbols, by category

Most used first. The examples are written as the paper writes them.

Notation conventions

  1. st\mathbf{s}_{t}, at\mathbf{a}_{t}, ρπ\rho_{\pi}

    Subscript (index or label) 356 uses

    A subscript picks an element (xᵢ), a time step (h_t), a named copy (W_q), or the parameters (p_θ).

  2. Tπ\mathcal{T}^{\pi}, QπoldQ^{\pi_{\mathrm{old}}}, ZπoldZ^{\pi_{\mathrm{old}}}

    Superscript (power or label) 55 uses

    Usually a power (x² = x·x), but a capital or a word up there is often just a label (W^Q).

  3. ZZ, ff, ll

    Italic letters (variables) 28 uses

    A plain italic letter is a variable; conventions say what kind (x input, y target, W weights…).

  4. π∗\pi^{*}

    Star (optimal) 12 uses

    As a superscript, the optimal value: θ* is the best θ. Between two terms, convolution.

  5. H\mathcal{H}, T\mathcal{T}

    Calligraphic letters 10 uses

    A script capital usually names a set, a space, a distribution or a loss.

  6. ∇^\hat{\nabla}, Q^\hat{Q}

    Hat (estimate) 8 uses

    A hat marks an estimate or prediction: ŷ is the model’s guess for y.

  7. D\mathcal{D}

    Dataset (𝒟) 7 uses

    The dataset: usually N input-label pairs.

  8. ψˉ\bar{\psi}

    Bar (mean) 7 uses

    A bar usually marks an average: x̄ is the mean of the x values.

Greek letters

  1. π\pi, Π\Pi

    Pi 146 uses

    A policy π(a | s) in reinforcement learning, or the constant 3.14159…

  2. ϕ\phi

    Phi 29 uses

    The parameters of a second model (often the encoder q_φ), or a feature map φ(x).

  3. ψ\psi

    Psi 22 uses

    The parameters of a third network (after θ and φ), a feature map, or the digamma function ψ(x).

  4. θ\theta

    Theta 21 uses

    The model’s parameters: all of its weights and biases, as one collection.

  5. τ\tau

    Tau 13 uses

    A temperature that sharpens or flattens a softmax; in RL, a trajectory.

  6. γ\gamma

    Gamma 9 uses

    The discount factor in reinforcement learning, or the learned scale in normalization layers.

  7. ρ\rho

    Rho 7 uses

    A correlation coefficient, a decay rate (RMSprop, Adadelta), or an importance ratio in RL.

  8. ϵ\epsilon

    Epsilon 7 uses

    A tiny constant for numerical safety (10⁻⁸ in Adam), or noise ε ~ 𝒩(0, I).

  9. α\alpha

    Alpha 5 uses

    Often a learning rate or step size; also attention weights αᵢⱼ or a mixing weight.

  10. μ\mu

    Mu 3 uses

    A mean: the average of a distribution, a batch, or a layer’s features.

  11. λ\lambda

    Lambda 3 uses

    Usually the strength of a regularization term; also eigenvalues.

Vectors and matrices

  1. s\mathbf{s}, a\mathbf{a}, u\mathbf{u}

    Bold lowercase (vector) 222 uses

    A bold lowercase letter is a vector: a list of numbers.

  2. ⋅\cdot

    Centre dot 16 uses

    A dot product between vectors, plain multiplication between numbers, or an empty slot f(·).

  3. ×\times

    Times (cross) 11 uses

    Usually the “by” in a shape (n × d); also plain multiplication or a cross product.

  4. ∣A∣|\mathcal{A}|

    Absolute value (bars) 8 uses

    Absolute value of a number; for a set, its size; for a matrix, sometimes its determinant.

  5. α−1\alpha^{-1}

    Inverse 2 uses

    The matrix inverse, A⁻¹A = I; for a function, its inverse function; for a number, 1/x.

  6. det⁡\det

    Determinant 1 use

    A number from a square matrix: how much it scales volume. Zero means it is not invertible.

  7. diag\mathrm{diag}

    Diag 1 use

    Build a diagonal matrix from a vector, or pull out the diagonal of a matrix.

Calculus and gradients

  1. ∇\nabla, ∇ψ\nabla_{\psi}, ∇θ\nabla_{\theta}

    Nabla (gradient) 12 uses

    The gradient: the vector of partial derivatives. ∇_θ L is how the loss changes with each parameter.

  2. ∞\infty

    Infinity 12 uses

    Infinity; as a norm subscript, ‖x‖_∞ is the largest absolute entry.

  3. π′\pi^{\prime}

    Prime 6 uses

    Either a derivative, f′(x), or simply "another one": x′ is a second sample, s′ the next state.

  4. d\mathrm{d}

    Derivative (d/dx) 3 uses

    An ordinary derivative: the rate of change of one quantity with respect to one variable.

Probability and statistics

  1. ∣|

    Given (conditional bar) 32 uses

    “Given”: p(y | x) is the probability of y given that x is known.

  2. ∼\sim

    Distributed as (tilde) 25 uses

    “Is drawn from” or “is distributed as”: x ~ p means x is a sample from the distribution p.

  3. log⁡\log

    Logarithm 16 uses

    A logarithm, almost always the natural log (base e) in ML papers.

  4. pp

    Probability p(x) 10 uses

    A probability or probability density; p is usually the true or model distribution, q an approximation.

  5. ;;

    Semicolon (parameterized by) 5 uses

    In p(x; θ), the semicolon separates the variable x from fixed parameters θ.

  6. ∥\|

    KL divergence 3 uses

    How different distribution q is from p. Zero when they match; not symmetric.

  7. exp⁡\exp

    Exponential 3 uses

    The exponential function eˣ, with e ≈ 2.718. Always positive.

  8. N\mathcal{N}

    Normal distribution 1 use

    The normal (Gaussian) distribution with the given mean and variance.

Functions and operators

  1. ::, →\rightarrow

    Arrow (maps to) 13 uses

    Maps to (f: X → Y), tends to (x → 0), or implies (⇒).

  2. ←\leftarrow

    Assignment arrow 6 uses

    Assignment in an algorithm: replace the variable on the left with the value on the right.

  3. ∑t=0T\sum_{t=0}^{T}, ∑t=0∞\sum_{t=0}^{\infty}, ∑l=t∞\sum_{l=t}^{\infty}

    Summation 5 uses

    Add up the expression for every value of the index, from the bottom limit to the top.

  4. 12\frac{1}{2}

    Fraction 5 uses

    Division: the top divided by the bottom.

  5. tanh⁡\tanh

    Hyperbolic tangent 5 uses

    An S-shaped activation squashing any number into (−1, 1).

  6. min⁡\min, min\mathrm{min}, max\mathrm{max}

    Max and min 3 uses

    The largest (or smallest) value, over the arguments or over the range in the subscript.

  7. arg⁡min⁡π′∈Π\arg\min_{\pi^{\prime}\in\Pi}

    Argmin 2 uses

    The input that makes the function smallest: θ* = argmin L(θ) is the best parameter setting.

Reinforcement learning

  1. QQ

    Action-value function Q 52 uses

    Q(s, a) is the expected total reward from taking action a in state s, then following the policy.

  2. S\mathcal{S}, A\mathcal{A}

    State and action spaces 35 uses

    𝒮 is the set of all states and 𝒜 the set of all actions in a Markov decision process.

  3. JJ

    Objective J 19 uses

    J(θ) is the objective: the quantity to maximize, such as the expected return of a policy.

  4. rr

    Reward r 16 uses

    rₜ is the reward received at step t; R(s, a) is the reward function that hands it out.

  5. VV

    Value function V 16 uses

    V(s) is how much total discounted reward to expect from state s onward.

Sets, shapes and definitions

  1. ∈\in

    Element of 24 uses

    “Is in” or “belongs to”: x ∈ S says x is a member of the set S.

  2. ≤\leq, ≥\geq, <<

    Inequalities 18 uses

    Less than / greater than (or equal). ≪ means “much smaller than”.

  3. R\mathbb{R}

    Real numbers (ℝ) and shapes 3 uses

    The real numbers. ℝⁿˣᵈ is the set of n × d arrays of reals: it states a shape.

  4. ≜\triangleq

    Defined as (≜) 2 uses

    “Is defined as”: the same as :=. Introduces notation; it is not a claim to check.

  5. {1,2}\{1,2\}

    Set braces 2 uses

    A set: a collection of items. {x | condition} is every x that satisfies the condition.

  6. ∪\cup

    Union and intersection 1 use

    Union ∪: in either set. Intersection ∩: in both.

  7. ≠\neq

    Not equal 1 use

    The two sides are different.

  8. RD\mathbb{R}^{D}

    Tensor shapes 1 use

    ℝ with a superscript of sizes joined by × declares an array’s shape: ℝ^{B×T×d} is a 3-axis tensor.

3 things the catalog has no entry for yet
  • E⁡\operatorname{\mathbb{E}} \mathbb{E} 20
  • DKL\mathrm{D_{KL}} D_{KL} 3
  • arg⁡\arg \arg 1

Formulas from arXiv's HTML version of the paper, © their authors; the explanations are this site's. Title and authors as arXiv lists them.

More reinforcement learning and alignment papers