SeeingML
Neural Networks & Deep Learning Guide 1 of 6 · tap to switch
✦ Interactive Visual Guide 9 min · 4 hands-on labs · Beginner friendly

Neural Networks & the Perceptron

Demystify neural networks from a single weighted switch to multi-layer perceptrons that solve XOR and approximate any curve.

Every headline about AI makes neural networks sound like glowing digital brains. Open the hood, though, and the core building block is a tiny everyday scorecard!

Suppose you want a simple switch to decide whether today is a Great Beach Day using just two clues rated from 0 to 10: Temperature and Sunshine. You give warmth an importance weight of 1.2, sunshine a weight of 1.0, and add a picky starting baseline of -12 so chilly, cloudy days fail automatically:

  • Warm, sunny day (Temperature = 8, Sunshine = 9): (8 × 1.2) + (9 × 1.0) - 12 = +6.6 -> Above zero, so Go to Beach!
  • Cold, cloudy day (Temperature = 2, Sunshine = 3): (2 × 1.2) + (3 × 1.0) - 12 = -6.6 -> Below zero, so Stay Home.

In machine learning, this weighted decision switch is called an Artificial Neuron, and its classic single-layer form is called a Perceptron. Scientists write that exact Beach Score recipe in compact shorthand as z = w₁x₁ + w₂x₂ + b: multiply each clue (x₁, x₂) by its importance weight (w₁, w₂), add your strictness baseline called the bias (b), and check if the total score z crosses zero.

The single neuron below starts off-target at 8/12 with dashed amber rings around the missed days. Slide Temp Weight (w₁) and Sun Weight (w₂) to rotate the angle of the straight decision line, and adjust Bias (b) to slide the line across the chart until all 12 weather days are cleanly separated!

Interactive Lab 1: Inside a Single Artificial Neuron (Weights + Bias)
8/12 correct (67%)
Beach Score = 0.8 × Temp + 0.6 × Sun - 4.2 (> 0 means Go!)
Great Beach DayStay HomeWrong Guess (Miss)
002.52.5557.57.51010GO TO BEACHSTAY HOMETemperature (0 to 10)Sunshine (0 to 10)
0.8
0.6
-4.2
4 days still missed (dashed amber rings). Slide Bias (b) lower to push the boundary up toward the sunny days, and adjust Temp Weight (w₁) or Sun Weight (w₂) to rotate its tilt until all 12 dots are cleanly separated.

From a Single Perceptron to Hidden Layers: Solving XOR

If a single Perceptron works so neatly, why do we ever connect thousands of neurons into a network?

Picture a two-way staircase hallway light controlled by a Bottom Switch (X) and a Top Switch (Y). When both switches are OFF (0, 0) or both are ON (1, 1), the light is OFF. Flip either one switch by itself ((0, 1) or (1, 0)), and the light turns ON.

In computer science, this “one or the other, but not both” rule is called XOR (Exclusive OR). Inspect the chart below to see why 1 straight line is mathematically stuck at 3 out of 4 (75%), leaving Both ON (1, 1) trapped on the wrong side. Then click Add Hidden Layer (2 Neurons) to watch two straight cuts fold into a green diagonal ribbon that solves all 4 corners!

Interactive Lab 2: The Staircase Switch Puzzle (XOR) & Hidden Layers
Stuck at 3/4 (75%)
Step 1: Notice how one straight cut always traps a corner. Now add a hidden layer:
1 Straight CutBoth OFF (0, 0)Light: OFFTrapped in green zone! (Wrong)Both ON (1, 1)Light: OFFOnly Top ON (0, 1)Light: ONOnly Bottom ON (1, 0)Light: ONBottom Switch (X): OFF (0) to ON (1)Top Switch (Y): OFF (0) to ON (1)
Why 1 line gets stuck at 3/4: No matter how you rotate or slide a single straight ruler, putting both green ON corners on one side traps Both ON (1, 1) on the wrong side (dashed amber ring). Click Add Hidden Layer (2 Neurons) above to see the breakthrough!

Notice the trick: Neuron 1 draws the bottom-left fence (“Is at least one switch ON?”), Neuron 2 draws the top-right fence (“Are both switches ON?”), and the output neuron keeps only the green ribbon in between! Combining two simple straight cuts builds a brand-new shape that no single Perceptron could draw alone.


Bending hinges onto any curve: the Universal Approximation Theorem

Now suppose you want to predict how much electricity a rooftop solar panel produces from 6 AM to 6 PM. Power climbs quickly in the sunny morning, dips when afternoon clouds roll in, and rises slightly again before sunset. One rigid straight stick can never hug a bumpy curve like that.

Imagine instead connecting several straight sticks end to end with bendable hinges. One hinge bends a stick into a roof shape; three hinges fold around both the morning peak and the cloudy afternoon valley; seven hinges let eight short straight sticks follow the smooth curve almost seamlessly!

