🧠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.
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:
Multiply each input by its weight, then add them all up.
Add a fixed nudge (the bias) that shifts the result up or down regardless of inputs.
Pass z through an activation function to produce the final output.
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 |
🏗️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.
- Input layer — just passes raw data in (pixel values, numbers, encoded text).
- Hidden layers — each layer learns increasingly abstract features. Layer 1 might detect edges, layer 2 shapes, layer 3 faces.
- Output layer — produces the final answer: a class, a number, a probability.
Adjust inputs, weights, bias and activation function. Watch the neuron fire in real time.
Inputs
Weights
Bias
Activation Function
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? |
|---|