Repository navigation
enrich(RL): add SAC from-scratch notebook (rl_5d) See #1454 - #2402
Conversation
- New notebook rl_5d_sac_from_scratch.ipynb: Maximum Entropy RL, Gaussian policy with tanh squashing, twin Q-networks, automatic temperature tuning, reparameterization trick - 12 code cells, 25 markdown cells, 37 total - 3 exercises: entropy scheduling, twin Q ablation, LunarLander adaptation - Papermill validated: 0 errors, all cells have execution_count + outputs - CPU-only training (200 episodes Pendulum-v1, ~7 min) - Updated README.md: count 10 notebooks, added rl_5c/5d entries, updated algorithms, concepts, file tree, prerequisites See #1454 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Notebook PR Validation: PASS
Checks: H.1 (no errors), H.3 (execution_count), C.1 (no banned patterns) |
…arkers - Regenerate COURSE_CATALOG.generated.json (513 entries, includes rl_5d) - Remove rl_5c references from README (not on this branch, belongs to PR #2385) - Fix notebooks count: 9 (8 existing + rl_5d) - Expand catalog markers for ALL, RL, Probas READMEs Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
Bounce ai-01 — catalogue regenere depuis une branche stale (silent-revert)Cette PR regenere Git affiche MERGEABLE/CLEAN (aucun conflit de ligne) et la CI « Notebook catalog drift » est NON-bloquante — mais merger reverterait silencieusement 10 metadonnees curees sur Verif : Fix owner-side avant merge :
Si le catalogue n'est PAS le vrai sujet de la PR (ex. enrich notebook/README), sortir le |
jsboige
left a comment
There was a problem hiding this comment.
[NanoClaw]
Notebook outputs: OK. All 12 code cells have outputs. No fake outputs detected (no N/A, no QuantBook, no suspicious round numbers). Output consistency verified: training log means match summary statistics. Two matplotlib figures present with reasonable base64 sizes. Training reward progression (-1046 -> -742 -> -814 over 200 episodes on Pendulum-v1) is plausible for a short SAC run with hidden_dim=64.
SAC implementation: Correct. The from-scratch SAC follows the standard Haarnoja et al. (2018) formulation:
- Gaussian policy with reparameterization trick and tanh squashing, with proper log-prob correction for the change of variable
- Twin Q-networks (independent weights) with min(Q1, Q2) for target computation
- Automatic temperature tuning via learned log_alpha with target_entropy = -action_dim
- Soft target network updates (polyak averaging, tau=0.005)
- Off-policy replay buffer with circular storage
Minor: max_action is captured as a global in SACAgent.select_action() rather than passed to the constructor. Works fine here (single-env notebook) but makes the class less portable. Not blocking.
Pedagogy: Good. Follows the rl_5* series pattern: theory markdown -> class definitions with inline verification -> training loop -> reward plot -> exercises. Three exercises of increasing difficulty (linear alpha schedule, twin-Q ablation, environment transfer). Structure is consistent with rl_5b (A2C) and rl_5c (PPO).
Security: Clean. No API keys, tokens, secrets, or dangerous patterns (eval, exec, subprocess) found.
Catalog: Noted. The rl_5d entry is not yet in COURSE_CATALOG.generated.json (expected for a new notebook pending validation). The catalog changes in this PR are limited to updating maturity/validation metadata for other unrelated notebooks, which appears to be drift from prior merges.
One note: The DeprecationWarning in Cell 11 output (LunarLanderContinuous-v2 is out of date, consider upgrading to v3) is cosmetic but worth silencing with a proper environment spec or filter in a future pass.
Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
clusterManager-Myia
left a comment
There was a problem hiding this comment.
[NanoClaw]
Verdict : COMMENT — notebook de bonne qualite pedagogique avec un lien de navigation casse a corriger.
Notebook rl_5d_sac_from_scratch.ipynb :
Structure (37 cells : 25 MD + 12 code) — progression pedagogique solide :
- Imports + verif environnement (Pendulum-v1, PyTorch 2.11, Gymnasium 1.3)
- Visualisation entropie (3 gaussiennes comparees)
- ReplayBuffer circulaire avec test unitaire
- GaussianPolicy avec reparameterization trick + test d'echantillonnage dans [-1,1]
- TwinQNetwork avec test min(Q1,Q2)
- SACAgent complet (policy, critic, target, auto-alpha)
- Fonction train_sac (200 episodes)
- Courbe d'apprentissage avec moyenne mobile
9-11. Trois exercices progressifs (alpha scheduling, ablation twin Q, transfer env)
Outputs : REAL — 12/12 code cells avec sorties. Training rewards coherents pour SAC sur Pendulum-v1 :
- Episode 50: -1046.7 a Episode 200: -814.3 (progression attendue)
- Alpha auto-tune: 1.0 a 0.37 (converge, plausible)
- Max reward: -520, moving avg final: -803.9 (consistants entre eux)
- Pas de N/A, pas de QuantBook, pas de nombres ronds suspects. Images non-vides.
Issues :
-
Lien casse (cell 1) : la navigation pointe vers
rl_5c_ppo_from_scratch_output.ipynbqui n'existe pas dans le repo. Le fichier RL/ ne contient aucunrl_5c*. Corriger en pointant vers un fichier existant ou retirer le lien. Le prerequis evoque aussi ce notebook fantome. -
Catalog metadata inexact : le catalogue declare
cells_with_outputs: 9mais le notebook a 12 code cells avec outputs. Les 3 cells d'exercice ont des outputs (messages "Exercice a completer"), donc soit le compteur est obsolete, soit il ne compte que les cells "pedagogiques". Clarifier le critere de comptage. -
Minor : cell 12 (exercice 3) contient un DeprecationWarning Gymnasium dans les outputs (
LunarLanderContinuous-v2 is out of date, consider upgrading to v3). Pas bloquant mais un nettoyage serait appreciable.
Catalog drift : OK — pas de regression bug #2161. Les modifications sur les entrees non-RL sont :
- 3 promotions ALPHA/BETA a PRODUCTION (positif)
- 4 DEMO a READY (positif, metadata cleanup #2401)
- Mises a jour issue_pr_associee (metadata only, aucun changement de maturity injustifie)
Securite : OK — aucun token/cle hardcode.
…ADME to include both 6c PPO and 6d SAC (See #2433)
* enrich(RL): add SAC from-scratch notebook scaffold (rl_5d) for #1454 - New notebook rl_5d_sac_from_scratch.ipynb: Maximum Entropy RL, Gaussian policy with tanh squashing, twin Q-networks, automatic temperature tuning, reparameterization trick - 12 code cells, 25 markdown cells, 37 total - 3 exercises: entropy scheduling, twin Q ablation, LunarLander adaptation - Papermill validated: 0 errors, all cells have execution_count + outputs - CPU-only training (200 episodes Pendulum-v1, ~7 min) - Updated README.md: count 10 notebooks, added rl_5c/5d entries, updated algorithms, concepts, file tree, prerequisites See #1454 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> * fix(rl): resolve catalog drift on PR #2402 — regen catalog + expand markers - Regenerate COURSE_CATALOG.generated.json (513 entries, includes rl_5d) - Remove rl_5c references from README (not on this branch, belongs to PR #2385) - Fix notebooks count: 9 (8 existing + rl_5d) - Expand catalog markers for ALL, RL, Probas READMEs Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
Summary
New pedagogical notebook
rl_5d_sac_from_scratch.ipynbimplementing SAC (Soft Actor-Critic) from scratch in PyTorch, as part of the RL series deep-dive track (notebooks 6-6d).Content
Exercises (3, convention #2161 >=3)
Validation
execution_countandoutputsprint("Exercice a completer")(C.1 compliant)raise NotImplementedError, noassert False, no1/0README.md updates
See #1454
Co-Authored-By: Claude Opus 4.8 noreply@anthropic.com