Skip to content

Add gradient descent arena at /descent#167

Open
ianalloway wants to merge 1 commit into
mainfrom
claude/gradient-descent-729tge
Open

Add gradient descent arena at /descent#167
ianalloway wants to merge 1 commit into
mainfrom
claude/gradient-descent-729tge

Conversation

@ianalloway

Copy link
Copy Markdown
Owner

Summary

  • Adds /descent — drop SGD, momentum, and Adam on a loss surface and watch them race
  • src/features/descent/optimizers.ts: three surfaces with analytic gradients (tilted bowl, two gaussian pits, rippled bowl), and the three optimizers with proper formulations (momentum with velocity, Adam with bias-corrected first/second moments)
  • src/pages/Descent.tsx: contour-banded loss heatmap rendered to an offscreen buffer, click-to-drop optimizer races with colored trails, surface picker, learning-rate slider
  • src/App.tsx: lazy-loaded /descent route with SEO metadata

How it works

  • The heatmap normalizes the surface over [−1,1]², bright green = low loss, with faint contour banding
  • Clicking drops all three optimizers at that point; each steps its own update rule against the same analytic gradient each frame
  • Ripples is the local-minima demo: SGD stalls in dips, momentum coasts through; Two pits splits the field between a shallow and deep minimum depending on the start; the bowl's anisotropy (1.8× steeper in y) shows momentum's characteristic overshoot ringing
  • Adam's step is internally scaled 3× lr so all three are watchable at the same slider setting; convergence stops a trail when the gradient is negligible

Test plan

  • Load /descent — two-pits surface, three dots race from the corner leaving cyan/yellow/pink trails
  • Click anywhere — all three restart from that point
  • Ripples at low lr — SGD (cyan) sticks in a dip, momentum (yellow) escapes further downhill
  • Two pits: drops near the shallow pit get trapped there; near the ridge they split
  • Bowl: momentum visibly oscillates across the steep axis before settling
  • Learning rate high (0.08) — overshooting/zigzagging; low (0.002) — smooth slow creep
  • Surface buttons rebuild the heatmap and restart
  • Trails and dots render over the heatmap at any window size

Generated by Claude Code

Three loss surfaces with analytic gradients (tilted bowl, two gaussian
pits of different depths, rippled bowl) rendered as a contour-banded
heatmap; clicking drops SGD, momentum, and bias-corrected Adam at the
same point and they race downhill leaving colored trails. Adam's step
is scaled 3x lr so the comparison is visually fair. Ripples surface
shows SGD stalling in local dips while momentum coasts through; two
pits shows optimizers splitting between the shallow and deep minima
depending on start point. Learning-rate slider applies live; positions
clamp to the domain and optimizers stop at negligible gradient.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WgEKRuVdor8KhaiPkv38aQ
@netlify

netlify Bot commented Jul 19, 2026

Copy link
Copy Markdown

Deploy Preview for ianalloway ready!

Name Link
🔨 Latest commit af3ce9a
🔍 Latest deploy log https://app.netlify.com/projects/ianalloway/deploys/6a5c57e99004e000081e7f46
😎 Deploy Preview https://deploy-preview-167--ianalloway.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@vercel

vercel Bot commented Jul 19, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
ian-web-forge Ready Ready Preview, Comment Jul 19, 2026 4:51am

@ianalloway
ianalloway marked this pull request as ready for review July 19, 2026 04:53
Copilot AI review requested due to automatic review settings July 19, 2026 04:53
@cursor

cursor Bot commented Jul 19, 2026

Copy link
Copy Markdown

Bugbot is not enabled for your account, so this pull request was not reviewed.

Enable Bugbot in the Cursor dashboard to get automatic reviews on future PRs.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants