Skip to content

Add momentum and the momentum coefficient - #559

Merged
d-morrison merged 6 commits into
mainfrom
claude/project-thread-gc1kf8
Oct 31, 2026
Merged

d-morrison merged 6 commits into
mainfrom
claude/project-thread-gc1kf8

Conversation

@d-morrison

Copy link
Copy Markdown
Contributor

Requested by Ezra · project thread

Part 4 of moving general gradient-descent content from lds to mds, after mds#558. This PR adds momentum (the heavy-ball method) and the momentum coefficient to the optimization gradient descent page, each with an example in R and Python.

The lds chapter's cost C, parameters, and learning rate become mds's f, iterates, and step length. The lds definition of momentum sets the learning rate outside the velocity, and this PR keeps that form. The lds figure of momentum paths on the narrow valley stays in lds, since it belongs to the lds exercise.

After this merges and the site publishes, a follow-up lds PR will replace the lds copies with links. Adaptive methods and Adam, then the step-count schedules, are the next moves.

Not rendered locally (the container has no Quarto or R packages). I ran the R and Python logic on its own and got the same values: after 20 updates plain descent is at 0.1216, momentum at 0.3447, and momentum's lowest point is -0.6037 at update 9. The PR build is the render check.


Generated by Claude Code

Moved from the lds gradient descent chapter, reworded to mds notation
(f, step length, iterates); lds will link here.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019xfc9ow6EykAkrucpc8Fyw
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019xfc9ow6EykAkrucpc8Fyw
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019xfc9ow6EykAkrucpc8Fyw
@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

@github-actions

This comment has been minimized.

…cters

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019xfc9ow6EykAkrucpc8Fyw
@github-actions

Copy link
Copy Markdown
Contributor

Claude finished review — View run


I fetched PR #559 live: it is open, not a draft, not merged, and its head is f03f65d66b555d2c9a80f4ef304aaf4613a41c5b. That is the commit I reviewed, so the review stands.

Review of PR #559 at f03f65d

This round covers f03f65d, the one commit after b4dd5fc. It touches _exm-momentum-coefficient.qmd and _exm-momentum.qmd. I read the diff but did not render the site or run the linter.

What changed since the last round

The commit replaces each trailing # nolint: undesirable_function_linter. on an rbind line with a # nolint start: undesirable_function_linter. / # nolint end pair on its own lines. Nothing else changed. The R code is the same, so the output is unchanged.

  • _exm-momentum-coefficient.qmd:20-22: the pair wraps the rbind(beta = ..., weight = ..., memory = ...) call.
  • _exm-momentum.qmd:30-32: the pair wraps summary_mo <- rbind(last = ..., lowest = ...).

The start/end syntax is valid for lintr and exempts only the named linter. The change also keeps the code lines under 80 characters, which was the commit's goal.

Findings

None. No math, prose or links changed, so the macro and line-break checks have nothing new to examine. The earlier optional note about a missing momentum-coefficient macro for \beta is unchanged and still non-blocking.

Verdict

Ready for merge. The prior review at #559 (comment) (verdict: Ready for merge) still stands. This commit only reformats the lint exemption and adds no new problems.

Stopping Point: Clean stopping point reached --- session done; UMS executed; no follow-up items pending

Structured Review Data (JSON)
{
  "schema_version": "1.1",
  "reviewer": "claude",
  "commit_sha": "f03f65d66b555d2c9a80f4ef304aaf4613a41c5b",
  "verdict": "CLEAN",
  "findings": [],
  "detailed_assessment": "The nolint start and end pairs around the rbind calls in _exm-momentum.qmd and _exm-momentum-coefficient.qmd are valid lintr syntax and exempt only undesirable_function_linter.",
  "holistic_assessment": "The commit changes only lint-exemption formatting with no change to computed output, prose, math or scope, so the earlier clean verdict and its regression assessment remain valid."
}

Reviewed commit: f03f65d

@github-actions

Copy link
Copy Markdown
Contributor

💰 Cost: $0.2229 (review) — run

@github-actions

github-actions Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor
PR Preview Action v1.8.1
Preview removed because the pull request was closed.

2026-10-31 07:09 UTC

@d-morrison
d-morrison merged commit 4cacd9f into main Oct 31, 2026
39 checks passed
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.

2 participants