← 论文海报合集← Paper Notes|
理论与优化 · Theory & Optimization · ICLR 2019Theory & Optimization · ICLR 2019

Soft Actor-Critic Algorithms and Applications

最大熵强化学习的统一框架:自动温度调节版 SACA unified framework for maximum entropy reinforcement learning: SAC with automatic temperature tuning
Tuomas Haarnoja, Aurick Zhou, Kristian Hartikainen, George Tucker, Sehoon Ha, Jie Tan, Vikash Kumar, Henry Zhu, Abhishek Gupta, Pieter Abbeel, Sergey Levine  ·  UC Berkeley / Google Brain

SAC(Soft Actor-Critic)将强化学习的奖励最大化目标与策略熵最大化统一为一个框架,实现更高效的探索与更稳定的训练。本文(arXiv:1812.05905,v2 于 2019-01-29)在原始 SAC(arXiv:1801.01290)基础上提出自动温度(entropy coefficient)调节,彻底消除温度超参数的手动调节需求,在模拟基准与真实机器人任务上均达到当时最优效果。SAC (Soft Actor-Critic) unifies the reward-maximization objective of reinforcement learning with policy-entropy maximization into a single framework, yielding more efficient exploration and more stable training. This paper (arXiv:1812.05905, v2 of 2019-01-29) builds on the original SAC (arXiv:1801.01290) and introduces automatic temperature (entropy coefficient) tuning, removing the need to hand-tune the temperature hyperparameter entirely, and reaches then-state-of-the-art results on both simulated benchmarks and real-robot tasks.

arXiv 2018-12-13 / v2 2019-01-29 off-policy · maximum entropy RL MuJoCo · 真实机器人real robots 📄 arXiv:1812.05905 Project Page
Soft Actor-Critic maximum entropy RL 最大熵强化学习maximum entropy reinforcement learning automatic temperature tuning off-policy actor-critic continuous control MuJoCo

01 动机 MotivationMotivation

Model-free 深度强化学习在游戏和机器人控制中屡获成功,但面临两大核心挑战: (1)样本效率低——常用 on-policy 算法(TRPO、PPO、A3C)每次更新都需要采集新数据,复杂任务需要数百万步; (2)超参数敏感——学习率、探索常数等细微设置对不同任务影响极大,泛化性差。 原始 SAC(1801.01290)虽引入最大熵框架,却对温度超参数 α 极为敏感: 与常规 RL 不同,最大熵框架中奖励量级与温度耦合,任务切换即需重新调参。Model-free deep reinforcement learning has repeatedly succeeded in games and robot control, yet it faces two core challenges: (1) low sample efficiency — the commonly used on-policy algorithms (TRPO, PPO, A3C) must collect fresh data for every update, and complex tasks require millions of steps; (2) hyperparameter sensitivity — subtle settings such as learning rate and exploration constants have a drastic, task-dependent effect, so generalization is poor. Although the original SAC (1801.01290) introduced the maximum entropy framework, it is extremely sensitive to the temperature hyperparameter α: unlike conventional RL, reward magnitude and temperature are coupled in the maximum entropy framework, so every change of task calls for re-tuning.

"SAC as presented in [haarnoja2018soft] can suffer from brittleness to the temperature hyperparameter… a sub-optimal temperature can drastically degrade performance."
Hopper benchmark training curve
Hopper-v1 上的训练曲线对比(纵轴:evaluation return,横轴:environment steps)。 SAC(蓝色:自动调温;橙色:固定温度)以更快速度超越 DDPG、PPO、TD3 和 SQL,且随机种子间方差极小,体现出算法的高稳定性。 图源:论文 Figure 1(Hopper 子图)。Training curves on Hopper-v1 (vertical axis: evaluation return; horizontal axis: environment steps). SAC (blue: automatic temperature; orange: fixed temperature) overtakes DDPG, PPO, TD3 and SQL faster, with very small variance across random seeds, showing the high stability of the algorithm. Source: Figure 1 of the paper (Hopper subplot).
160kMinitaur 真实机器人学会行走所需步数(约 2 小时)Environment steps for the Minitaur real robot to learn walking (about 2 hours)
300kDexterous Claw 从图像学会旋转阀门所需步数(约 20 小时)Steps for the Dexterous Claw to learn valve rotation from images (about 20 hours)
21-dimrllab Humanoid 动作空间维度——off-policy 算法中极难解决Action-space dimensionality of rllab Humanoid — extremely hard for off-policy algorithms
0使用自动温度调节后需要手动调参的超参数数量(温度)Hyperparameters (the temperature) still requiring manual tuning once automatic temperature adjustment is used

02 方法 MethodMethod

