13 / 15 · 90–120 min
Learn a velocity field.
Can we learn to turn noise into conditioned displacements?
Check my intuition
01 · Predict
Before changing the settings.
A training displacement connects x₀ = 1 to x₁ = 4 through xₜ = (1−t)x₀ + tx₁. What constant target velocity u = x₁−x₀ is used?
A hint
Subtract the start from the end.
02 · Experiment and compare
Put the model to the test.
Compare zero updates with 600 updates at a fixed seed. Observe held-out loss, then integrate the field for both instructions. Change the learning rate to see that more training does not guarantee a better result.
A 4→8→2 network, 58 parameters trained on 256 synthetic displacements. Validation uses 128 new examples. Euler integration in 40 steps; displayed positions are recomputed with learned weights.
- Training loss
- 0.49
- Validation loss
- 0.44
- Final distance to target
- 0.58
Read values as a table
| Sample | x | y |
|---|---|---|
| 1.00 | 2.65 | 0.81 |
| 2.00 | 2.85 | 2.02 |
| 3.00 | 2.85 | 2.58 |
| 4.00 | 2.59 | 0.69 |
| 5.00 | 2.81 | 1.97 |
| 6.00 | 2.99 | 1.94 |
| 7.00 | 2.99 | 2.03 |
| 8.00 | 2.71 | 1.26 |
| 9.00 | 3.13 | 1.99 |
| 10.00 | 2.74 | 2.72 |
| 11.00 | 3.07 | 2.43 |
| 12.00 | 3.35 | 2.14 |
| 13.00 | 2.40 | 0.59 |
| 14.00 | 2.87 | 3.29 |
| 15.00 | 2.47 | 1.65 |
| 16.00 | 2.73 | 0.99 |
| 17.00 | 2.86 | 2.40 |
| 18.00 | 3.18 | 1.85 |
| 19.00 | 2.85 | 1.02 |
| 20.00 | 2.74 | 1.50 |
| 21.00 | 2.92 | 1.44 |
| 22.00 | 2.87 | 1.97 |
| 23.00 | 2.76 | 1.97 |
| 24.00 | 3.03 | 2.07 |
Understand the calculations
03 · Connect the diagram to calculations
The numbers behind motion.
We construct 256 synthetic pairs: Gaussian start x₀, endpoint x₁ near (3, ±2), a condition and a time t. The network receives (xₜ, t, condition) and predicts x₁−x₀. Eight tanh units and a linear output give 58 parameters. Backpropagation applies the chain rule to squared loss; mini-batch SGD with 16 examples updates weights. Gradient norm is capped at 10. The 128 validation examples never update weights. The learned field is then integrated in 40 Euler steps. This is flow matching on synthetic displacements; it learns neither visual perception nor real motor commands.
xₜ = (1−t)x₀ + tx₁ ; target_u = x₁−x₀
h = tanh(W₁[xₜ,t,c] + b₁)
uθ = W₂ h + b₂
L = ½ ||uθ − target_u||²
x_next = x + Δt uθ(x,t,c)A few lines to reconstruct
hidden_gradient = (W2.T @ output_error) * (1-hidden**2)
W1 -= rate * outer(hidden_gradient, inputs)
W2 -= rate * outer(output_error, hidden)The notebook provides one function per laboratory, hand-calculated examples and tests. Exercises isolate components; these pages run the complete simulations.
Keep an observation
04 · Record
What changed?
Compare two settings. Record the effect, your explanation and a case where the model might fail. Saving keeps the current settings and seed, not a certification of competence.
atomsh / lab