来源信息
- 仓库
- brycewang-stanford/Auto-Empirical-Research-Skills
- 最近来源活动
- 2026年4月3日 02:07
- 检测到的 SKILL.md 语言
- 英语
- 星标
- 3,291
- 分支
- 432
安装方式
默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。
检查来源文件
决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。
菜单
默认使用会先检查来源的 Prompt;你也可以切换为直接命令,或下载本地副本。
决定是否安装前,请先阅读 SKILL.md,以及 SkillsMP 当前展示的配套文件。
用 Codex 或 Claude 帮你安装 复制这段 Prompt,粘贴到 Codex、Claude 或其他助手里,让它检查 Skill 页面并帮你完成安装。
直接命令不会经过审查 Prompt;运行前请先检查来源。
npx skills add https://github.com/brycewang-stanford/Auto-Empirical-Research-Skills --skill reinforcement-learning-guide命令会保持在同一行。复制前请横向滚动并检查完整内容。
想先保存到本地?可下载 SkillsMP 当前能够提供的文件。
基于 SOC 职业分类
正在显示 SKILL.md
| name | reinforcement-learning-guide |
| description | Reinforcement learning fundamentals, algorithms, and research |
| metadata | {"openclaw":{"emoji":"🤖","category":"domains","subcategory":"ai-ml","keywords":["reinforcement learning","machine learning","deep learning","neural network"],"source":"wentor-research-plugins"}} |
Understand and implement reinforcement learning algorithms from tabular methods through deep RL, including policy gradients, actor-critic, and model-based approaches.
An agent interacts with an environment to maximize cumulative reward:
Agent Environment
| |
|--- action a_t ---------->|
| |--- next state s_{t+1}
|<-- reward r_t, state s_t |--- reward r_{t+1}
| |
| Concept | Symbol | Definition |
|---|---|---|
| State | s | Observation of the environment |
| Action | a | Decision made by the agent |
| Reward | r | Scalar feedback signal |
| Policy | pi(a|s) | Mapping from states to actions |
| Value function | V(s) | Expected cumulative reward from state s |
| Q-function | Q(s, a) | Expected cumulative reward from (s, a) |
| Discount factor | gamma | Weight of future vs. immediate rewards (0-1) |
| Return | G_t | Sum of discounted future rewards from time t |
# Return (discounted cumulative reward)
G_t = r_t + gamma * r_{t+1} + gamma^2 * r_{t+2} + ...
# Bellman equation for V
V(s) = E[r + gamma * V(s') | s]
# Bellman equation for Q
Q(s, a) = E[r + gamma * max_a' Q(s', a') | s, a]
# Policy gradient theorem
gradient J(theta) = E[gradient log pi_theta(a|s) * Q(s, a)]
| Category | Algorithm | Key Idea | On/Off Policy |
|---|---|---|---|
| Value-based | Q-Learning | Learn Q(s,a), act greedily | Off-policy |
| DQN | Q-Learning + neural net + replay buffer | Off-policy | |
| Double DQN | Two networks to reduce overestimation | Off-policy | |
| Dueling DQN | Separate value and advantage streams | Off-policy | |
| Policy gradient | REINFORCE | Monte Carlo policy gradient | On-policy |
| PPO | Clipped surrogate objective | On-policy | |
| TRPO | Trust region constraint | On-policy | |
| Actor-Critic | A2C/A3C | Advantage actor-critic (parallel) | On-policy |
| SAC | Maximum entropy + off-policy AC | Off-policy | |
| TD3 | Twin delayed DDPG | Off-policy | |
| Model-based | Dreamer | World model + imagination | On-policy |
| MBPO | Model-based policy optimization | Off-policy | |
| MuZero | Learned model + planning (MCTS) | Off-policy |
import torch
import torch.nn as nn
import torch.optim as optim
import numpy as np
from collections import deque
import random
class QNetwork(nn.Module):
def __init__(self, state_dim, action_dim, hidden_dim=128):
super().__init__()
self.net = nn.Sequential(
nn.Linear(state_dim, hidden_dim),
nn.ReLU(),
nn.Linear(hidden_dim, hidden_dim),
nn.ReLU(),
nn.Linear(hidden_dim, action_dim)
)
def forward(self, x):
return self.net(x)
class DQNAgent:
def __init__(self, state_dim, action_dim, lr=1e-3, gamma=0.99,
epsilon=1.0, epsilon_decay=0.995, epsilon_min=0.01,
buffer_size=10000, batch_size=64):
self.action_dim = action_dim
self.gamma = gamma
self.epsilon = epsilon
self.epsilon_decay = epsilon_decay
self.epsilon_min = epsilon_min
self.batch_size = batch_size
self.q_network = QNetwork(state_dim, action_dim)
self.target_network = QNetwork(state_dim, action_dim)
.target_network.load_state_dict(.q_network.state_dict())
.optimizer = optim.Adam(.q_network.parameters(), lr=lr)
.replay_buffer = deque(maxlen=buffer_size)
():
random.random() < .epsilon:
random.randint(, .action_dim - )
torch.no_grad():
q_values = .q_network(torch.FloatTensor(state))
q_values.argmax().item()
():
.replay_buffer.append((state, action, reward, next_state, done))
():
(.replay_buffer) < .batch_size:
batch = random.sample(.replay_buffer, .batch_size)
states, actions, rewards, next_states, dones = (*batch)
states = torch.FloatTensor(np.array(states))
actions = torch.LongTensor(actions)
rewards = torch.FloatTensor(rewards)
next_states = torch.FloatTensor(np.array(next_states))
dones = torch.FloatTensor(dones)
q_values = .q_network(states).gather(, actions.unsqueeze()).squeeze()
torch.no_grad():
best_actions = .q_network(next_states).argmax()
next_q = .target_network(next_states).gather(, best_actions.unsqueeze()).squeeze()
targets = rewards + .gamma * next_q * ( - dones)
loss = nn.MSELoss()(q_values, targets)
.optimizer.zero_grad()
loss.backward()
.optimizer.step()
.epsilon = (.epsilon_min, .epsilon * .epsilon_decay)
loss.item()
():
.target_network.load_state_dict(.q_network.state_dict())
class PPOAgent:
def __init__(self, state_dim, action_dim, lr=3e-4, gamma=0.99,
lam=0.95, clip_ratio=0.2, epochs=10):
self.gamma = gamma
self.lam = lam
self.clip_ratio = clip_ratio
self.epochs = epochs
self.actor = nn.Sequential(
nn.Linear(state_dim, 64), nn.Tanh(),
nn.Linear(64, 64), nn.Tanh(),
nn.Linear(64, action_dim), nn.Softmax(dim=-1)
)
self.critic = nn.Sequential(
nn.Linear(state_dim, 64), nn.Tanh(),
nn.Linear(64, 64), nn.Tanh(),
nn.Linear(64, 1)
)
self.optimizer = optim.Adam(
list(self.actor.parameters()) + list(self.critic.parameters()), lr=lr
)
def compute_gae(self, rewards, values, dones):
"""Generalized Advantage Estimation."""
advantages = []
gae = 0
for t in reversed(range(len(rewards))):
next_value = values[t + 1] if t + 1 < (values)
delta = rewards[t] + .gamma * next_value * ( - dones[t]) - values[t]
gae = delta + .gamma * .lam * ( - dones[t]) * gae
advantages.insert(, gae)
torch.FloatTensor(advantages)
():
values = .critic(states).squeeze().detach().numpy()
advantages = .compute_gae(rewards, values, dones)
returns = advantages + torch.FloatTensor(values[:(advantages)])
advantages = (advantages - advantages.mean()) / (advantages.std() + )
_ (.epochs):
probs = .actor(states)
dist = torch.distributions.Categorical(probs)
new_log_probs = dist.log_prob(actions)
entropy = dist.entropy().mean()
ratio = (new_log_probs - old_log_probs).exp()
clipped = torch.clamp(ratio, - .clip_ratio, + .clip_ratio)
actor_loss = -torch.(ratio * advantages, clipped * advantages).mean()
critic_loss = nn.MSELoss()(.critic(states).squeeze(), returns)
loss = actor_loss + * critic_loss - * entropy
.optimizer.zero_grad()
loss.backward()
.optimizer.step()
| Environment | Domain | Complexity | Key Paper |
|---|---|---|---|
| Gymnasium (ex-Gym) | Classic control, Atari | Low-High | Brockman et al., 2016 |
| MuJoCo | Continuous control, robotics | Medium-High | Todorov et al., 2012 |
| DMControl | Continuous control from pixels | High | Tassa et al., 2018 |
| ProcGen | Procedurally generated games | High (generalization) | Cobbe et al., 2020 |
| Minigrid | Grid-world navigation | Low-Medium | Chevalier-Boisvert et al. |
| Isaac Gym | GPU-accelerated physics sim | High | Makoviychuk et al., 2021 |
| NetHack | Complex roguelike game | Very High | Kuttler et al., 2020 |
| Venue | Type | Focus |
|---|---|---|
| NeurIPS | Conference | Broad ML including RL |
| ICML | Conference | Broad ML including RL |
| ICLR | Conference | Representation learning, deep RL |
| AAAI | Conference | Broad AI |
| CoRL | Conference | Robot learning |
| JMLR | Journal | Broad ML (open access) |
| L4DC | Conference | Learning for dynamics and control |