SAC 是一个 off-policy actor-critic 算法,基于最大熵强化学习(Maximum Entropy RL)框架, 同时优化期望回报和策略熵。本文在原始 SAC 上增加了三点关键改进: (1)自动梯度调节温度 α; (2)双 soft Q-network 减少正偏差; (3)目标网络软更新提升稳定性。SAC is an off-policy actor-critic algorithm built on the maximum entropy reinforcement learning (Maximum Entropy RL) framework, optimizing expected return and policy entropy at the same time. This paper adds three key improvements to the original SAC: (1) gradient-based automatic tuning of the temperature α; (2) twin soft Q-networks to reduce positive bias; (3) soft target-network updates for better stability.

最大熵目标函数The Maximum Entropy Objective

标准 RL 最大化期望回报;最大熵 RL 额外最大化每步的策略熵:Standard RL maximizes the expected return; maximum entropy RL additionally maximizes the policy entropy at every step:

π* = argmax_π Σ_t E[(r(s_t, a_t) + α · H(π(·|s_t)))]

其中 α 为温度参数,控制熵项相对于奖励的权重,决定最优策略的随机程度。 当 α → 0 时退化为标准 RL 目标。最大熵框架使策略在不确定区域充分探索, 同时能捕获多个近优行为模式。Here α is the temperature parameter: it controls the weight of the entropy term relative to the reward and determines how stochastic the optimal policy is. As α → 0 the objective degenerates to standard RL. The maximum entropy framework makes the policy explore thoroughly in uncertain regions while capturing multiple near-optimal behavior modes.

Soft Policy Iteration — 收敛性保证Soft Policy Iteration — Convergence Guarantee

算法以 soft policy iteration 为理论基础,交替执行:The algorithm is grounded in soft policy iteration, alternating between:

论文证明(Theorem 1):对任意初始策略,soft policy iteration 收敛到 Π 中最优策略。 在连续域中用神经网络参数化 Q-function 和策略,通过重参数化技巧(reparameterization trick) 计算低方差策略梯度估计,并用随机梯度下降交替更新。The paper proves (Theorem 1) that, for any initial policy, soft policy iteration converges to the optimal policy in Π. In continuous domains the Q-function and the policy are parameterized by neural networks, a low-variance policy gradient estimate is obtained through the reparameterization trick, and the two are updated alternately by stochastic gradient descent.

自动温度调节(核心创新)Automatic Temperature Tuning (the Core Innovation)

将温度调节转化为约束优化问题:在满足最低期望熵约束的前提下最大化期望回报。Temperature tuning is recast as a constrained optimization problem: maximize the expected return subject to a minimum expected-entropy constraint.

max_{π_{0:T}} E[Σ r(s,a)] s.t. E[-log π_t(a|s)] ≥ H̄ ∀t

通过对偶方法推导,α 的更新目标为:Derived through the dual method, the update objective for α is:

J(α) = E_{a~π_t}[-α log π_t(a|s) - α H̄]

熵目标 H̄ 设为动作空间维度的负值(如 HalfCheetah-v1 为 −6)。 α 随策略改进自动调整,无需针对每个任务手动设置,从而完全消除温度调参负担The entropy target H̄ is set to the negative of the action-space dimensionality (−6 for HalfCheetah-v1, for instance). α adjusts itself as the policy improves, with no per-task manual setting, thereby eliminating the burden of temperature tuning entirely.

双 Q-network 与目标网络Twin Q-networks and Target Networks

采用两个独立 soft Q-function(参数 θ_1, θ_2),训练时取最小值以减轻正偏差, 与 TD3 中的 double Q-learning trick 类似。目标网络权重通过指数移动平均 (smoothing coefficient τ = 0.005)软更新,提升训练稳定性。Two independent soft Q-functions (parameters θ_1, θ_2) are used and the minimum is taken during training to mitigate positive bias, analogous to the double Q-learning trick in TD3. Target network weights are updated softly by an exponential moving average (smoothing coefficient τ = 0.005), improving training stability.

Ant-v1 benchmark training curve
Ant-v1 上的训练曲线。DDPG 无法在此任务上取得任何进展(prior work 亦有同样报告), 而 SAC(蓝/橙)持续提升并远超 TD3 和 PPO。图源:论文 Figure 1(Ant 子图)。Training curves on Ant-v1. DDPG makes no progress at all on this task (prior work reports the same), whereas SAC (blue/orange) keeps improving and far surpasses TD3 and PPO. Source: Figure 1 of the paper (Ant subplot).

算法超参数(来自论文 Table 1)Algorithm Hyperparameters (from Table 1 of the paper)

