Neural Networks & Deep Learning Guide 1 of 6 · tap to switch
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!
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!
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!
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.
See Matrix Layer Formulation, Universal Approximation & Depth EfficiencyThesis / Reference
1. Vectorized Multi-Layer Perceptron (MLP): Stacking fully connected layers maps an input vector forward via alternating affine transformations and element-wise non-linear activations :
Here holds all layer weights as one GPU-friendly matrix multiplication, and shifts each neuron’s firing threshold.
2. Universal Approximation Theorem (Cybenko, 1989; Hornik, 1991; Leshno et al., 1993): For any continuous target function and tolerance , there exists a single-hidden-layer network satisfying , provided 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 and width can carve up to distinct linear regions (growing exponentially with depth 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
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.
Quick Intuition Check
Four quick real-world scenarios. No scores, just test your intuition.
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?
Why is a single Perceptron mathematically stuck at 3 out of 4 (75%) accuracy on the XOR staircase switch puzzle?
Adding more ReLU hidden neurons inserts more bendable hinge joints into the line, allowing a neural network to trace practically any smooth curve.
If one huge flat hidden layer can theoretically trace any curve, why do modern deep neural networks stack many layers deep instead?
Common Questions
What is a neural network in simple terms?
What is the role of weights and bias inside a neuron?
Why did the XOR problem matter so much in neural network history?
What does the Universal Approximation Theorem actually say?
If one wide hidden layer can approximate anything, why do we build DEEP networks?
Related Visual Guides
Activation Functions (ReLU, Sigmoid & GELU)
Why every neural layer needs a non-linear bend, how ReLU cured vanishing gradients, and why modern LLMs love GELU.
Backpropagation
See how neural networks pass blame backward from a wrong guess to every weight in one efficient Chain Rule sweep.
Matrices & Matrix Multiplication
See a matrix as a live space-warping machine, watch the Determinant scale or squash area, and master PyTorch layer shapes.
Written & illustrated by Muhammad Aashir Irshad · Updated December 2026 · Free open-access reference
Cite this guide in a paper, thesis, or course (BibTeX & APA)
@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}
} Irshad, M. A. (2026). Neural Networks & the Perceptron: Interactive Visual Guide. SeeingML. https://seeingml.com/learn/neural-networks/