TL;DR
Soft Actor-Critic (SAC) is a reinforcement learning algorithm for continuous actions. It trains a random policy to earn reward and to stay as random as possible, and it reuses past experience through a replay buffer. The entropy term keeps exploration going, and two value estimators keep training stable. On the harder continuous-control benchmarks, including the 21-dimensional Humanoid, SAC learned faster and reached higher returns than the off-policy DDPG, the on-policy PPO and soft Q-learning.
Builds on: Maximum Entropy Reinforcement Learning, Actor-Critic Methods, Experience Replay, Reparameterization Trick · Leads to: the SAC algorithm
Why it mattered
Before SAC, deep RL on robot-style control problems was expensive in samples and fragile in tuning. On-policy methods such as PPO discard each batch after a few updates, so they need many fresh rollouts. Off-policy methods such as DDPG can reuse data but often failed on the hardest tasks. SAC showed that one algorithm could reuse data, stay stable and explore well on these tasks, and it became a common baseline for continuous control in research and in robot learning.
Its maximum entropy idea also spread beyond this algorithm. Choosing the entropy weight, the temperature, became a central design question, and the 2018 follow-up by the same authors (arXiv 1812.05905) made that weight adjust itself during training, which removed one of the main hand-tuned settings.
The problem
The paper names two problems with deep RL that limit real use.
- Sample complexity. Many methods need a very large number of environment steps, even on simple tasks. On-policy methods throw data away after each update, so every step needs new experience.
- Brittleness. Learning rates, exploration constants and other settings must be tuned carefully, and small changes can make training fail.
Off-policy learning is the obvious cure for the first problem, since it reuses old data. But combining off-policy updates with neural function approximation is unstable, and the deterministic policies of DDPG explore poorly. SAC addresses both by making the policy stochastic, adding entropy to the objective so exploration is built in, and combining off-policy updates with two value estimators.
How it works
The walkthrough follows one update for one stored transition. The policy outputs a Gaussian with mean and standard deviation for a single action. The critics estimate the value of state-action pairs.
flowchart LR A[Act with the policy and store the transition] --> B[Replay buffer] B --> C[Sample a minibatch] C --> D[Update the value network] C --> E[Update the two Q-functions] C --> F[Update the policy] E --> G[Slowly move the target value network] D --> G
- Act and store. In state the policy samples an action and the environment returns reward and next state . The transition goes into the replay buffer. Check: the buffer grows with every step, so old transitions stay available for reuse.
- Sample a minibatch. Pick transitions from the buffer at random. This breaks the link between neighbouring steps, as in Experience Replay.
- Update the value network. Its target is the average over actions of . Say the sampled is and . The target is . Check: the entropy part raises the target when the policy is less certain, since is larger.
- Update the two Q-functions. The target is . With and , the target is . If , the squared error is . Check: the loss falls as moves toward . The same update is done for .
- Update the policy. Draw noise and form the action with and , which gives . The policy loss is . Say and the smaller Q is . The loss is . Check: gradient descent makes the policy favour actions with high , while the term stops it from collapsing onto one action.
- Move the target. The target value network follows the value network slowly. With smoothing , a value network output of and an old target of give a new target of .
Steps 3 to 6 run on gradient updates, and step 1 runs on every environment step. Each environment step is followed by one or more updates; how many is a hyperparameter.
The math
The objective is the sum of expected reward and expected policy entropy, weighted by a temperature :
The entropy measures how spread out the policy is over actions. A larger gives entropy more weight relative to reward. The reward scale and trade off against each other, so tuning one changes the balance set by the other.
Step 3 in symbols
The soft value network is trained to match the average over actions of :
Here is the replay buffer.
Step 4 in symbols
The Q-functions are trained toward the soft Bellman target, using a target value network :
The paper trains two Q-functions with parameters and . The policy update uses the smaller of their values, and this reduces the positive bias that value methods pick up from maximising over noisy estimates.
Step 5 in symbols
The policy is written as a deterministic transformation of noise, with drawn from a fixed distribution such as a standard normal. This is the Reparameterization Trick. The policy objective becomes
Because is a differentiable network, gradients flow through into the action. This is the same kind of gradient that DDPG uses for deterministic policies, now available for stochastic ones.
Step 6 in symbols
The target network moves by a moving average:
A value of near makes the target follow the value network closely, and a small makes it slow.
Worked examples
Reward , discount , and the next state's target value .
- Discounted next value: .
- Add the reward: .
- Target: .
- Interpretation: if the current Q-estimate is , the update pushes it up, with a squared error of .
Two actions are sampled for one state. The first has and . The second has and .
- First term: .
- Second term: .
- Average loss: .
- Interpretation: the first action has the lower term because its Q is higher, even though it is less probable under the policy. The part of each term is what keeps the policy from putting all its weight on the single highest-Q action.
Suppose a continuous-control task gives reward per step, the temperature is , and the policy's entropy for one action dimension is nats at each step. Take an episode of steps.
- Total reward: .
- Total entropy bonus: .
- Share of the objective from entropy: .
- If the reward were scaled by instead, the total reward would be and the entropy share would be .
- Interpretation: scaling the reward shrinks the entropy share, so the reward scale and the temperature must be tuned together for each environment.
Try it: the entropy term for one step is with and , and the reward for that step is . What share of the step's objective comes from entropy? Answer: , and the total is , so the share is .
Results
The paper evaluates on OpenAI Gym continuous-control tasks and on the rllab Humanoid task, which has 21 action dimensions. It compares SAC with DDPG, PPO and soft Q-learning, and reports evaluation return over training.
On the easier tasks, SAC performs about as well as the baselines. On the harder tasks, including Humanoid, it learns faster and reaches higher return. DDPG makes little or no progress on the hardest tasks. PPO needs far more environment steps to reach similar return, because it cannot reuse data. Soft Q-learning learns the tasks but more slowly.
The limits are clear from the paper. In the 2018 version the temperature is a hyperparameter tuned per environment, and the results are on simulated benchmarks, not on real robots. The follow-up paper addresses the temperature by adjusting it automatically.
Common mistakes and tradeoffs
It is tempting to think that SAC is simply DDPG with noise added. In fact the policy is trained to maximise entropy as well as value, the critic is a soft value function, and the policy update uses the smaller of two Q-functions. Adding exploration noise to a deterministic policy does not reproduce those properties.
It is tempting to think the entropy bonus is just an exploration trick that can be switched off once training is done. In fact the entropy term is part of the objective the policy is trained on. The deterministic policy used for evaluation is a separate choice made after training.
It is tempting to think a larger reward always helps learning. In fact the reward and the entropy term sit in one objective, so scaling the reward changes how much the entropy term matters. The two must be tuned together.
When to use SAC: continuous actions, expensive environment steps, and a need for off-policy reuse. When not to use it: discrete action spaces, where other methods are simpler. Alternatives include PPO when parallel simulation is cheap, and TD3, a deterministic off-policy method, when a simpler update is preferred.
Reading guide
Read the paper in this order, with the lessons that cover what each part needs.
- Introduction. Motivates sample efficiency and stability. Needs Reinforcement Learning.
- Related work. Covers off-policy actor-critics, DDPG and maximum entropy methods. Needs Policy Gradient, Q-Learning and Deep Deterministic Policy Gradient (DDPG).
- Preliminaries. Defines the maximum entropy objective. Needs Markov Decision Process, Maximum Entropy Reinforcement Learning and Entropy.
- Soft policy iteration. The derivation. Needs Bellman Equation and Maximum Entropy Reinforcement Learning.
- Soft Actor-Critic. The practical algorithm: value, Q, policy and target updates. Needs Actor-Critic Methods, Experience Replay, Reparameterization Trick and Double Q-Learning.
- Experiments. Benchmarks and comparisons. Needs Proximal Policy Optimization (PPO) for the on-policy baseline.
Check yourself
QuestionWhat does the entropy term in the SAC objective encourage, and why does that help learning?Show answer
It encourages the policy to stay spread out over actions. This keeps exploration going while the policy still earns reward, so the agent keeps trying actions it does not yet know well.
QuestionA critic target has reward , discount , and next-state target value . What is the target ?Show answer
The discounted next value is . The target is . The Q-estimate is pushed toward .
QuestionWhy does SAC use a reparameterized action when computing the policy gradient?Show answer
Because the action is a differentiable function of the noise and the policy parameters, the gradient of the Q-function with respect to the action can flow back into the policy. The paper notes that this gives a lower-variance estimator than the likelihood-ratio gradient.
QuestionA policy gives an action with . What is its policy loss term ?Show answer
The loss term is . Minimising it favours actions with high Q, and the part keeps the policy from becoming too concentrated.