MLML Bites
Lessons/Lesson 1

The smallest brain you can build

A single neuron, from zero · 12 min

Everyone tells you a neural network is "inspired by the brain" and then drowns you in calculus. Forget that for now.

A neuron is just a tiny decision machine. It takes a few numbers in, multiplies each by an importance (a weight), adds them up, and if the total is big enough it fires a 1, otherwise a 0.

That's it. If you can write a function that adds numbers and compares to a threshold, you can build a neuron. Let's do exactly that.

A neuron in 6 lines

main.pyPython · numpy

Run it. You just built something that behaves like an AND gate: it only outputs 1 when both inputs are 1.

Notice the magic is entirely in the numbers w = [1, 1] and b = -1.5. Different numbers → a different decision. Learning (next lesson) is just the computer searching for the right numbers on its own.

Stuck on a line, or curious what zip does? Select Explain under any cell, or Ask the tutor anything.

Your turn

Change the weights and/or bias so the SAME neuron computes the logical OR instead of AND. (OR fires when at least one input is 1.) Print the truth table to prove it.

exercise.pyPython · numpy