In neural networks, each hidden neuron inserts one of those bendable joints using a simple hinge switch called ReLU (Rectified Linear Unit, which stays flat at zero on one side and rises in a straight ramp on the other). Because connecting enough of these ReLU hinges side by side can approximate practically any smooth curve, mathematicians gave this superpower a famous name: the Universal Approximation Theorem.

Click from 1 Neuron (Straight) up to 8 Hidden Neurons below to watch purple hinge-joint dots appear along the line and shrink the Avg Error!

Interactive Lab 3: Solar Panel Power vs. Hour of Day (Bending ReLU Hinges)
Avg Error: 25.0
Step 1: One rigid stick cannot follow a sunny-to-cloudy day. Add hidden neurons to insert bendable hinges:
True Solar PowerNetwork (1 Straight Stick)Hinge Joint (0)Error Gap
02550751006 AM9 AM12 PM3 PM6 PMHour of Day (6 AM to 6 PM)Power Output
1 Neuron, 0 hinges (Avg Error: 25.0): One neuron can only draw a single rigid straight stick across the day. It completely misses both the sunny morning surge around 9 AM and the cloudy dip around 3 PM, leaving a huge shaded error gap.

Why “Deep” beats “Wide”: building reusable hierarchies

Wait: if a single wide hidden layer packed with enough hinges can trace any curve, why do modern vision and language models stack dozens or hundreds of layers deep?

Think about spotting a bicycle in a photograph. Trying to jump straight from raw camera brightness squares to “bicycle” in one giant flat layer would force the network to re-learn every lighting change, color, and angle from scratch, and then start all over again to recognize a scooter or a bus!

Stacking layers deep solves this by stacking simple shapes into reusable building blocks step by step: pixels -> edges -> parts -> full objects. Early layers spot short curves and slanted lines from raw pixels, middle layers assemble those strokes into circular wheels, a triangular frame, and handlebars, and the final layer simply checks which parts lit up together. Because the exact same “wheel” detector works for bicycles, scooters, cars, and buses, deep networks solve hard real-world problems with far fewer total weights!

Click through Layer 1 to Layer 4 below to watch raw messy pixels transform step by step into a recognized bicycle.

Interactive Lab 4: Stacking Simple Shapes Into Whole Objects (Deep Layers)
Stage 1 of 4: Raw Pixels
Click from Layer 1 to Layer 4 to watch raw pixels build into a full bicycle:
Camera Grid: 242 Tiny Brightness Squares (0 to 255)Outlined square = just one pixel value (brightness 214)
What this layer sees: Hundreds of tiny color and brightness squares (numbers from 0 to 255). Looking at one square alone gives zero clue whether this photo shows a bicycle or a cat.
Everyday analogy: Individual alphabet letters scattered across a table.
Why stacking layers wins: Trying to jump straight from messy pixels to "bicycle" in one flat layer would force the network to memorize every camera angle and lighting change from scratch.
Building Blocks StackedStep 1 of 4
Pixels
Edges
Parts
Bicycle
Layer 1 (Raw Pixels): Layer 1 only sees raw brightness squares. Click Layer 2 (Simple Edges) to watch neighboring squares combine into tiny slanted and curved strokes!
See Matrix Layer Formulation, Universal Approximation & Depth EfficiencyThesis / Reference

1. Vectorized Multi-Layer Perceptron (MLP): Stacking LL fully connected layers maps an input vector x=h(0)∈Rd0\mathbf{x} = \mathbf{h}^{(0)} \in \mathbb{R}^{d_0} forward via alternating affine transformations and element-wise non-linear activations ϕ(⋅)\phi(\cdot):

z(ℓ)=W(ℓ) h(ℓ−1)+b(ℓ),h(ℓ)=ϕ ⁣(z(ℓ))(ℓ=1,…,L)\mathbf{z}^{(\ell)} = \mathbf{W}^{(\ell)}\,\mathbf{h}^{(\ell-1)} + \mathbf{b}^{(\ell)}, \qquad \mathbf{h}^{(\ell)} = \phi\!\big(\mathbf{z}^{(\ell)}\big) \quad (\ell = 1, \dots, L)

Here W(ℓ)∈Rdℓ×dℓ−1\mathbf{W}^{(\ell)} \in \mathbb{R}^{d_\ell \times d_{\ell-1}} holds all layer weights as one GPU-friendly matrix multiplication, and b(ℓ)∈Rdℓ\mathbf{b}^{(\ell)} \in \mathbb{R}^{d_\ell} shifts each neuron’s firing threshold.

2. Universal Approximation Theorem (Cybenko, 1989; Hornik, 1991; Leshno et al., 1993): For any continuous target function f:[0,1]d→Rf : [0, 1]^d \to \mathbb{R} and tolerance ε>0\varepsilon > 0, there exists a single-hidden-layer network f^(x)=∑j=1mvj ϕ(wj⊤x+bj)\hat{f}(\mathbf{x}) = \sum_{j=1}^{m} v_j\,\phi(\mathbf{w}_j^\top \mathbf{x} + b_j) satisfying sup⁡x∣f(x)−f^(x)∣<ε\sup_{\mathbf{x}} |f(\mathbf{x}) - \hat{f}(\mathbf{x})| < \varepsilon, provided ϕ\phi is non-polynomial.