参数ParameterValue
OptimizerAdam
Learning rate3 × 10⁻⁴
Discount γ0.99
Replay buffer size10⁶
Hidden layers2(所有网络)2 (all networks)
Hidden units/layer256
Minibatch size256
Entropy target H̄−dim(A)(如 HalfCheetah-v1 为 −6)−dim(A) (−6 for HalfCheetah-v1, for instance)
NonlinearityReLU
Target smoothing τ0.005
Target update interval1
Gradient steps/step1

03 实验 ExperimentsExperiments

实验分三部分:(1)OpenAI Gym MuJoCo 连续控制基准 + rllab Humanoid; (2)真实世界四足机器人 Minitaur 行走; (3)基于图像的灵巧手操作(Dynamixel Claw 旋转阀门)。 对比基线包括 DDPG、PPO、TD3、SQL,每个算法训练 5 个不同随机种子,每 1000 步评估一次。The experiments come in three parts: (1) the OpenAI Gym MuJoCo continuous control benchmarks plus rllab Humanoid; (2) real-world quadrupedal locomotion with the Minitaur robot; (3) image-based dexterous manipulation (valve rotation with a Dynamixel Claw). The baselines compared against are DDPG, PPO, TD3 and SQL; every algorithm is trained with 5 different random seeds and evaluated every 1000 steps.

MuJoCo 模拟基准MuJoCo Simulated Benchmarks

Humanoid rllab benchmark training curve
rllab Humanoid(21 维动作空间)训练曲线——对 off-policy 算法极具挑战性。 SAC 是唯一成功求解该任务的 off-policy 方法,DDPG 和 TD3 均无法取得进展。 图源:论文 Figure 1(Humanoid rllab 子图)。Training curves on rllab Humanoid (21-dimensional action space) — exceedingly challenging for off-policy algorithms. SAC is the only off-policy method that solves the task; neither DDPG nor TD3 makes any progress. Source: Figure 1 of the paper (Humanoid rllab subplot).

"SAC performs comparably to the baseline methods on the easier tasks and outperforms them on the harder tasks with a large margin, both in terms of learning speed and the final performance." DDPG 在 Ant-v1、Humanoid-v1 和 Humanoid(rllab)上完全失败(与 prior work 一致); SQL 能学会所有任务但收敛更慢且渐近性能更差; SAC 自动温度版(蓝)与固定温度版(橙)表现相当,验证自动调节的有效性。DDPG fails completely on Ant-v1, Humanoid-v1 and Humanoid (rllab), consistently with prior work; SQL learns every task but converges more slowly and with worse asymptotic performance; the automatic-temperature version of SAC (blue) performs on par with the fixed-temperature version (orange), confirming the effectiveness of automatic tuning.

真实机器人:Minitaur 四足行走Real Robot: Minitaur Quadrupedal Locomotion

Minitaur quadruped locomotion
Minitaur(8 个直驱电机,腿部可在矢状面运动)在平地上的学习帧序列。 策略在约 160k 环境步数(约 2 小时真实训练时间)后学会行走。 论文还测试了斜坡(slope)、木块障碍(obstacles)、台阶(stairs)—— 均无需额外训练即可泛化,"due to entropy maximization at training time, the policy can readily generalize to these perturbations." 图源:论文 Figure 3。Frame sequence of Minitaur (8 direct-drive motors, legs moving in the sagittal plane) learning on flat ground. The policy learns to walk after roughly 160k environment steps (about 2 hours of real training time). The paper further tests slopes, block obstacles and stairs — all of which generalize without extra training, "due to entropy maximization at training time, the policy can readily generalize to these perturbations." Source: Figure 3 of the paper.

真实机器人:Dexterous Hand Claw 旋转阀门Real Robot: Dexterous Hand Claw Valve Rotation

Dexterous claw valve rotation task
Dynamixel Claw(9 DoF,3 指)旋转阀门任务。上行:高分辨率帧序列;下行:策略实际接收的 32×32 像素图像观测。 从图像端到端学习需约 300k 步(20 小时); 从阀门关节角度(非图像)学习需约 3 小时, 显著快于同任务 PPO 报告的 7.4 小时。 图源:论文 Figure 4。Valve rotation task with a Dynamixel Claw (9 DoF, 3 fingers). Top row: high-resolution frame sequence; bottom row: the 32×32 pixel image observations the policy actually receives. Learning end-to-end from images takes about 300k steps (20 hours); learning from the valve joint angle rather than images takes about 3 hours, markedly faster than the 7.4 hours reported for PPO on the same task. Source: Figure 4 of the paper.

消融:温度敏感性Ablation: Temperature Sensitivity

