Build garagePlay → read → next · ~10 min

Tutorials · Chapter D (4/4) · ~10 min

Neural nets by building

Play → read → next

Steer a tiny neuron with weights until the output matches your target — a demo you can narrate.

Playground

Neural nets by building

Tweak weights. A neuron: weighted sum → sigmoid → decision.

z = 0.90 · sigmoid(z) = 0.71

Recap

What you just did

You controlled a mini neural unit by hand. When you raised a weight, the output moved. That’s intuition you can’t get from a diagram alone: networks learn by changing numbers that change behavior. You can say, “Watch — I nudge this weight, the prediction flips.”

Teach

How it works

One neuron, stripped down:

def neuron(x1, x2, w1, w2, b):
    z = w1 * x1 + w2 * x2 + b
    # step activation for the toy
    return 1 if z >= 0 else 0

# Want AND-ish: both inputs 1 → 1
print(neuron(1, 1, 1.0, 1.0, -1.5))  # 1
print(neuron(1, 0, 1.0, 1.0, -1.5))  # 0
  1. Inputs → signals
  2. Weights + bias → importance / threshold
  3. Activation → turn the sum into a decision

Stack many of these and you get deep nets — same idea, more knobs.

Use it

When you'd use this

  • Understanding why training “moves gradients” (weights change on purpose)
  • Debugging “dead” units (weights so small the neuron never fires)
  • Explaining AI to someone: “It’s weighted combinations, not vibes”

Watch out

Watch out

Hand-tuning feels like understanding, then you meet thousands of weights. Scaling needs automatic training (the previous labs). Don’t confuse a toy neuron with “I built ChatGPT.”

Try next

Try this next

Flip the sign of one weight and try the same inputs. Explain aloud why the decision changed.