Skip to main content

spinning-up-deep-rl

Learn or apply deep reinforcement learning with OpenAI Spinning Up: policy gradients, VPG, PPO, SAC, TD3, DDPG, TRPO. Use whenever an RL agent will not learn, reward stays flat, or the user asks how PPO or SAC works.

v1.0.3New

Unsigned, install at your own risk

Unverified

This skill has no cryptographic signature attached. We can't verify the contents match what the publisher intended.

Install this skill

No account required. Pick your tool, or use the command that detects it for you.

Run in your terminal. It detects your AI tool.

npx @skills-hub-ai/cli install alirezarezvani-spinning-up-deep-rl
Or get the file:
Browse all CLI commands →
Manual setup by platform

Claude Code

~/.claude/skills/alirezarezvani-spinning-up-deep-rl/SKILL.md

Setup guide →
0Save

Instructions

Spinning Up in Deep RL

Author: Joshua Achiam (OpenAI) | Source: spinningup.readthedocs.io, MIT | Chapters: 20 | Generated: 2026-08-25

How to Use This Skill

  • No argument — load the core frameworks below
  • A topic — ask about advantage function, target networks, entropy regularization;
    I resolve it through the Topic Index and read that chapter file
  • chNN — I load that chapter's summary
  • "what chapters do you have?" — the full index
/cs-spinning-up-deep-rl                      # core frameworks + chapter index
/cs-spinning-up-deep-rl entropy regularization   # topic index -> ch19, read that chapter
/cs-spinning-up-deep-rl ch09                 # one chapter summary

When you ask about something not in Core Frameworks, I read the relevant chapter file before
answering rather than guessing from the index.


Core Frameworks & Mental Models

The RL problem

pi* = argmax_pi J(pi), where J(pi) = E_{tau~pi}[R(tau)]. Every algorithm approximates
this; where it substitutes a different objective (a Bellman residual, a surrogate), that
substitution is the source of its failure modes. Four value functions — V^pi, Q^pi, V*,
Q* — all obey Bellman self-consistency, and a*(s) = argmax_a Q*(s,a) is why Q-learning
is a viable family at all. Advantage A^pi(s,a) = Q^pi(s,a) - V^pi(s) is the relative-quality
signal policy gradients run on. (ch07)

The two branching questions

Place any algorithm by asking: does it have or learn a model, and what does it learn
(policy, Q-function, value function, model). That generates the whole landscape. (ch08)

Policy optimization vs Q-learning — the central trade-off

  • Policy optimization is principled: you directly optimize the thing you want. Stable
    and reliable. On-policy, so it cannot reuse data, so it is sample-hungry.
  • Q-learning only indirectly optimizes performance, by training Q_theta to satisfy a
    self-consistency equation. Many failure modes, so less stable. But substantially more
    sample efficient when it works, because it reuses everything.
  • Satisfying the Bellman equations well carries no guarantee of good policy performance.
  • The two are not exclusive — DDPG and SAC live between them deliberately. (ch08)

The policy gradient template

grad J = E[ sum_t grad log pi_theta(a_t|s_t) * Phi_t ]. Five valid choices of Phi_t:
full return, reward-to-go, reward-to-go minus a baseline, Q^pi, and A^pi. All share an
expectation and differ in variance. Two rules get you from the first to the last:

  • Don't let the past distract you — drop rewards obtained before the action. Those terms
    had zero mean and nonzero variance: pure noise.
  • Baselines — by the EGLP lemma, any state-only b(s) can be added or subtracted freely.
    The standard choice is V^pi(s_t), learned by MSE regression onto reward-to-go. (ch09)

The policy-gradient loss is not a loss function

Its data distribution depends on the parameters, and it does not measure performance even in
expectation. Only at the current parameters, with data from those parameters, does it have
the negative gradient of performance. You can send it to negative infinity while performance
craters, and it usually will. Only average return means anything.
(ch09)

Broken RL code almost always fails silently

It runs fine; the agent just never learns. Usually something is computed with the wrong
equation, on the wrong distribution, or piped to the wrong place. If it doesn't work, assume
there's a bug
before touching hyperparameters. Debug by measuring everything and reading the
code critically. The archetype is one missing squeeze: a [N] vs [N,1] shape mismatch is
broadcast-compatible, raises nothing, and silently turns the Bellman backup into an [N,N]
matrix. (ch10, ch12)