Reward scale ablation on Ant-v1
Ant-v1 上的 reward scale(与温度等价的超参数)消融。 奖励量级过小导致策略趋近于均匀分布(探索过多,无法利用奖励信号); 过大导致策略过早收敛(确定性策略,探索不足); 适当值下算法快速稳定学习。 自动温度调节在所有环境下均表现良好,有效消除了此类敏感性。 图源:论文附录 Ablation 图。Ablation of the reward scale (a hyperparameter equivalent to temperature) on Ant-v1. Too small a reward magnitude drives the policy toward a uniform distribution (too much exploration, unable to exploit the reward signal); too large a magnitude makes the policy converge prematurely (deterministic policy, insufficient exploration); at an appropriate value the algorithm learns fast and stably. Automatic temperature tuning behaves well in every environment and effectively removes this kind of sensitivity. Source: ablation figure in the appendix of the paper.

Half-Cheetah 对比Half-Cheetah Comparison

HalfCheetah benchmark training curve
HalfCheetah-v1 训练曲线。SAC 在样本效率和最终性能上均超越 TD3(当时最先进 off-policy 方法)。 图源:论文 Figure 1(HalfCheetah 子图)。Training curves on HalfCheetah-v1. SAC surpasses TD3 (the off-policy state of the art at the time) in both sample efficiency and final performance. Source: Figure 1 of the paper (HalfCheetah subplot).

04 局限性 LimitationsLimitations

Note:论文未设置专门的 Limitations 节。以下各点均标注来源: [stated] 表示论文正文明确提及,[inferred] 表示从设计中推断。Note: the paper has no dedicated Limitations section. Every point below is annotated with its source: [stated] means explicitly mentioned in the body of the paper, [inferred] means inferred from the design.
温度目标 H̄ 仍需人工指定 [stated + inferred]The entropy target H̄ still has to be specified by hand [stated + inferred]

论文将熵目标设为 −dim(A)(动作空间维度的负值),是一个经验性默认值而非自动推导。 虽然该设置在实验中表现稳定,但对于不同任务结构(如稀疏奖励、高度非线性动作空间) 是否依然适用,论文未做系统性验证。[inferred from design]The paper sets the entropy target to −dim(A) (the negative of the action-space dimensionality), an empirical default rather than an automatically derived value. Although the setting proves stable in the experiments, whether it remains appropriate for different task structures (sparse rewards, highly nonlinear action spaces) is never systematically verified. [inferred from design]

连续动作空间假设 [stated]Continuous action space assumption [stated]

SAC 的理论推导(Soft Policy Iteration 的收敛性证明)要求有限动作空间(|A| < ∞), 而实际算法通过高斯参数化拓展到连续域——理论严格性有所损失。 此外,动作范围约束通过 tanh squashing 处理,对于边界行为频繁的任务可能引入额外偏差。[inferred]The theoretical derivation of SAC (the convergence proof for Soft Policy Iteration) requires a finite action space (|A| < ∞), whereas the practical algorithm extends to continuous domains through a Gaussian parameterization — some theoretical rigor is lost. Action range constraints are moreover handled by tanh squashing, which may introduce additional bias for tasks with frequent boundary behavior. [inferred]

双 Q-network 近似导致超参数仍存在 [inferred]The twin Q-network approximation still leaves hyperparameters behind [inferred]

使用两个 Q-network 取最小值减轻正偏差,但并未完全消除——仍依赖目标网络软更新系数 τ、 网络容量(256 × 2 层)等固定超参数。这些参数在论文中未做系统性消融验证。[inferred]Taking the minimum over two Q-networks mitigates positive bias but does not remove it entirely — it still relies on fixed hyperparameters such as the target-network soft update coefficient τ and the network capacity (256 × 2 layers). These are never systematically ablated in the paper. [inferred]

真实机器人实验规模有限 [inferred]Limited scale of the real-robot experiments [inferred]

Minitaur 和 Claw 实验仅展示了单个机器人平台、单个任务的成功案例,缺乏多任务、 多机器人平台的系统性评估。真实世界实验的可复现性(硬件差异、传感器噪声)未深入讨论。[inferred]The Minitaur and Claw experiments only exhibit success cases on a single robot platform and a single task, lacking any systematic evaluation across multiple tasks and multiple robot platforms. The reproducibility of the real-world experiments (hardware differences, sensor noise) is not discussed in depth. [inferred]

收敛性证明仅适用于 tabular 设置 [stated]The convergence proof only holds in the tabular setting [stated]

"Although this algorithm will provably find the optimal solution, we can perform it in its exact form only in the tabular case." 神经网络函数逼近引入的误差不在理论保证范围之内,实践中的收敛依赖于近似对偶梯度下降的启发性论证。[stated]The error introduced by neural network function approximation lies outside the theoretical guarantee; convergence in practice rests on the heuristic argument for approximate dual gradient descent. [stated]