3. Exponential Expressivity of Depth (Montúfar et al., 2014; Telgarsky, 2016): While width guarantees theoretical existence, a deep ReLU network of depth LL and width ww can carve up to O ⁣((w/d)(L−1)dwd)\mathcal{O}\!\big((w/d)^{(L-1)d} w^d\big) distinct linear regions (growing exponentially with depth LL versus only polynomially with width in a shallow network). That compositional folding is why Deep Learning dominates high-dimensional perception and language tasks.

See a Clean Multi-Layer Perceptron (MLP) in PyTorchOptional Code
python
import torch
import torch.nn as nn

# A compact 3-layer Multi-Layer Perceptron (Input -> 64 -> 32 -> 1 Output)
model = nn.Sequential(
  nn.Linear(in_features=10, out_features=64),  # W1 * x + b1
  nn.ReLU(),                                   # non-linear hinge switch
  nn.Linear(in_features=64, out_features=32),  # W2 * h1 + b2
  nn.ReLU(),
  nn.Linear(in_features=32, out_features=1),   # final output logit
)

x_batch = torch.randn(16, 10)
logits = model(x_batch)
print("Output shape:", logits.shape)  # torch.Size([16, 1])

Wait: why did we need that ReLU hinge between layers?

What happens if you build a 10-layer neural network and forget to put an activation function like ReLU or Sigmoid between layers? Something shocking: the entire 10-layer network mathematically collapses back into ONE plain straight line!

Let’s see why right now in Activation Functions.

✓ Self-Check

Quick Intuition Check

Four quick real-world scenarios. No scores, just test your intuition.

1

Inside a single neuron (Perceptron) computing z = w₁x₁ + w₂x₂ + b, what do the weights (w₁, w₂) and bias (b) do to the straight decision line?

Pick an option first, or peek anytime
2

Why is a single Perceptron mathematically stuck at 3 out of 4 (75%) accuracy on the XOR staircase switch puzzle?

Pick an option first, or peek anytime
3

Adding more ReLU hidden neurons inserts more bendable hinge joints into the line, allowing a neural network to trace practically any smooth curve.

Pick an option first, or peek anytime
4

If one huge flat hidden layer can theoretically trace any curve, why do modern deep neural networks stack many layers deep instead?

Pick an option first, or peek anytime
Quick Reference

Common Questions

What is a neural network in simple terms?
A neural network is a layered team of simple mathematical switches called neurons. Each neuron multiplies its input numbers by learned weights, adds a bias threshold, applies a bendy activation function, and passes its score to the next layer until the final layer outputs a prediction.
What is the role of weights and bias inside a neuron?
Weights control how important each input clue is (and tilt the angle of the neuron's decision boundary), while the bias shifts the boundary up or down, acting like a strictness threshold for how strong the evidence must be before the neuron activates.
Why did the XOR problem matter so much in neural network history?
In 1969, Marvin Minsky and Seymour Papert proved that a single-layer Perceptron can only draw one straight line, making it mathematically impossible to solve XOR (where diagonal corners share labels). Adding a Hidden Layer solved XOR cleanly and launched modern Multi-Layer Perceptrons (MLPs).
What does the Universal Approximation Theorem actually say?
Proven by Cybenko (1989) and Hornik (1991), it guarantees that a neural network with just ONE sufficiently wide hidden layer and a non-linear activation (like ReLU or Sigmoid) can approximate any continuous function on a bounded domain to arbitrary precision.
If one wide hidden layer can approximate anything, why do we build DEEP networks?
Approximating a complex real-world pattern like human faces with a single flat layer can require an astronomically huge number of neurons. Stacking multiple layers lets the network compose reusable hierarchies (edges -> shapes -> eyes -> faces) using exponentially fewer parameters.

Written & illustrated by Muhammad Aashir Irshad · Updated December 2026 · Free open-access reference

https://seeingml.com/learn/neural-networks/ Open GitHub issue Suggest an edit
Cite this guide in a paper, thesis, or course (BibTeX & APA)
BibTeX
@misc{irshad2026neuralnetworks,
  author       = {Irshad, Muhammad Aashir},
  title        = {Neural Networks & the Perceptron: Interactive Visual Guide},
  howpublished = {SeeingML},
  year         = {2026},
  month        = {dec},
  url          = {https://seeingml.com/learn/neural-networks/},
  note         = {Interactive visual guide}
}
APA

Irshad, M. A. (2026). Neural Networks & the Perceptron: Interactive Visual Guide. SeeingML. https://seeingml.com/learn/neural-networks/