Reproduce a generative mechanism.
Train a small flow model locally, verify its gradients, preserve optimizer state and compare numerical samplers. The supplied Python reference uses only the standard library. No account, paid API, model download or GPU is required. Python 3.10 or newer is recommended.
Choose your depth
Use the browser flow lesson, then inspect the recorded run below. Predict how sample positions change from the starting cloud to the final frame. Save your own browser experiment to Project 6; software installation is optional.
These optional entry points do not add to required lesson completion or change published path requirements.
Inspect a supplied, reproducible run
The 370-parameter 3–16–16–2 model trained for 1,000 updates at rate 0.01. It uses the same original four-mode data and independent Gaussian/data pairing as the browser lesson: 32 training and 32 disjoint public development points. This is a synthetic mechanism study, not real-image model training or independent learner evidence.
Frame 0: 4/24 near centers; counts 0, 0, 2, 2; mean center distance 0.8842.
Recorded final result: 19/24 near centers; counts 4, 4, 6, 5; mean center distance 0.2820. Heun uses 16 steps × 24 points × 2 field evaluations = 768 calls. Training loss 1.5893 and development loss 1.5421 are velocity MSE, not exact likelihood. The imperfect final set is retained.
Read recorded frame coordinates
- [1.448549, 0.887777]
- [1.513084, 1.348792]
- [2.302003, -0.230314]
- [-1.203952, 0.171840]
- [-0.613882, 0.731365]
- [-1.415055, -0.011844]
- [-0.378284, 1.843211]
- [-1.968711, 0.975094]
- [-1.504718, 0.618986]
- [0.896241, -1.371799]
- [-0.554647, -0.275669]
- [0.834939, -0.365438]
- [1.392036, 0.525189]
- [1.454720, -1.029520]
- [-1.708941, 1.856083]
- [0.054135, -1.894893]
- [0.572588, -1.172332]
- [0.449206, -1.163630]
- [0.669538, 1.124448]
- [-0.302791, -0.070350]
- [1.675860, 0.719157]
- [0.181377, 0.046589]
- [-0.635922, 0.398450]
- [0.148418, -0.273492]
The separately implemented Python and TypeScript versions agreed on the recorded 1,000-update parameters within 1.5 × 10⁻¹³ and frame coordinates within 2.1 × 10⁻¹³ on the checked environment. The parity check allows 10⁻⁷ for floating-point differences; it does not promise bitwise identity across runtimes or prove sample quality. Recorded Python version: 3.9.6.
Run, resume and compare
Save the Python files in a local folder. Run these commands in that folder. The reference refuses to overwrite an existing output; choose new filenames when repeating a run.
python3 generative-flow.py check python3 generative-flow.py train first.json --updates 100 python3 generative-flow.py train resumed.json --resume first.json --updates 900 python3 generative-flow.py sample resumed.json euler.json --method euler --steps 32 --seed 7 python3 generative-flow.py sample resumed.json heun.json --method heun --steps 16 --seed 7
The two sampling commands use the same frozen model, seed and 768-call budget. Their paths can differ. Compare failures and coverage; equal calls are not equal elapsed time. Training counts are capped at 1,000 total, and sampling at 64 steps over 24 points. Interrupting a process leaves earlier checkpoint files intact; no output is written until the current computation completes.
Resume restores parameters, first and second Adam moments and the update number. Training pairs are deterministically selected by that update number. The command resumes the exported live model, while Project 6 imports the artifact's frozen sampling run. If a browser export contains a newer live model and older frozen run, those are intentionally different choices. Imported history is not authenticated. A changed learning rate is a changed experiment and must be reported.
Import euler.json or heun.json using the generative project. Samples and metrics are recomputed from numeric parameters. Add a diffusion or GAN capture at the same seed for the required different-mechanism comparison. Two samplers of the same flow alone do not satisfy that requirement.
Implement a step yourself
The exercise file contains an explicit unimplemented integrate function. Before editing, this command deliberately fails with NotImplementedError:
python3 generative-sampler-exercise.py
Implement Euler and Heun while preserving the input point. Count actual field queries, query Heun's predictor at the new time, reject invalid controls and return a new two-coordinate point. The public checks include constant fields, a linear field with a known solution and a time-dependent field that catches a stale second-query time. Add at least one counterexample of your own.
Then build your own objective and simultaneous-gradient calculation. Check all coordinates against finite differences on a small batch before scaling training. Keep the supplied reference unchanged and compare numerical results, optimizer resume and work accounting. Passing public checks is practice evidence; it does not establish independent authorship or implementation quality.
Explain the mechanism and its limits
- Data: original synthetic coordinates, fixed train/development split, public exposure and no image-scale claim.
- Model: position and normalized time inputs; two velocity outputs; independent source/target pairs, not optimal-transport matching.
- Training: simultaneous gradients, Adam moment correction and norm clipping at five; velocity MSE differs from generated distribution quality.
- Sampling: fixed initial Gaussian points, frozen weights, explicit numerical integration and no hidden projection onto target modes.
- Evidence: full coordinates, failures, mode counts, seeds and call budgets; distinguish supplied results from learner-generated artifacts.
The saved project includes five separate scalar/design transfer cases. Human implementation review, broader device profiling and learner pilots remain pending. Optional studio work does not award project mastery automatically.