🧠Inspired by the Brain (Loosely!)

Your brain contains roughly 86 billion neurons. Each neuron receives signals from thousands of neighbours, combines those signals, and if the combined signal is strong enough — it fires, sending its own signal onward.

🔄 Analogy: Office Gossip Network Imagine an office where each person (neuron) listens to a few colleagues. They weigh how much they trust each source, add up what they've heard, and only pass the rumour on if it feels "significant enough". Chain enough of these people together and you can process surprisingly complex information!

Artificial neural networks borrow this idea — but they're not real brains. They're a mathematical model loosely inspired by biology. No feelings, no consciousness — just numbers flowing through functions. That's actually good news: it means we can understand them completely.

⚙️A Single Artificial Neuron

Strip away everything and a neuron does exactly three steps:

Step 1 — Weighted Sum

Multiply each input by its weight, then add them all up.

z = w₁·x₁ + w₂·x₂ + … + wₙ·xₙ
Step 2 — Add Bias

Add a fixed nudge (the bias) that shifts the result up or down regardless of inputs.

z = z + b
Step 3 — Activation

Pass z through an activation function to produce the final output.

output = f(z)
⚖️ Analogy: The Decision Maker Think of a juror weighing evidence. Each piece of evidence (input) has a credibility (weight). Some pieces matter more than others. The juror also has a prior belief (bias) — maybe they're naturally trusting or sceptical. The activation function is the moment of judgement: "guilty / not guilty" (step), or a nuanced confidence percentage (sigmoid).

Weights encode how much each input matters. A large positive weight means "if this input is high, push me toward firing". A negative weight means "if this input is high, push me away from firing".
Bias is a default leaning that doesn't depend on any input — it's like a thumb on the scales.
Activation function introduces non-linearity — without it, no matter how many neurons you stack, the whole network would collapse into a single linear equation.

📈Activation Functions, Plain & Simple

The activation function is what makes neurons interesting. Here are the four you'll encounter most:

Name Formula Output Range Intuition
Step z ≥ 0 ? 1 : 0 0 or 1 Hard yes/no — the light switch
Sigmoid 1 / (1 + e⁻ᶻ) 0 → 1 Soft squish — "how likely?" probability-like
ReLU max(0, z) 0 → ∞ Ignore negatives, pass positives unchanged
Tanh Math.tanh(z) -1 → 1 Centered sigmoid — negative outputs possible
💡 Why Non-Linearity? If every neuron just multiplied and added (no activation), the whole network — no matter how deep — would only learn straight lines. Real-world patterns (faces, speech, text) are anything but linear. Non-linear activations let the network learn curvy, complex decision boundaries.

🏗️Layers: Why Depth Matters

A single neuron is powerful but limited. Stack them into layers — an input layer, one or more hidden layers, and an output layer — and the story changes dramatically.

x₁
x₂
x₃
x₄
Input
h
h
h
h
h
Hidden 1
h
h
h
Hidden 2
y₁
y₂
Output
💡 The Forward Pass Data flows left-to-right, layer by layer. Each neuron computes its weighted sum, applies its activation, and passes its output to every neuron in the next layer. This one-shot left-to-right computation is called the forward pass. (How the network learns — the backward pass — is the subject of Lesson 05.)
Build-a-Neuron 🧪 Interactive

Adjust inputs, weights, bias and activation function. Watch the neuron fire in real time.

Inputs

Weights

Bias

Activation Function

Sigmoid ReLU Tanh Step
COMPUTATION
Logic-Gate Perceptron 🔌 Interactive

A single neuron can learn AND and OR gates — but not XOR. Pick a gate and see why.

Perceptron Weights & Bias

Truth Table

x₁ x₂ z = w₁·x₁+w₂·x₂+b Output (Step) Expected Match?