fix(deep-learning-book): address review nits — internal naming and SAME-padding disclosure

Two small findings from the automated review on PR #994, both verified against the
source before fixing.

1. reading_path_planner.py: the plan() parameter was named include_optional while
   the CLI flag and call site both use include_intro, and it only ever gates ch01.
   Renamed the parameter and its use for consistency. Behavior unchanged, confirmed
   both ways: --include-intro keeps ch01 first, the default drops it.

2. model_arithmetic.py: conv2d "same" padding computes ceil(H / stride), which is
   the TensorFlow/Keras SAME convention, and the tool did not disclose which
   framework it matches. Documented it in the module docstring — including that
   PyTorch's padding='same' is symmetric-only and rejects a stride other than 1, so
   a strided PyTorch layer will not match, with "valid" named as the exact-case
   workaround — plus a pointer comment at the computation itself. No arithmetic
   change; the sample stack reports identical parameters and FLOPs.

The reviewer's third point was that it could not execute the gates in a sandboxed
environment. No code change: those gates were run locally and are green.

Verified after the change: compileall, check_paths, check_frontmatter,
check_dual_publish, check_model_freshness, smoke_scripts (696 passed),
derive_counters --check, check_skill_names, check_plugin_json, the book-skill
validator, and --sample --output json on all four tools.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01BswsZp5zrJWFAGU6KWNA1s
This commit is contained in:
Claude 2026-08-25 19:02:25 +00:00
parent cf572c83b6
commit c75500f804
No known key found for this signature in database
2 changed files with 10 additions and 2 deletions

View file

@ -14,6 +14,12 @@ forward pass; a training step costs roughly 3x a forward pass (forward + backwar
Layer types: input, linear, conv2d, pool2d, flatten, embedding, layernorm, activation,
dropout, mha (multi-head self-attention), lstm, gru.
conv2d "same" padding follows TensorFlow/Keras SAME: output is ceil(H / stride), with
any needed padding split across the two sides (and the extra pixel going to the bottom
and right at even kernel sizes). PyTorch's padding='same' is symmetric-only and rejects
a stride other than 1, so a strided PyTorch layer will not match this row declare it
as "valid" with the padding you actually apply if you need that case exactly.
Standard library only. No frameworks, no network calls.
Exit codes:
@ -87,6 +93,8 @@ def step(layer: dict, shape: tuple[int, ...], index: int) -> tuple[tuple[int, ..
)
channels, height, width = shape
if padding == "same":
# TensorFlow/Keras SAME convention; see the module docstring for how this
# differs from PyTorch's stride-1-only padding='same'.
out_h, out_w = math.ceil(height / stride), math.ceil(width / stride)
elif padding == "valid":
out_h = (height - kernel) // stride + 1

View file

@ -242,12 +242,12 @@ def out_of_scope_hits(goal: str) -> list[str]:
def plan(goal: str, background: str, hours_per_week: float,
include_optional: bool) -> dict:
include_intro: bool) -> dict:
lane_key, _ = score_lanes(goal)[0]
lane = LANES[lane_key]
targets = lane["targets"]
chapters = close_prerequisites(targets)
if not include_optional and lane_key != "complete":
if not include_intro and lane_key != "complete":
# ch01 is context; keep it only when the reader asked for everything.
chapters = [c for c in chapters if c != 1]
ordered = order_path(chapters)