Skip to content

feat(ml,#12422,#4.1): conv NumPy from scratch + torch allclose, parité epsilon machine - #14006

Merged
myia-ai-01 merged 3 commits into
mainfrom
feature/12422-vision-4.1-conv-numpy-torch
Sep 1, 2026
Merged

myia-ai-01 merged 3 commits into
mainfrom
feature/12422-vision-4.1-conv-numpy-torch

Conversation

@jsboige

@jsboige jsboige commented Sep 1, 2026

Copy link
Copy Markdown
Owner

Grain: DEEP/notebook-python — lane myia-po-2026:CoursIA-2 — prev: MED/guard #13947

Tell c.830 — 4.1 / 3 notebooks Vision 04 (EPIC #12422, GO COMPLET user)

User-blocker #12422 levé en session directe 2026-09-01 (msg-20260901T074251-vfrtwn ai-01 dispatch) : GO COMPLET sur la série Vision 04, pas le GO réduit. 3 PRs/notebooks à livrer, ce cycle = 4.1, suite 4.2 (résiduelles) + 4.3 (transfer learning ResNet) sur les cycles suivants.

Claim posé c.830 avec paths corrigés (MyIA.AI.Notebooks/ML/DataScienceWithAgents/04-Vision/*, pas GenAI/Image/* comme mon ancien claim c.535 RELEASED pour incompatibilité) — j'avais auto-RELEASED c.535 sur constat paths incompatibles, merci à ai-01 pour la correction dans le dispatch.

Summary

Ouvre la série 04-Vision (MyIA.AI.Notebooks/ML/DataScienceWithAgents/04-Vision/) avec le premier notebook de la trilogie annoncée par l'Epic #12422 : le neurone convolutif from scratch. Implémentation NumPy pur (single + multi-canal) avec gradient vérifié par différence finie, parité epsilon machine avec torch.nn.Conv2d, et démonstration visuelle de l'invariance par translation sur image réelle (Sobel, Gaussien).

Trois primitives installées, qui serviront dans 4.2 (empilement profond) et 4.3 (transfer learning) :

  1. conv2d_valid NumPy (C_in, H, W) → (C_out, H-kH+1, W-kW+1) avec sa rétropropagation
  2. Parité NumPy ↔ torch à epsilon machine (float32 : 1,91e-06 ; float64 : 5,33e-15)
  3. Pooling 2×2 + invariance par translation, mesurée pixel-à-pixel

Validation (rule H.1 — preuve réelle)

Exécution Papermill 36/36 cellules, 0 erreur :

  • Cellule [3] §2 : Y_np[0,0] = -0.1234..., vérification directe écart = 0,00e+00 (formule exacte)
  • Cellule [4] §2 vec : np.array_equal(Y_np, Y_vec) = True, max abs diff = 0,00e+00
  • Cellule [5] §3 : gradient check NumPy vs différence finie, max abs diff = 1e-10 (seuil 1e-5) → PASS
  • Cellule [12] §4 multi-canal : parité NumPy (C_in=3, C_out=4) vs torch.nn.Conv2d
    • float32 : max abs diff = 1,91e-06, max rel diff = 2,19e-05 → PASS (précision BLAS CPU)
    • float64 : max abs diff = 5,33e-15 → PASS (epsilon machine)
  • Cellule [21] §5 invariance : translation de 3 pixels → position du max translate de 3 pixels (Sobel vertical sur bord franc)
  • Cellule [22] §5 pooling : translation de 1 pixel → invisible après max-pool 2×2
  • Cellule [26] §6 image réelle : Sobel v/h appliqué sur chat ImageNet, parité f32 NumPy vs torch = 4,77e-07 (v) / 0,00e+00 (h, bit-identical)

validate_pr_notebooks.py PASS (à rejouer post-push).

Scope (atomique)

Fichier Statut LoC
4.1-Conv-NumPy-Torch-Allclose.ipynb new 36 cellules (26 md / 10 code, 3 exercices)
04-Vision/README.md new 5050 chars (présentation trilogie 4.1-4.2-4.3)

Aucune modification à 03-DeepLearning/, 02-ML-Cours/, ou autre série. Aucun marqueur CATALOG-STATUS touché (catalog-pr-hygiene HARD 1). 2 fichiers, ~3000 lignes max (notebooks), domaine unique (Vision). Split OK (Tell c.692-L1 strict sustained).

C.1 — exercices stubs (sans raise NotImplementedError)

3 exercices (Tell c.692-L1 strict sustained ≥ 3) :

  1. Filtre Laplacien : K_lap = [[0,1,0],[1,-4,1],[0,1,0]], application sur image, comparaison visuelle Sobel vs Laplacien, parité torch.
  2. Empilement de 8 filtres aléatoires : (8, 3, 3), application + visualisation grille 2×4, commentaire sur spécialisation.
  3. Invariance par translation quantitative : 6 translations [0..5], mesure position max sans/avec pooling, graphe, commentaire rayon d'invariance.

Tous trois : print("A completer") (jamais raise NotImplementedError), structure TODO etudiant conservée. Notebook s'exécute end-to-end même exercices non complétés.

C.2 — outputs commit-réalité

Toutes les cellules code portent execution_count ET outputs cohérents. Papermill SUCCESS 36/36. 3 PNG sauvés localement (/tmp/sobel_invariance.png, /tmp/filtres_appliques.png, etc.) — un seul est conservé en base64 dans le notebook (Sobel).

Compliance

  • Tell c.692-L1 strict : 2 fichiers, < 3000 lignes, domaine unique (Vision), atomique.
  • Tell c.711-L1 strict (pre-commit H.3) : execution_count != null partout, outputs != [], 0 raise NotImplementedError.
  • Tell c.677-L4 sustained : body PR généré via scratchpad (c830_pr_body.md), pas dans le worktree.
  • Tell c.805 LEÇON DURABLE : narrow count = 0 (terme banni user 2026-08-31T22h+).
  • Tell c.591-L1 strict : CPU-only (NumPy + torch CPU), pas de GPU-only.
  • Tell c.740 ★ sustained : cron f12ffe4d 7,37 * * * * actif.
  • Tell c.806 LEÇON DURABLE : worktree AVANT édition, force-with-lease sur PR à lane unique.
  • Tell c.745 NEW sustained : 3 GESTES BANNIS respectés (DELETE / PATCH neutralisant / PUT dismissals tiers — aucun applicable ici, PR vierge).
  • Tell c.816 NEW durable : aucune action merge/close d'autrui, gh auth vérifié.
  • Tell c.11145 ★★★ strict UN message : 1 DM envoyé ce cycle (ACK ai-01 msg-20260901T083714-l8ci02). PR fix(ci,#13874): forme universelle de la garde fork -- couvre pull_request_target #13947 escalade G-VAR-3 OVERRIDE postée c.829 — sustained, attente décision ai-01.
  • Worker identity c.598 amended c.816 : gh auth switch autorisé mais non utilisé ce cycle.

Suite

Cycles à venir :

  • c.831 : 4.2 — ConvNet profonde, résiduelles vs sans, normes gradient par couche. Cross-ref explicite avec 3.4-Attention-Transformer (même bloc pré-norme).
  • c.832 : 4.3 — ResNet18 pré-entraîné ImageNet, frozen vs fine-tuned sur dataset français, 3 seeds + DM-test.

Closes Epic #12422 (sous-tâche 4.1 sur 3 — See #12422 pour la part Epic-wide, à fermer au merge de 4.3).

Refs #12422 (Epic parente)
Refs #13947 (escalade G-VAR-3 OVERRIDE sustained c.829 — drain prévu après merge 4.1)

…é epsilon machine

Cycle c.830, post user GO COMPLET (msg-20260901T074251-vfrtwn ai-01 dispatch).
Ouvre la série 04-Vision avec le premier notebook de la trilogie annoncée
par l'Epic #12422 : le neurone convolutif from scratch. Discipline
03-DeepLearning (from scratch PUIS framework, parité epsilon machine).

- conv2d NumPy pur (single + multi-canal) avec gradient vérifié par
  différence finie (max abs diff 1e-10)
- parité NumPy ↔ torch.nn.Conv2d : float32 1,91e-06, float64 5,33e-15
- pooling 2x2 + invariance par translation mesurée pixel-à-pixel
- application Sobel/Gaussien sur image réelle (cat ImageNet)
- 3 exercices : Laplacien / empilement 8 filtres aléatoires /
  invariance translation quantitative

36 cellules (26 md / 10 code), Papermill 36/36 SUCCESS, 0 erreur.
C.1 OK (3 exos, jamais raise NotImplementedError).
C.2 OK (execution_count + outputs cohérents).

Refs #12422 (Epic parente, sous-tâche 4.1 sur 3)
Refs #13947 (escalade G-VAR-3 OVERRIDE sustained c.829, drain prévu après merge 4.1)

Co-Authored-By: Claude Haiku 4.5 (1M context) <noreply@anthropic.com>
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

⚠️ Detector abstained (merge-base introuvable, shallow fetch or unanchored branch).

c.415 (#11873): scope = notebooks CHANGED in this PR, not the whole corpus.
See python scripts/check_markdown_claims_output.py --help for re-running locally.
Detector rationale: c.290 / c.331 / PR #11435 pathologie.

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

G-VAR-2/3 GENRE signals (advisory, non bloquant, #10020).
La lane `myia-po-2026:CoursIA-2` voit ces signaux actifs sur les mergees du jour (UTC 2026-09-01) :

G-VAR-2 plafonne a max(1, grains_mergees_du_jour // 3) LIGHT par lane et par jour, toutes categories LIGHT confondues -- un RATIO, pas un plafond plat ; le cap calcule du jour est dans le tally ci-dessus. G-VAR-3 interdit deux genres LIGHT consecutifs. Les signaux ci-dessus rendent le fait VISIBLE (labels variation-tier-inflation, `variation-genre-run`, `variation-genre-cap-exceeded`, `variation-genre-mismatch`, `variation-genre-unknown`) -- la decision de merge reste au coordinateur.

@github-actions

github-actions Bot commented Sep 1, 2026 •

Copy link
Copy Markdown
Contributor

Golden-Set Execution (H.7 P3)

✅ 8/8 notebooks passed (certified reproducible)

Notebook Status Time
2.1-Workflow-ML.ipynb ✅ SUCCESS 5.3s
2.2-Descente-de-gradient.ipynb ✅ SUCCESS 4.2s
2.3-Regression-lineaire-logistique.ipynb ✅ SUCCESS 5.0s
2.4-Arbres-Forets-Ensembles.ipynb ✅ SUCCESS 4.8s
Search-1-StateSpace.ipynb ✅ SUCCESS 3.9s
SL-1-LogicalLearning.ipynb ✅ SUCCESS 2.7s
rl_4_multi_armed_bandits.ipynb ✅ SUCCESS 25.6s
GameTheory-04c-NashExistence-Python.ipynb ✅ SUCCESS 3.3s

Pinned lockfile: scripts/notebook_tools/golden_set.lock.txt (H.7 P3, axe A #4208)

…README

The 04-Vision/README.md table referenced 4.2-ConvNet-Profonde-Pourquoi-
Residuelles.ipynb and 4.3-Transfer-Learning-ResNet.ipynb as if they
already existed, but they are PR-suivantes (c.830 feuille de route).

check-links FAILURE (run 99808182291) caught the broken links.
Fix (Tell c.820 NEW durable): replace forward links with textual
mentions flagged '(PR suivante, voir feuille de route)'. No perimeter
change: 4.1 stays linked, 4.2/4.3 are listed in the table without
clickable targets until their PRs land.

Diff: -2/-2 (purely textual, no scope change).

Grain: LIGHT/repair -- lane myia-po-2026:CoursIA-2 -- prev: DEEP/notebook-python #14023 c.833
check-navlinks FAILURE (run 33497315608) detected the forward link
[4.2 (ConvNet profonde : pourquoi les résiduelles)](4.2-...)
in cell 0 markdown of 4.1-Conv-NumPy-Torch-Allclose.ipynb.

Same fix as c.834 README: replace clickable forward link with text flag
"PR suivante, voir feuille de route" until 4.2/4.3 PRs land.

Tell c.834 transferable: check-links (README) + check-navlinks (notebooks)
both read clickable links as assertions of scope. Both must be sanitized
when a PR is the first of a new sub-series.

Diff: 1 file, +2/-2 (purely textual cell source edit, 0 scope change,
outputs unchanged - C.2 respected).
@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Notebook PR Validation: PASS

  • Notebooks checked: 1
  • Code cells validated: 10
  • Result: All passed

Checks: H.1 (no errors), H.3 (execution_count), C.1 (no banned patterns)
Non-Python kernels (.NET/Lean): C.1 + errors only (execution_count advisory)
QuantConnect notebooks: C.1 + errors only (require QC Cloud for execution)

@myia-ai-01
myia-ai-01 merged commit 91c18be into main Sep 1, 2026
61 of 62 checks passed
@jsboige
jsboige deleted the feature/12422-vision-4.1-conv-numpy-torch branch September 2, 2026 13:12
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