Wikipedia 强化学习核心概念 (Wikipedia Reinforcement Learning Concepts)¶
来源: Wikipedia (英文维基百科)
编译时间: 2026-06-01
状态: 中英对照编译
基于: Reinforcement learning, Q-learning, Policy gradient 等条目
关联: 深度学习概念, 决策科学概念
📚 目录 (Table of Contents)¶
1. 强化学习基础 (Reinforcement Learning Basics)¶
英文定义 (English Definition):
Reinforcement learning (RL) is a type of machine learning where an agent learns to make decisions by interacting with an environment. The agent learns to achieve a goal by trial and error, receiving rewards or penalties for its actions.
中文翻译 (Chinese Translation):
强化学习 (RL) 是一种机器学习类型,其中智能体通过与环境交互来学习做出决策。智能体通过试错学习实现目标,为其行为接收奖励或惩罚。
核心组件 (Core Components):
| 组件 | 英文 | 中文 | 说明 |
|---|---|---|---|
| Agent | Agent | 智能体 | 学习和决策的主体 |
| Environment | Environment | 环境 | 智能体交互的外部世界 |
| State | State | 状态 | 环境的当前情况 |
| Action | Action | 行动 | 智能体可以采取的行为 |
| Reward | Reward | 奖励 | 行动后的即时反馈 |
| Policy | Policy | 策略 | 状态到行动的映射 |
| Value | Value | 价值 | 长期回报的期望 |
强化学习 vs 监督学习 (RL vs Supervised Learning):
| 方面 | 监督学习 | 强化学习 |
|---|---|---|
| 数据 | 标注的训练数据 | 与环境交互获得 |
| 反馈 | 正确答案标签 | 延迟的奖励信号 |
| 目标 | 最小化预测误差 | 最大化累积奖励 |
| 时序性 | 通常独立同分布 | 序列决策,有时间依赖 |
| 探索 | 不需要 | 需要探索 - 利用权衡 |
强化学习流程 (RL Process):
┌─────────────┐
│ 智能体 │
│ Agent │
└──────┬──────┘
│ 行动 (Action: aₜ)
↓
┌─────────────┐
│ 环境 │
│ Environment │
└──────┬──────┘
│ 状态 (State: sₜ₊₁)
│ 奖励 (Reward: rₜ₊₁)
↓
┌─────────────┐
│ 智能体 │ ← 更新策略
│ Agent │
└─────────────┘
2. 马尔可夫决策过程 (Markov Decision Processes)¶
英文定义:
A Markov Decision Process (MDP) is a mathematical framework for modeling decision making in situations where outcomes are partly random and partly under the control of a decision maker.
中文翻译:
马尔可夫决策过程 (MDP) 是建模决策的数学框架,用于结果部分随机、部分由决策者控制的情况。
MDP 五元组 (MDP Tuple):
其中: - \(S\): 状态空间 (State space) - \(A\): 行动空间 (Action space) - \(P\): 状态转移概率 (Transition probability) - \(R\): 奖励函数 (Reward function) - \(\gamma\): 折扣因子 (Discount factor)
马尔可夫性质 (Markov Property):
英文:
The future is independent of the past given the present. Mathematically:
中文:
给定现在,未来与过去独立。数学上:
回报与折扣 (Return and Discounting):
累积回报 \(G_t\) 定义为:
折扣因子的作用:
| γ值 | 含义 | 适用场景 |
|---|---|---|
| 0 | 只关心即时奖励 | 短期任务 |
| 0.9-0.99 | 平衡近期与远期 | 大多数场景 |
| 1 | 平等对待所有奖励 | 持续任务(需终止) |
3. 值方法 (Value Methods)¶
状态价值函数 (State Value Function)¶
英文:
The state value function V(s) represents the expected return when starting from state s and following policy π thereafter.
中文:
状态价值函数 V(s) 表示从状态 s 开始并遵循策略π后的期望回报。
贝尔曼方程 (Bellman Equation):
最优价值函数 (Optimal Value Function):
行动价值函数 (Action Value Function / Q-Function)¶
英文:
The action value function Q(s,a) represents the expected return when taking action a in state s and following policy π thereafter.
中文:
行动价值函数 Q(s,a) 表示在状态 s 采取行动 a 后遵循策略π的期望回报。
Q 函数贝尔曼方程 (Q-Function Bellman Equation):
最优 Q 函数 (Optimal Q-Function):
Q-Learning 算法¶
英文:
Q-Learning is a model-free reinforcement learning algorithm that learns the optimal action-value function through temporal difference updates.
中文:
Q-Learning 是一种无模型强化学习算法,通过时序差分更新学习最优行动价值函数。
Q-Learning 更新规则 (Q-Learning Update Rule):
其中: - \(\alpha\): 学习率 (learning rate) - \(r_{t+1} + \gamma \max_a Q(s_{t+1}, a)\): TD 目标 - \(r_{t+1} + \gamma \max_a Q(s_{t+1}, a) - Q(s_t, a_t)\): TD 误差
Q-Learning 算法伪代码 (Q-Learning Pseudocode):
Initialize Q(s,a) arbitrarily for all s,a
Repeat for each episode:
Initialize s
Repeat for each step of episode:
Choose a from s using policy derived from Q (e.g., ε-greedy)
Take action a, observe r, s'
Q(s,a) ← Q(s,a) + α[r + γ max_a' Q(s',a') - Q(s,a)]
s ← s'
until s is terminal
Python 实现示例 (Python Implementation):
import numpy as np
class QLearningAgent:
def __init__(self, n_states, n_actions, alpha=0.1, gamma=0.99, epsilon=0.1):
self.q_table = np.zeros((n_states, n_actions))
self.alpha = alpha # 学习率
self.gamma = gamma # 折扣因子
self.epsilon = epsilon # 探索率
self.n_actions = n_actions
def choose_action(self, state):
"""ε-greedy 策略"""
if np.random.random() < self.epsilon:
return np.random.randint(self.n_actions) # 探索
else:
return np.argmax(self.q_table[state]) # 利用
def update(self, state, action, reward, next_state, done):
"""Q-Learning 更新"""
best_next_action = np.argmax(self.q_table[next_state])
td_target = reward + (0 if done else self.gamma * self.q_table[next_state][best_next_action])
td_error = td_target - self.q_table[state][action]
self.q_table[state][action] += self.alpha * td_error
SARSA 算法¶
英文:
SARSA (State-Action-Reward-State-Action) is an on-policy temporal difference learning algorithm that learns the action-value function for the current policy.
中文:
SARSA (状态 - 行动 - 奖励 - 状态 - 行动) 是一种同策略时序差分学习算法,学习当前策略的行动价值函数。
SARSA vs Q-Learning:
| 特性 | SARSA | Q-Learning |
|---|---|---|
| 策略类型 | 同策略 (On-policy) | 异策略 (Off-policy) |
| 更新目标 | \(Q(s', a')\) (实际采取的 action) | \(\max_a Q(s', a)\) (最优 action) |
| 探索影响 | 考虑探索,更保守 | 不考虑探索,更激进 |
| 收敛性 | 收敛到当前策略的 Q 值 | 收敛到最优 Q 值 |
| 安全性 | 更安全(考虑探索风险) | 可能高估风险行动 |
SARSA 更新公式 (SARSA Update Formula):
注意:使用实际采取的下一个行动 \(a_{t+1}\),而非最大 Q 值的行动。
4. 策略梯度方法 (Policy Gradient Methods)¶
策略梯度定理 (Policy Gradient Theorem)¶
英文:
Policy gradient methods directly optimize the policy parameterized by θ. The policy gradient theorem provides the gradient of the expected return with respect to θ.
中文:
策略梯度方法直接优化参数化为θ的策略。策略梯度定理提供了期望回报关于θ的梯度。
策略梯度公式 (Policy Gradient Formula):
REINFORCE 算法 (REINFORCE Algorithm):
REINFORCE 算法:
1. 初始化策略参数 θ
2. 对于每个回合:
a. 用当前策略生成轨迹: s₀, a₀, r₁, s₁, a₁, r₂, ..., sₜ
b. 对于每个时间步 t:
- 计算回报: Gₜ = rₜ₊₁ + γrₜ₊₂ + ...
- 更新: θ ← θ + α∇θ log πθ(aₜ|sₜ) · Gₜ
Python 实现 (Python Implementation):
import torch
import torch.nn as nn
import torch.optim as optim
class REINFORCE:
def __init__(self, state_dim, action_dim, lr=0.01, gamma=0.99):
self.gamma = gamma
self.policy_net = nn.Sequential(
nn.Linear(state_dim, 128),
nn.ReLU(),
nn.Linear(128, action_dim),
nn.Softmax(dim=-1)
)
self.optimizer = optim.Adam(self.policy_net.parameters(), lr=lr)
self.saved_log_probs = []
self.rewards = []
def select_action(self, state):
state = torch.FloatTensor(state)
probs = self.policy_net(state)
m = torch.distributions.Categorical(probs)
action = m.sample()
self.saved_log_probs.append(m.log_prob(action))
return action.item()
def update(self):
# 计算折扣回报
returns = []
G = 0
for r in reversed(self.rewards):
G = r + self.gamma * G
returns.insert(0, G)
returns = torch.tensor(returns)
# 标准化回报
returns = (returns - returns.mean()) / (returns.std() + 1e-9)
# 计算损失
policy_loss = []
for log_prob, G in zip(self.saved_log_probs, returns):
policy_loss.append(-log_prob * G)
self.optimizer.zero_grad()
policy_loss = torch.cat(policy_loss).sum()
policy_loss.backward()
self.optimizer.step()
# 清空
self.saved_log_probs = []
self.rewards = []
带基线的策略梯度 (Policy Gradient with Baseline)¶
英文:
Adding a baseline reduces the variance of the policy gradient estimator without introducing bias.
中文:
添加基线可以减少策略梯度估计量的方差,而不引入偏倚。
带基线的策略梯度 (Policy Gradient with Baseline):
其中 \(b(s)\) 是基线函数,通常使用 \(V(s)\)。
优势函数 (Advantage Function):
优势函数衡量行动 a 相对于平均情况有多好。
5. Actor-Critic 方法 (Actor-Critic Methods)¶
A2C (Advantage Actor-Critic)¶
英文:
A2C combines policy gradient (actor) with value function estimation (critic). The actor updates the policy, and the critic evaluates the current policy.
中文:
A2C 结合策略梯度(演员)与价值函数估计(评论家)。演员更新策略,评论家评估当前策略。
A2C 架构 (A2C Architecture):
┌─────────────────┐
│ 状态 s │
└────────┬────────┘
│
┌────┴────┐
↓ ↓
┌───────┐ ┌───────┐
│ Actor │ │ Critic│
│ 策略π │ │ 价值 V│
└───┬───┘ └───┬───┘
│ │
↓ ↓
行动 a 价值 V(s)
用于计算优势
A2C 损失函数 (A2C Loss Functions):
策略损失 (Policy Loss): $$ L_{policy} = -\log \pi_\theta(a|s) \cdot A(s,a) $$
价值损失 (Value Loss): $$ L_{value} = (V(s) - G)^2 $$
总损失: $$ L = L_{policy} + c_1 \cdot L_{value} - c_2 \cdot S[\pi_\theta] $$
其中 \(S[\pi_\theta]\) 是策略熵,用于鼓励探索。
PPO (Proximal Policy Optimization)¶
英文:
PPO is a family of policy gradient methods that use a clipped surrogate objective to prevent large policy updates.
中文:
PPO 是一族策略梯度方法,使用截断的代理目标来防止大的策略更新。
PPO 截断目标 (PPO Clipped Objective):
其中: - \(r_t(\theta) = \frac{\pi_\theta(a|s)}{\pi_{\theta_{old}}(a|s)}\): 概率比 - \(\epsilon\): 截断参数(通常 0.2)
PPO 算法特点 (PPO Algorithm Features):
| 特点 | 说明 |
|---|---|
| 截断更新 | 防止策略变化过大 |
| 多轮更新 | 每个样本可使用多次 |
| 易于实现 | 比 TRPO 更简单 |
| 效果好 | 当前最流行的 RL 算法之一 |
PPO Python 核心代码 (PPO Core Code):
def ppo_update(self, states, actions, old_log_probs, returns, advantages):
# 计算概率比
log_probs = self.policy_net(states).log_prob(actions)
ratio = torch.exp(log_probs - old_log_probs)
# 截断目标
surr1 = ratio * advantages
surr2 = torch.clamp(ratio, 1-self.epsilon, 1+self.epsilon) * advantages
policy_loss = -torch.min(surr1, surr2).mean()
# 价值损失
value_loss = (self.value_net(states) - returns).pow(2).mean()
# 熵正则化
entropy = self.policy_net(states).entropy().mean()
# 总损失
loss = policy_loss + self.value_coef * value_loss - self.entropy_coef * entropy
# 反向传播
self.optimizer.zero_grad()
loss.backward()
self.optimizer.step()
6. 深度强化学习 (Deep Reinforcement Learning)¶
DQN (Deep Q-Network)¶
英文:
DQN combines Q-learning with deep neural networks to handle high-dimensional state spaces, such as raw pixel inputs from games.
中文:
DQN 将 Q-learning 与深度神经网络结合,处理高维状态空间,如来自游戏的原始像素输入。
DQN 关键创新 (DQN Key Innovations):
| 创新 | 英文 | 中文 | 作用 |
|---|---|---|---|
| Experience Replay | Experience Replay | 经验回放 | 打破样本相关性 |
| Target Network | Target Network | 目标网络 | 稳定训练 |
| ε-greedy | ε-greedy | ε-贪婪 | 探索策略 |
DQN 架构图 (DQN Architecture):
原始像素输入 (84×84×4)
↓
[卷积层 32@8×8]
↓
[卷积层 64@4×4]
↓
[卷积层 64@3×3]
↓
[全连接层 512]
↓
[全连接层] → Q 值 (每个行动的 Q 值)
DQN 更新规则 (DQN Update Rule):
深度强化学习算法对比 (Deep RL Algorithm Comparison)¶
| 算法 | 类型 | 连续行动 | 样本效率 | 稳定性 | 代表应用 |
|---|---|---|---|---|---|
| DQN | Value-based | ❌ | 低 | 中等 | Atari 游戏 |
| DDPG | Actor-Critic | ✅ | 中等 | 中等 | 机器人控制 |
| PPO | Policy-based | ✅ | 中等 | 高 | Dota 2, 机器人 |
| SAC | Actor-Critic | ✅ | 高 | 高 | 复杂控制任务 |
| A3C | Actor-Critic | ✅ | 中等 | 中等 | 多任务学习 |
多智能体强化学习 (Multi-Agent Reinforcement Learning)¶
英文:
Multi-agent RL extends single-agent RL to scenarios with multiple interacting agents. It introduces additional challenges like non-stationarity and credit assignment.
中文:
多智能体 RL 将单智能体 RL 扩展到多个交互智能体的场景。它引入了非平稳性和信用分配等额外挑战。
MARL 挑战 (MARL Challenges):
| 挑战 | 英文 | 中文 |
|---|---|---|
| Non-stationarity | 非平稳性 | 其他智能体也在学习 |
| Credit assignment | 信用分配 | 团队奖励如何归因 |
| Coordination | 协调 | 智能体间协作 |
| Communication | 通信 | 智能体间信息传递 |
7. 应用与挑战 (Applications and Challenges)¶
代表性应用 (Representative Applications)¶
| 应用 | 领域 | 算法 | 年份 |
|---|---|---|---|
| AlphaGo | 围棋 | MCTS + DNN | 2016 |
| AlphaZero | 通用棋类 | MCTS + ResNet | 2017 |
| OpenAI Five | Dota 2 | PPO | 2018 |
| AlphaStar | 星际争霸 2 | Transformer + RL | 2019 |
| Robotic Control | 机器人 | SAC, PPO | 持续 |
强化学习挑战 (RL Challenges)¶
主要挑战 (Main Challenges):
| 挑战 | 英文 | 中文 | 当前研究方向 |
|---|---|---|---|
| Sample efficiency | 样本效率 | 需要大量交互 | 模型基础 RL, 离线 RL |
| Exploration | 探索 | 有效探索策略 | 内在动机,好奇心 |
| Generalization | 泛化 | 迁移到新环境 | 元学习,迁移学习 |
| Safety | 安全性 | 避免危险行为 | 安全 RL, 约束优化 |
| Reward design | 奖励设计 | 设计合适的奖励 | 逆强化学习,偏好学习 |
强化学习与因果推断 (RL and Causal Inference)¶
英文:
Causal inference methods can improve RL by distinguishing correlation from causation, enabling better generalization and more robust policies.
中文:
因果推断方法可以通过区分相关性和因果关系来改进 RL,实现更好的泛化和更稳健的策略。
交叉应用 (Intersection Applications):
| 方向 | 说明 |
|---|---|
| 反事实推理 | 评估未采取行动的效果 |
| 因果发现 | 学习环境因果结构 |
| 领域泛化 | 利用因果不变性 |
| 离线 RL | 从观察数据学习策略 |
📊 强化学习知识图谱¶
graph TB
A[强化学习] --> B[MDP 框架]
A --> C[学习方法]
A --> D[深度学习结合]
A --> E[应用]
B --> B1[状态]
B --> B2[行动]
B --> B3[奖励]
B --> B4[策略]
B --> B5[价值]
C --> C1[Value-based<br/>Q-Learning, SARSA]
C --> C2[Policy-based<br/>REINFORCE, PPO]
C --> C3[Actor-Critic<br/>A2C, A3C]
D --> D1[DQN]
D --> D2[DDPG]
D --> D3[SAC]
E --> E1[游戏 AI]
E --> E2[机器人控制]
E --> E3[自动驾驶]
style A fill:#4CAF50
style C2 fill:#2196F3
style D1 fill:#FF9800
🔑 关键术语对照表 (Glossary)¶
| English | 中文 | 定义 |
|---|---|---|
| Reinforcement learning | 强化学习 | 通过与环境交互学习的 ML 范式 |
| Agent | 智能体 | 学习和决策的主体 |
| Environment | 环境 | 智能体交互的外部世界 |
| State | 状态 | 环境的当前表示 |
| Action | 行动 | 智能体可采取的行为 |
| Reward | 奖励 | 即时反馈信号 |
| Policy | 策略 | 状态到行动的映射 |
| Value function | 价值函数 | 长期回报期望 |
| MDP | 马尔可夫决策过程 | RL 的数学框架 |
| Q-learning | Q 学习 | 异策略值学习方法 |
| SARSA | SARSA | 同策略时序差分方法 |
| Policy gradient | 策略梯度 | 直接优化策略的方法 |
| Actor-Critic | 演员 - 评论家 | 结合值与策略的方法 |
| DQN | 深度 Q 网络 | 深度学习的 Q 学习 |
| PPO | 近端策略优化 | 截断策略梯度方法 |
| Experience replay | 经验回放 | 存储重用经验的机制 |
| Exploration-exploitation | 探索 - 利用 | 尝试新行动 vs 使用已知最佳 |
| Discount factor | 折扣因子 | 未来奖励的折现率 |
| Bellman equation | 贝尔曼方程 | 价值函数的递归关系 |
| Advantage function | 优势函数 | Q 值与 V 值的差异 |
编译完成时间: 2026-06-01
来源: Wikipedia Reinforcement learning, Q-learning, Policy gradient 等条目
关联文档: deep-learning-concepts-zh-en.md, decision-science-concepts-zh-en.md