Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问许可证需确认审计提醒

reinforcement-learning强化学习

Agent Skill

reinforcement-learning 用于记录任务执行中的错误、用户纠正、经验和能力缺口,适合在 Codex、Claude、Cursor、Gemini CLI 中希望让 Agent 持续沉淀问题、修正和最佳实践时使用。可结合来源仓库、安装命令和原始 README 继续核验具体用法。安装前建议确认权限范围、维护状态,以及是否会触发联网、命令执行或文件读写。

总安装

247

周安装

10

GitHub Stars

4

下载量

78
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

2

许可证

unknown

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:reinforcement-learning(强化学习)
来源仓库:https://github.com/aznatkoiny/zai-skills
仓库路径:skills/reinforcement-learning
安装命令:
npx skills add https://github.com/aznatkoiny/zai-skills --skill reinforcement-learning
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。该命令会通过 npx skills 从第三方来源获取 Skill;本站只展示命令,不托管安装包,也不自动执行。

skills.shnpx skills
npx skills add https://github.com/aznatkoiny/zai-skills --skill reinforcement-learning

简介

reinforcement-learning 用于记录任务错误与用户反馈,支持 Agent 持续学习和能力迭代。

  • 适用于 Codex、Claude、Cursor、Gemini CLI 中需要强化学习流程优化的场景。
  • 通过 GitHub 安装,提供基于 Gymnasium 和 Stable-Baselines3 的实践指导。
  • 使用前需确认环境依赖和运行权限,避免误执行命令或访问敏感资源。
  • 建议结合具体项目验证代码片段,确保符合实际部署要求。

SKILL.md

Reinforcement Learning Best Practices

Overview

This skill provides comprehensive guidance for implementing reinforcement learning in Python using the modern ecosystem (2024-2025). Gymnasium has replaced OpenAI Gym as the standard environment interface. Stable-Baselines3 (SB3) is recommended for prototyping, RLlib for production/distributed training, and CleanRL for research.

When to Use

  • Building RL agents for discrete or continuous control tasks
  • Creating custom simulation environments
  • Tuning hyperparameters for RL algorithms
  • Debugging training issues (reward curves, policy collapse, numerical instability)
  • Deploying trained policies to production

Library Selection

LibraryBest ForEaseFlexibilityProduction
Stable-Baselines3Prototyping, learningHighMediumGood
RLlibProduction, distributedMediumHighExcellent
CleanRLResearch, understandingHighLowPoor
TorchRLCustom implementationsLowHighestGood

Algorithm Decision Tree

Start
  |
  v
Action space type?
  |
  +-- Discrete --> Sample efficiency critical?
  |                  |
  |                  +-- Yes --> DQN (or Double/Dueling DQN)
  |                  +-- No  --> Stability critical?
  |                               |
  |                               +-- Yes --> PPO
  |                               +-- No  --> A2C (faster iterations)
  |
  +-- Continuous --> Sample efficiency critical?
                       |
                       +-- Yes --> SAC (auto entropy) or TD3
                       +-- No  --> PPO (more stable, less efficient)

Quick Selection Table:

ScenarioRecommendedWhy
Discrete actions, getting startedPPOStable, good defaults
Continuous controlSAC or TD3Sample efficient, handles continuous well
Sample efficiency criticalSAC, DQNOff-policy, reuses experience
Stability criticalPPOTrust region, consistent
High-dimensional obs (images)PPO + CNNHandles visual input well
Fast iteration neededA2CSimpler, faster per update

Quick Start with Stable-Baselines3

Basic Training

from stable_baselines3 import PPO
from stable_baselines3.common.env_util import make_vec_env

# Create vectorized environment (4 parallel envs)
env = make_vec_env("CartPole-v1", n_envs=4)

# Initialize and train
model = PPO("MlpPolicy", env, verbose=1)
model.learn(total_timesteps=100_000)

# Save and load
model.save("ppo_cartpole")
loaded_model = PPO.load("ppo_cartpole")