Learn by doing

Write your own implementations, shortest correct version of each, simplest algorithms
first
. VPG, DQN, A2C, PPO, DDPG, roughly in that order; ~250-300 lines each. Single-threaded
before parallel. Iterate fast in simple environments — under 5 minutes turnaround at the
debug stage.
Do not attempt Atari or Humanoid before the toy task works. Read papers for
their ablations and supplementary material, but do not overfit to paper details (the
original DDPG's architecture, init scheme and batch norm are not strictly necessary) or to
existing implementations
(their abstractions serve reuse, not your single use case). (ch10)

Rigor: four standards

  1. Fair comparisons — tune the baseline as hard as your method; never handicap it.
  2. Remove stochasticity as a confounder — at least 3 seeds, 10 or more to be thorough.
    Two seed groups can produce curves that look like different distributions.
  3. High-integrity experiments — launch fresh final runs and precommit to reporting them.
    Tuning produces hypotheses; final runs produce conclusions.
  4. Check each claim separately — ablate every design decision. (ch10)

The safe-step family (on-policy)

VPG takes an unconstrained gradient step, so a single bad step can collapse performance.
TRPO constrains the step in KL-divergence between policies, not distance in parameter
space
, then backtracking-line-searches until the exact constraint holds. PPO drops the
constraint and instead clips the objective so the policy gains nothing by moving far,
which is first-order, far simpler, and empirically at least as good. (ch14, ch15, ch16)

The overestimation family (off-policy)

DDPG amortizes the intractable continuous max_a Q(s,a) into a learned policy:
max_a Q(s,a) ~= Q(s, mu(s)). It needs a replay buffer (licensed because the Bellman
equation is indifferent to how data was collected) and target networks (because the target
otherwise depends on the parameters being trained). Its failure mode is Q-value
overestimation, which the policy actively exploits
. TD3 answers with clipped double-Q,
delayed policy updates and target policy smoothing. SAC adds entropy regularization,
making the explore-exploit trade-off an explicit coefficient alpha. (ch17, ch18, ch19)


Chapter Index

#TitleKey Frameworks
ch01IntroductionThe missing middle step, Code Design Philosophy
ch02InstallationInstall-then-verify, MuJoCo optionality
ch03Algorithms: What's Included and WhyThe two lineages, on/off-policy trade-off, code template
ch04Running ExperimentsOne flag per kwarg, ExperimentGrid, save-dir suffixes
ch05Experiment OutputsTools not files, watch-then-measure
ch06Plotting ResultsPerformance alias, prefix autocompletion, seed averaging
ch07Part 1: Key Concepts in RLMDPs, four value functions, Bellman equations, advantage
ch08Part 2: Kinds of RL AlgorithmsTaxonomy, model bias, policy-opt vs Q-learning
ch09Part 3: Intro to Policy OptimizationLog-derivative trick, EGLP lemma, reward-to-go, baselines
ch10Spinning Up as a Deep RL ResearcherLearn by doing, three idea frames, four rigor standards
ch11Key Papers in Deep RL13-section topic map
ch12ExercisesProblem Set 1 and 2, the silent DDPG bug
ch13BenchmarksThe parity disclosure, family-specific metrics
ch14Vanilla Policy GradientThe six-step loop
ch15Trust Region Policy OptimizationKL trust region, line search, conjugate gradient
ch16Proximal Policy OptimizationPPO-Clip, KL early stopping
ch17Deep Deterministic Policy GradientMSBE, replay buffers, target networks, polyak
ch18Twin Delayed DDPGClipped double-Q, delayed updates, target smoothing
ch19Soft Actor-CriticEntropy regularization, reparameterization, squashed Gaussian
ch20Logger, MPI Tools and Run UtilsEpochLogger pattern, MPI PyTorch order

Topic Index

  • Advantage function ch07, ch09, ch14
  • Baselines ch09
  • Bellman equations ch07, ch17
  • Benchmarks / parity ch13, ch01
  • Clipped double-Q ch18, ch19
  • Continuous action spaces ch07, ch17
  • Debugging / silent failure ch10, ch12
  • DDPG ch17, ch03, ch08
  • Entropy regularization ch19
  • Exploration vs exploitation ch14, ch17, ch19
  • GAE ch09, ch14
  • Installation ch02
  • KL divergence / trust region ch15, ch16
  • Logging ch20, ch05
  • MDPs ch07
  • Model-based RL ch08
  • MPI / parallelization ch20, ch02, ch04
  • MSBE ch17
  • Off-policy ch03, ch08, ch17
  • On-policy ch03, ch08, ch14
  • Papers / literature ch11, ch10
  • Plotting ch06, ch13
  • Policies (categorical, Gaussian, squashed) ch07, ch19
  • Policy gradient derivation ch09
  • PPO ch16, ch03
  • Q-learning ch08, ch07
  • Replay buffer ch17
  • Reparameterization trick ch19, ch10
  • Research process / rigor ch10, ch13
  • Reward-to-go ch09
  • Running experiments ch04, ch05
  • SAC ch19, ch03, ch08
  • Seeds / variance ch10, ch13, ch04
  • Target networks / polyak ch17, ch18
  • TD3 ch18, ch12
  • TRPO ch15, ch03
  • Value functions ch07, ch09
  • VPG ch14, ch09

Supporting Files

  • glossary.md · patterns.md · cheatsheet.md

Scope & Limits

Covers the Spinning Up documentation only, as of the January 2020 PyTorch update. It does
not cover: DQN and the discrete-action value-learning family (referenced, never
implemented here), recurrent or convolutional architectures, partially-observed settings,
model-based implementations, exploration/meta-RL/hierarchy beyond ch11's reading list, or any
deep RL work after early 2020. The six implementations are educational; ch13 says which are
research-grade. For topics beyond this source, I say so rather than improvising.


Compiled from OpenAI's Spinning Up in Deep RL documentation (MIT, Copyright (c) 2018 OpenAI),
primarily developed by Joshua Achiam. Structured study notes, not a reproduction of the source.

This skill doesn’t include stateful context yet, instructions only. Learn about stateful skills.

Security

Loading security scan...

Reviews (0)

Browse all →
senior-architectSystem architecture decisions with a written rationale: monolith vs microservices, database choice, scaling limits, ADRs, Mermaid diagrams. Load whenever the user asks should we split, which database, will it scale, or wants an ADR.33 installsseo-auditFind why a site is not ranking: technical SEO, on-page issues, meta tags, site health. Use whenever the user asks why a page is not on Google, why traffic dropped or for an SEO audit.31 installsgrill-meInterview the user relentlessly about a plan or design until reaching shared understanding, resolving each branch of the decision tree. Use when user wants to stress-test a plan, get grilled on their design, or mentions "grill me".23 installscode-reviewerUse for any code review: a pull request, a diff, a commit, or a pasted function, handler or file in TypeScript, JavaScript, Python, Go, Swift, Kotlin, C#/.NET, Java, C, C++, Rust, Ruby, PHP or Dart/Flutter. Applies per-language rule packs (security such as SQL injection and missing auth, async and resource handling, error handling, performance) and scripts that score a PR's risk and complexity, then gives a merge verdict with blocking and non-blocking findings. Use whenever the user asks to review, check or look over code, says 'code review', 'review this PR', 'review this diff' or 'is this safe to merge', or asks what is wrong with a snippet, even a single function.22 installscode-to-prdUse when asked to write a PRD or product spec from an existing codebase (reverse-engineer requirements, document pages, fields, routes and endpoints). Maps the code with codebase_analyzer.py and scaffolds the PRD with prd_scaffolder.py.21 installssenior-qaWrite and improve tests for React or Next.js apps: Jest, React Testing Library, MSW mocks, Playwright E2E, coverage gaps. Use whenever the user asks to add tests to a component or page, mock an API, set up end-to-end tests or raise coverage.17 installs

More from Multi-Domain Skills

View source →
senior-frontendBuild and review React, Next.js, TypeScript or Tailwind frontends: components, scaffolding, performance and bundle size. Use whenever the user wants a new component or app, a page feels slow, the bundle is too big, or asks for a frontend code review.634 installsui-design-systemUse when building a design system: tokens, component docs, responsive scales or developer handoff. Generates tokens with design_token_generator.py.534 installssenior-backendBuild and fix backend services: REST or GraphQL APIs, auth, microservices, PostgreSQL queries, migrations and load tests. Use whenever the user's API is slow or broken, needs login or auth added, a schema change, or a new endpoint or service scaffolded.246 installsself-improving-agentCurate what the agent has learned into durable project knowledge. Reviews Claude Code auto-memory (MEMORY.md and its topic files) for learnings worth keeping, promotes proven ones into CLAUDE.md or .claude/rules/, records a correction as a lesson that persists across sessions, prunes stale or duplicate entries, and turns a recurring fix into a reusable skill. Use whenever the user asks what you have learned or saved about the project, which memories should become permanent rules, to remember a lesson or stop repeating a mistake, or to clean up, audit or check memory health.173 installssocial-media-managerPlan social media: strategy, content calendar, community management, follower growth. Use whenever the user asks what to post and when, or how to grow followers. Single posts: social-content.136 installsmarketing-strategy-pmmUse for product positioning, ICP, competitive battlecards or a go-to-market plan, before drafting. Applies April Dunford's positioning method and produces the positioning statement, battlecards and launch plan.72 installs

More Build skills

Browse category →
frontend-designGuidance for distinctive, intentional visual design when building new UI or reshaping an existing one. Helps with aesthetic direction, typography, and making choices that don't read as templated defaults.345 installsusing-superpowersUse when starting any conversation - establishes how to find and use skills, requiring skill invocation before ANY response including clarifying questions145 installsweb-gameScaffolds a browser-based game with Phaser 3, PixiJS, or Three.js including game loop, asset pipeline, responsive canvas, input handling, audio, save/load, and deployment to itch.io or web. Triggers: on: "web game", "browser game", "html5 game", "phaser game", "pixi game".132 installsflutterBuilds Flutter applications from videos, screenshots, descriptions, or app clone requests. Triggers on: flutter app, build a mobile app, replicate this app in Flutter, build from video, build from screenshots, clone this app, build an app, make an app like, recreate this UI.126 installsreverse-engineer-anythingReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.109 installsgsap-pluginsOfficial GSAP skill for GSAP plugins — registration, ScrollToPlugin, ScrollSmoother, Flip, Draggable, Inertia, Observer, SplitText, ScrambleText, SVG and physics plugins, CustomEase, EasePack, CustomWiggle, CustomBounce, GSDevTools. Use when the user asks about a GSAP plugin, scroll-to, flip animations, draggable, SVG drawing, or plugin registration.86 installs

Frequently asked questions about spinning-up-deep-rl

What does the spinning-up-deep-rl skill do?

Learn or apply deep reinforcement learning with OpenAI Spinning Up: policy gradients, VPG, PPO, SAC, TD3, DDPG, TRPO. Use whenever an RL agent will not learn, reward stays flat, or the user asks how PPO or SAC works. It's a reusable SKILL.md instruction set that loads into your AI coding assistant on demand, no prompt engineering, no copy-pasting every session.

How do I install the spinning-up-deep-rl skill?

Run `npx @skills-hub-ai/cli install alirezarezvani-spinning-up-deep-rl` from your terminal. The CLI writes the SKILL.md to the correct location for your AI tool (e.g. ~/.claude/skills/alirezarezvani-spinning-up-deep-rl/ for Claude Code or ~/.cursor/skills/ for Cursor with --target cursor) and adds it to your project's .skills.json lockfile.

Which AI tools does spinning-up-deep-rl work with?

spinning-up-deep-rl runs in Claude Code. It follows the open Agent Skills standard (SKILL.md), so the same skill works in every supported tool without modification.

Is the spinning-up-deep-rl skill free?

Yes. Every skill on skills-hub.ai is free and open-source. There are no premium tiers, paywalls, or usage limits. You only pay for whatever AI assistant you're already using.

How do I use spinning-up-deep-rl after installing it?

In Claude Code, type `/alirezarezvani-spinning-up-deep-rl` (or whatever slash command the skill registers) and the AI follows the skill's instructions immediately. You can also reference it by name in natural language, your AI loads the skill into context when relevant.

Can I share the spinning-up-deep-rl skill with my team?

Yes. Commit your project's .skills.json lockfile and teammates run `npx @skills-hub-ai/cli install` (no args) to install every skill at the exact version you pinned. Organization-scoped installs work via skills-hub.ai organizations.