Gradient Descent Lab.

One sigmoid neuron — weights w₁, w₂ and bias b — learns to separate two classes of points: visit a point, predict ŷ, score the miss, nudge all three numbers downhill, repeat. Play it or step through every number as it changes — the exact rules it plays by are spelled out at the bottom.

Interactive lab for stochastic gradient descent on a single sigmoid neuron. Four linked views: a scatter plot with the moving decision boundary, the neuron diagram with live weights, the current step's formulas with numbers substituted, and the training-loss curve per epoch. The fixed rules and assumptions are listed in the Given section at the bottom.

Data & decision boundary epoch 0 · pt 1/100

y = 1 y = 0 boundary ŷ = 0.5 past epochs next point

Training per-point sgd · you set the pace

status: ready
position:
weights:
boundary:
mean loss:
accuracy:
space play/pause · → step · e epoch

Network ŷ = σ(w₁x₁ + w₂x₂ + b)

edge colour = weight sign · thickness = |weight| · values follow the next point

The step, in numbers next: pt 1/100 · epoch 0 — ▸ step applies exactly this

1 · forward pass

z = w₁·x₁ + w₂·x₂ + b
ŷ = σ(z) = 1 / (1 + e−z)

2 · error at this point

E = −y·ln(ŷ) − (1−y)·ln(1−ŷ)

3 · gradient-descent update

δ = y − ŷ =
wᵢ ← wᵢ + α·δ·xᵢ   b ← b + α·δ
this is the gradient step w ← w − α·∂E/∂w, because for this E and σ,  ∂E/∂wᵢ = −(y−ŷ)·xᵢ and ∂E/∂b = −(y−ŷ).

Training loss mean E over all 100 points, after each epoch · hover for detail

Given — the rules of this lab fixed for every run, unless a control says otherwise

modelone sigmoid neuron (= logistic regression): ŷ = σ(w₁x₁ + w₂x₂ + b), ŷ read as P(y = 1). only three numbers ever learn — w₁, w₂, b — so the drawn boundary is always the straight line where ŷ = 0.5.
data100 fixed points, 50 per class, in the unit square, embedded in this file. the clouds overlap: no straight line gets all 100 right, and this run tops out around 94%.
startalways the same one-off random draw: w₁ −0.5308 · w₂ 0.9308 · b 0. ↺ reset returns to it, so every run is exactly reproducible.
objectiveper-point log-loss E = −y·ln(ŷ) − (1−y)·ln(1−ŷ). the chart tracks its mean over all 100 points, measured after each completed epoch.
update rulestochastic gradient descent, one point at a time in fixed order 1…100 (one pass = one epoch): w ← w + α(y−ŷ)x,  b ← b + α(y−ŷ). every point nudges the line, even correctly classified ones (unlike the perceptron trick), and each step descends only that one point's error — which is why the boundary wobbles instead of gliding.
deliberately absentno shuffling, no mini-batches, no momentum, no regularisation, no train/test split — loss and accuracy are measured on the same 100 points it trains on.
learning rate & stoppingα is constant (default 0.01); moving the slider mid-run applies from the next step. there is no convergence test — training simply stops after the set number of epochs (default 100). the default run lands at mean loss 0.3249, accuracy 94%.
accuracya point counts as correct when its predicted side agrees with its class: ŷ > 0.5 for y = 1, ŷ ≤ 0.5 for y = 0. accuracy can plateau while the loss still falls — the line keeps improving its confidence without flipping any point.
dataset · 100 points · with the network's current prediction for each
#x₁x₂yŷ nowE now