TL;DR
Soft Actor-Critic (SAC) learns two things at once: a policy that chooses actions, and critics that estimate how good those actions are. The policy is trained to earn reward while staying as random as the temperature setting allows. Because the method reuses old experience from a replay buffer, it is off-policy and sample efficient, and it works well on continuous control tasks such as robot joints.
It combines three ideas: the maximum entropy objective, the Actor-Critic Methods split between policy and value, and the Reparameterization Trick for differentiating through sampled actions. Its temperature is adjusted during training so that the policy keeps a chosen amount of randomness.
Where you'll see it: in robot locomotion and manipulation experiments, in simulated control benchmarks, and as a default baseline for continuous-action RL.
Intuition
A learner who keeps options open
Picture a robot learning to reach a cup. Early on, several arm motions look promising. A policy that commits to the first one that works will often stop improving, and a small disturbance such as a bumped table can knock it off course. A policy that keeps a spread of good motions can recover from a bump, and it keeps testing alternatives as it learns.
SAC builds this into training. Each action is scored by the reward it earns plus a bonus for the entropy of the policy at that state. The bonus is a price on certainty, set by a number called the temperature. A high price keeps the policy broad, and a low price lets it sharpen onto the best known motion.
Why it is off-policy
A method is off-policy when it learns from data that was not produced by its current policy. SAC stores every transition in a replay buffer (see Experience Replay) and samples mini-batches from it. The critics learn from old data, which makes each environment step much more useful than in on-policy methods that discard data after one update. The critic can learn from old data without any correction because it scores one specific action, and only the next action in the target is drawn from the current policy.
flowchart LR A[Environment step] --> B[Replay buffer] B --> C[Sample a mini-batch] C --> D[Update two soft Q critics] C --> E[Update the stochastic policy] D --> E E --> F[Adjust temperature alpha] F --> A
The math
The objective
SAC optimises the maximum entropy objective from maximum entropy RL. The policy has parameters . The soft action value has parameters , and the temperature sets the value of entropy. The soft state value is
The term is the surprise of the sampled action, and its average under the policy is the Entropy of the policy at . So is the expected action value plus the entropy bonus.
The critic
The critics are trained to satisfy the soft Bellman equation with a target network. Given a transition , the target is
Here is the discount factor, and denotes the target networks. Two critics are trained, and the minimum of their estimates is used in the target. Taking the smaller of two estimates counters the tendency of a single learned value to be too optimistic, the same overestimation problem that double Q-Learning addresses. Each critic is then regressed toward by squared error.
The target networks are updated slowly, as a moving average of the live critics, with a small number such as 0.005. This keeps the regression target from moving with every update.
The actor and the reparameterization
The policy is updated to minimise
The action is written as a deterministic function of the state and a noise sample, with . This is the reparameterization trick: the randomness sits in , so the gradient of the loss can flow through the action into the policy's parameters. The squashes the action into a bounded range, such as the torque limits of a motor.
Squashing changes the density, so the log-probability is corrected. If is the pre-squash sample and , then
summed over the action dimensions .
The temperature
Rather than fix , SAC can tune it so the policy's entropy stays near a target , commonly set to minus the number of action dimensions. The temperature loss is
When the policy is more random than the target, the gradient pushes down, and when it is too narrow, the gradient pushes up.
Worked examples
A state has two actions with equal probability , and their soft values are . Take , reward and discount .
- Expected action value: .
- Entropy term: for each action, so the expected surprise is .
- Soft state value: .
- Target: .
Interpretation: the target is higher than a plain Bellman target would be, , because the uniform policy has entropy that adds to the value of the next state. The critic learns this bonus, and the policy is rewarded for keeping it.
A Gaussian policy in one dimension has and . The noise sample is .
- Pre-squash sample: .
- Squashed action: .
- Gaussian log-density at : .
- Squash correction: , and .
- Log-probability of the squashed action: .
- With and a critic estimate , the actor's loss for this sample is .
Interpretation: the gradient of this loss with respect to and can be taken through , so the policy moves toward actions the critic rates higher, with the entropy term keeping the spread from collapsing.
A simulated arm has six action dimensions, so the target entropy is . In a batch, the average of is nats (entropy measured with the natural logarithm), meaning the policy is fairly random.
- Estimated entropy of the policy: .
- Temperature loss gradient: . This is positive.
- Starting from , a plain gradient step with learning rate gives .
- Repeat over many updates. As the policy narrows toward the target, the gradient shrinks and settles.
Interpretation: the policy is too random for the target, so the temperature falls and the reward term regains weight. The practical benefit is that the designer does not have to guess a good fixed for each task, which varies with reward scale. The implementation in practice uses an adaptive optimiser and parameterises through its logarithm to keep it positive.
Tradeoffs and failure modes
| Situation | What goes wrong | Better choice |
|---|---|---|
| Discrete actions with a small set of choices | The reparameterization gradient is not available for discrete sampling | Use a discrete-action method such as [[deep-q-network |
| Reward scale changes between tasks | A fixed temperature is too strong or too weak | Use the automatic temperature rule, or rescale rewards |
| Critics disagree strongly | The minimum of two critics can underestimate for a long time | Tune the target update rate, or check the critic loss curves |
| The replay buffer is stale or narrow | Critics learn from data far from the current policy | Keep the buffer large, and monitor how far the policy has moved |
| The task needs a single deterministic action at test time | Sampling noise hurts the final behaviour | Evaluate with the mean of the policy instead of a sample |
SAC is usually compared with DDPG, which uses a deterministic policy and no entropy bonus, and with on-policy methods such as PPO. SAC tends to need more compute per step but fewer environment steps, which matters most when simulation or hardware time is expensive.
History
Soft Q-learning, the value-based precursor, was introduced by Haarnoja and colleagues in 2017, using the soft Bellman equation and an energy-based policy. Their 2018 paper turned this into SAC, an off-policy actor-critic with a separate stochastic actor, two critics and the reparameterized actor update. It showed strong results on continuous control benchmarks with a single set of hyperparameters across tasks. A follow-up in late 2018 added the automatic temperature adjustment and reported results on real robots. Its stability and low tuning burden are why it became a standard baseline in continuous-action reinforcement learning.
Recap
SAC optimises reward plus the entropy of a stochastic policy, as set out in maximum entropy RL. Its critics learn the soft Bellman target from a replay buffer, taking the smaller of two estimates to limit overestimation. Its actor is updated through a reparameterized action, , with a log-probability corrected for the squash. A temperature rule adjusts the entropy bonus so the policy keeps a target level of randomness. The same Bellman structure, with a soft maximum in place of a hard one, underlies the whole method.
Check yourself
QuestionRecall: what are the two main roles in SAC, and what is the role of the temperature ?Show answer
The policy chooses actions and the critics estimate their soft values. The temperature sets how much the policy's entropy counts relative to reward. Large keeps the policy broad, and small lets it sharpen onto the best known actions.
QuestionComputation: a state has two equally likely actions with soft values . Take , reward and discount . What is the soft target ?Show answer
The expected action value is . The entropy term is , so the soft state value is . The target is .
QuestionWhy does SAC use a reparameterized action rather than sampling the action directly from the policy?Show answer
Sampling directly does not give a gradient with respect to and , because the random draw sits inside the sampling step. Writing the action as a smooth function of the parameters and a fixed noise sample moves the randomness into , so the loss can be differentiated through the action into the policy.
QuestionApplied: a researcher fixes at a value that works well on one robot task, then moves to a task whose rewards are 100 times larger. What is likely to happen, and what is the fix?Show answer
Rewards 100 times larger make the fixed entropy bonus relatively tiny, so the policy becomes too narrow and explores less. The fix is to let adapt with the automatic temperature rule, which keeps the entropy at its target whatever the reward scale, or to rescale the rewards so the trade-off is comparable across tasks.