# Evaluate
obs = env.reset()
for _ in range(1000):
    action, _ = loaded_model.predict(obs, deterministic=True)
    obs, reward, done, info = env.step(action)

Custom Environment Template

import gymnasium as gym
from gymnasium import spaces
import numpy as np

class CustomEnv(gym.Env):
    metadata = {"render_modes": ["human", "rgb_array"]}

    def __init__(self, render_mode=None):
        super().__init__()
        self.observation_space = spaces.Box(
            low=-np.inf, high=np.inf, shape=(4,), dtype=np.float32
        )
        self.action_space = spaces.Discrete(2)
        self.render_mode = render_mode

    def reset(self, seed=None, options=None):
        super().reset(seed=seed)
        self.state = self.np_random.uniform(low=-0.05, high=0.05, size=(4,))
        return self.state.astype(np.float32), {}

    def step(self, action):
        # Implement environment dynamics here
        observation = self.state.astype(np.float32)
        reward = 1.0
        terminated = False  # Episode ended due to task completion/failure
        truncated = False   # Episode ended due to time limit
        info = {}
        return observation, reward, terminated, truncated, info

    def render(self):
        pass

Hyperparameter Tuning with Optuna

import optuna
from stable_baselines3 import PPO
from stable_baselines3.common.evaluation import evaluate_policy

def objective(trial):
    learning_rate = trial.suggest_float("learning_rate", 1e-5, 1e-3, log=True)
    n_steps = trial.suggest_categorical("n_steps", [256, 512, 1024, 2048])
    gamma = trial.suggest_float("gamma", 0.9, 0.9999)

    model = PPO(
        "MlpPolicy", "CartPole-v1",
        learning_rate=learning_rate,
        n_steps=n_steps,
        gamma=gamma,
        verbose=0
    )
    model.learn(total_timesteps=50_000)

    mean_reward, _ = evaluate_policy(model, model.get_env(), n_eval_episodes=10)
    return mean_reward

study = optuna.create_study(direction="maximize")
study.optimize(objective, n_trials=50)
print(f"Best params: {study.best_params}")

Core Workflow

  1. Define the environment - Use Gymnasium API, validate spaces
  2. Select algorithm - Based on action space and requirements
  3. Start simple - Default hyperparameters, short training
  4. Monitor training - TensorBoard, check reward curves
  5. Debug issues - Use the debugging playbook
  6. Tune hyperparameters - Optuna for systematic search
  7. Evaluate properly - Separate eval env, multiple seeds
  8. Deploy - Export to ONNX/TorchScript

Reference Files

Essential Dependencies

pip install gymnasium stable-baselines3 tensorboard optuna
# For Atari environments
pip install gymnasium[atari] gymnasium[accept-rom-license]
# For MuJoCo
pip install gymnasium[mujoco]

Common Pitfalls to Avoid

  1. Not normalizing observations - Use VecNormalize wrapper
  2. Wrong action space handling - Check discrete vs continuous
  3. Ignoring seed management - Set seeds for reproducibility
  4. Training and eval on same env - Use separate eval environment
  5. Not monitoring entropy - Low entropy = policy collapse
  6. Sparse rewards without shaping - Add intermediate rewards
  7. Too large/small learning rate - Start with 3e-4 for most algorithms

适合场景

01

用户想查找某类 Agent Skill 时

02

需要根据任务场景推荐可安装能力包时

03

需要对比不同来源的安装命令和来源信息时

能力概览

能力 1

按任务关键词查找相关 Skills

能力 2

展示可复制的安装命令

能力 3

保留来源站点、仓库和原始说明,方便继续核验

能力 4

展示第三方安全扫描或审计结果

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Codex

35.01%
按下载量换算27

Claude

32.08%
按下载量换算25

Cursor

17.31%
按下载量换算14

Gemini CLI

9.31%
按下载量换算7

安全审计

Gen Agent Trust Hub

可疑

Socket

通过

Snyk

通过

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。当前只有一个来源,正式发布前建议补源仓库或其他目录站核验。

来源信息

继续浏览同类 Skills