Thomas Piacentini
← Workshop

13 / 15 · 90–120 min

Learn a velocity field.

Can we learn to turn noise into conditioned displacements?

Choose a laboratory
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.

lowerupperStep 40 / 40
Dots: integration of the learned field from 24 initial noise samples. Dashed: one trajectory. Circles mark demonstration centres.

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
Compare A and B →

Read values as a table
Samplexy
1.002.650.81
2.002.852.02
3.002.852.58
4.002.590.69
5.002.811.97
6.002.991.94
7.002.992.03
8.002.711.26
9.003.131.99
10.002.742.72
11.003.072.43
12.003.352.14
13.002.400.59
14.002.873.29
15.002.471.65
16.002.730.99
17.002.862.40
18.003.181.85
19.002.851.02
20.002.741.50
21.002.921.44
22.002.871.97
23.002.761.97
24.003.032.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.

Open my notebook →

atomsh / lab