AI Grounds

Open AI Grounds on a desktop

These interactive lessons need a larger screen. Please continue on a desktop or laptop computer.

Guided discovery

The Training Loop

Step a batch. Watch weights change.

Your network · 2 inputs → 2 ReLU units → 1 sigmoid output

Four training rows and two different held-out rows. Only training rows supply gradients. This is a deterministic teaching network, not a trained production model.

x1x2h1h2p
  1. 1. Forward
  2. 2. Loss
  3. 3. Backward
  4. 4. Update

Next: Forward · Epoch 0 · Updates 0 · Changed parameters: 0 of 9 · Next training rows: A1, A2.

Forward computes this batch's predictions; weights stay fixed.

Batch size

Changing batch size restarts this run. All means four rows averaged before one update.

Step multiplier. An edit discards pending batch arithmetic and keeps the parameters. Use arrow keys on the slider. Press Enter or leave the number field to apply an exact edit.

Training loss

Mean over all four training rows at current parameters.

0.589058

mean BCE(training)

The update itself uses only its current batch.

Validation loss

Mean over two held-out rows; not fitted.

0.573756

mean BCE(held-out)

A decrease is not guaranteed or evidence about all future data.

Model parameters · Initial → Current

Hidden rows: h1=ReLU(w11x1+w12x2+b1), h2=ReLU(w21x1+w22x2+b2); score=v1h1+v2h2+bOutput.
ParameterInitialCurrent
w110.6000000.600000
w12-0.200000-0.200000
w21-0.300000-0.300000
w220.8000000.800000
b10.1000000.100000
b20.1000000.100000
v10.5000000.500000
v2-0.400000-0.400000
bOutput0.0000000.000000

Loss history after each update

Solid indigo: full Training loss. Dashed orange: Validation loss. No fabricated history at update zero; exact current losses are above.

0.000.501.00No update history yet00Update
Exact examples
Rowx1x2LabelSplit
A1-1-10Training
A2-110Training
A31-11Training
A4111Training
H1-0.50.50Held-out
H20.5-0.51Held-out
Exact batch arithmetic

BCE=max(z,0)−label×z+ln(1+exp(−|z|)). Its score derivative is p−label. ReLU's derivative is zero at zero. Row gradients are averaged before Update; no batch accumulation across updates.

Execute Forward to populate a batch trace.

Exact loss history
UpdateTrainingValidation
Scope and sources

Fixed row order, no shuffling, momentum, regularization or early stopping. Batch size edits restart parameters. Run one epoch finishes the remaining batches if already partway through an epoch. The tiny held-out set is validation evidence, not a final-test score or a guarantee. Display rounds to six decimals; all computations use full precision.

Deep Learning · Batch and minibatch optimization
PyTorch · Stable binary cross entropy