How neural networks work: the idea under all of it
Under every transformer, every image generator, every language model, sits one idea: the neural network. Here's how it actually works, neurons, weights, layers, and the simple trick by which it learns from its own mistakes, explained so it finally makes sense.
Underneath every AI system we've written about, the transformer, the language model, the image generator, the reasoning model, sits one idea, and it's the same idea in all of them. The neural network. Strip away the specialised architecture and what remains is always this: layers of simple units, connected by adjustable weights, that learn by correcting their own mistakes. If you understand the neural network, you understand the thing every other AI concept is built on top of.
And here's the encouraging part: the core idea is graspable, and more simple than the intimidating diagrams suggest. This is how neural networks actually work, what a "neuron" is, why stacking them in layers is powerful, and the honestly neat trick by which a network learns anything at all from nothing but examples and its own errors. It's the most foundational concept in modern AI, and once it clicks, everything else in the field has a floor to stand on.
The unit: a neuron is just a weighted vote
Start with the single building block, because the whole thing is just millions of copies of it. Despite the biological name, an artificial neuron is simple: it takes several numbers in, and produces one number out. That's it.
Here's what it does with those inputs. Each input arrives through a connection that has a weight, a number representing how much that input matters. The neuron multiplies each input by its weight, adds them all up (plus a small adjustable offset called a bias), and passes the result through one more step we'll get to. The weights are the key part: a large weight means "this input strongly influences my output," a weight near zero means "ignore this input," a negative weight means "this input pushes my output down." So a neuron is essentially taking a weighted vote of its inputs, combining them according to how important each one is, where "importance" is exactly what the weights encode.
That final step the result passes through is the activation function, and it does one essential job: it introduces non-linearity. Without it, a neuron would just be computing a straight-line combination of its inputs (like linear regression), and. This is the key mathematical fact, stacking straight-line functions only ever gives you another straight line, no matter how many you pile up. The activation function bends the output (a common one, ReLU, simply zeroes out negatives and passes positives through), and that bend is what lets networks represent curved, complex relationships. Non-linearity is the difference between a system that can only draw straight lines and one that can carve out any shape. It's not a technicality, it's what makes the whole enterprise capable of complexity.
The structure: layers turn simple into powerful
One neuron takes a weighted vote, modestly useful. The power comes from arranging many of them in layers, and understanding why is understanding the whole design.
A neural network has an input layer (which receives the raw data, the pixels of an image, the numbers representing a word), one or more hidden layers in the middle, and an output layer (which produces the final answer, a classification, a prediction, a probability). Data flows through in one direction: the input layer feeds the first hidden layer, whose outputs feed the next, and so on to the output. Each neuron in a layer takes a weighted vote of all the outputs from the previous layer, so information gets combined and recombined as it flows forward. This forward flow is called a forward pass, and it's how a trained network turns an input into an answer.
The reason depth matters, the reason we say deep learning, is that each layer builds on the patterns the previous one found, at a higher level of abstraction. Give a network an image: the first hidden layer might learn to detect edges and simple textures; the next combines edges into shapes and parts; the next combines parts into objects; the output layer names what it sees. No single layer does much, but the stack builds from raw pixels up to meaning, one level of abstraction at a time. This is the significant thing about depth: each layer only handles a small piece of the job, but the full stack accomplishes something no single layer could. A one-layer network can only learn simple patterns; a deep network can untangle enormously messy data, because it has room to build complexity gradually. That layered abstraction is why deep learning conquered problems, vision, language, that resisted every earlier approach.
The learning: how a network corrects itself
Now the deepest question, and the clever part. A freshly built network has random weights, it knows nothing, and its outputs are garbage. How does it go from random to knowing? How does it learn?
The answer is a loop, and it's a form of supervised learning: learning from examples where you know the right answer. The loop. First, show the network an example and let it make a prediction (a forward pass). Second, measure how wrong it was, compare its output to the correct answer using a loss function that produces a single number: the error. A big number means very wrong; zero means perfect. Third, and this is the key step, figure out how to adjust every weight in the network to make that error a little smaller. Fourth, make those tiny adjustments. Then repeat, millions of times, with millions of examples. Each pass, the network is a tiny bit less wrong, and over enough passes, "a tiny bit less wrong, millions of times" adds up to a network that's good.
The heart of this is step three: with millions of weights, how do you know which ones to nudge, and in which direction, to reduce the error? This is the problem that stumped researchers for years. They could build multi-layer networks but couldn't figure out how to train the hidden layers. The solution, from a landmark 1986 paper, is backpropagation, and it's the algorithm that made neural networks actually work.
Backpropagation: assigning blame, neatly
Backpropagation is the idea most worth understanding, so here it is in plain terms. When the network makes an error, that error was caused by all the weights together, but not equally. Some weights contributed a lot to the mistake, some a little, some pushed toward the right answer. To improve, you need to know each weight's share of the blame, so you can adjust the guilty ones more.
Backpropagation computes exactly this, and its trick is in the name: it works backward. It starts at the output, where the error is directly measurable, and traces that error backward through the network layer by layer, using calculus (the chain rule) to calculate how much each weight contributed to the final mistake. A weight that strongly influenced a wrong output gets assigned more blame; one that barely mattered gets less. The analogy that captures it: when you make a mistake dancing or playing an instrument, you don't just note that you erred, you retrace your steps to find where it went wrong, so you can fix that specific thing. Backpropagation retraces the network's steps, from the error back to every weight that helped cause it.
Once each weight knows its share of the blame, technically, the gradient, the direction and amount to change it to reduce error, the network adjusts every weight a tiny step in the improving direction. That adjustment step is gradient descent, and the size of the step is the learning rate (too big and it overshoots; too small and learning crawls). The two work as a pair: backpropagation figures out which way each weight should move, gradient descent moves it, and the loop repeats. Together, these three, a loss measuring error, backpropagation assigning blame, and gradient descent adjusting weights, form the engine by which every neural network, from a tiny one to a model with billions of parameters, learns. That is how these systems learn: not magic, but millions of tiny, blame-guided corrections.
Why this one idea underlies everything
The payoff for understanding all this, and why it's the true foundation of the field. Every modern AI architecture is, at bottom, this same idea, learned weights, stacked layers, non-linear activations, trained end-to-end by backpropagation. The differences between architectures are differences in how the neurons are wired, not in the fundamental mechanism.
A convolutional network wires neurons to look at small patches of an image, which suits grid-like visual data. A transformer wires them with attention, data-dependent connections that let any element influence any other, which suits sequences. But underneath, a transformer is still neurons with learned weights in stacked layers trained by backpropagation; attention is a clever wiring pattern, not a departure from the neural network. The same is true of the network inside an image generator, a reasoning model, a recommendation system. When you read that a language model has "billions of parameters," those parameters are the weights of a giant neural network, learned by exactly the loop above, just at colossal scale. This is why understanding the neural network unlocks everything else: it's not one AI technique among many, it's the substrate almost all of modern AI is built from.
The honest caveats
Two things worth keeping in view, because they follow directly from how networks learn. First, a network is only as good as its data: since it learns entirely from the examples you show it, bad or biased data teaches bad or biased behaviour, faithfully. Garbage in, garbage learned. Second, a network can memorise instead of learn, fitting the training examples exactly while failing to grasp the general pattern, so it performs well on what it's seen and badly on anything new. That's overfitting, and much of the practical craft of training networks is about preventing it. Neither caveat undercuts the power of the idea; both are consequences of the fact that a network learns from data by correcting error, with no understanding of the world beyond what the data contains.
The short version
A neural network is layers of simple units, neurons, each taking a weighted vote of its inputs and bending the result through a non-linear activation. Stacked in layers, they build from raw data up to meaning, one level of abstraction at a time. The network learns by a loop: predict, measure the error, use backpropagation to trace that error back through the layers and assign each weight its share of the blame, then nudge every weight a tiny step in the improving direction via gradient descent, repeated millions of times until the network is good. And every modern architecture, transformers included, is this same idea with a different wiring pattern.
a neural network learns by making millions of tiny, blame-guided corrections to adjustable weights, and that single, simple loop is the engine under nearly all of modern AI. Everything else in the field is a variation on how to wire the neurons and what to feed them. Get this, and you have the floor the whole subject stands on.
Common questions
How does a neural network work? A neural network is made of layers of simple units called neurons. Each neuron takes several inputs, multiplies each by a weight (a number representing its importance), sums them, and passes the result through a non-linear activation function. Data flows from an input layer through hidden layers to an output layer, with each layer building on the patterns the previous one found. The network learns by comparing its predictions to correct answers and adjusting its weights to reduce the error, repeated over many examples.
What is a neuron in a neural network? An artificial neuron is a simple unit that takes several numbers as input and produces one number as output. It multiplies each input by a weight (how much that input matters), adds them up with a bias, and passes the result through an activation function that introduces non-linearity. Essentially it takes a weighted vote of its inputs. Millions of these simple units, arranged in layers and connected by adjustable weights, make up a neural network.
What are weights in a neural network? Weights are the adjustable numbers on the connections between neurons that determine how much each input influences a neuron's output. A large weight means an input strongly affects the output; a weight near zero means it's ignored; a negative weight pushes the output down. Weights are what the network actually learns, training adjusts them to reduce error. When a model is said to have "billions of parameters," those parameters are essentially its weights.
What is backpropagation? Backpropagation is the algorithm neural networks use to learn. When the network makes an error, backpropagation works backward from the output through the layers, using calculus to calculate how much each weight contributed to the mistake, assigning each weight its share of the blame. This tells the network which weights to adjust and in which direction to reduce the error. Introduced in a landmark 1986 paper, it's what made training multi-layer networks possible and remains fundamental to all deep learning.
Why do neural networks have layers? Layers let a network build complexity gradually. Each layer takes the outputs of the previous one and finds higher-level patterns: for an image, early layers detect edges, middle layers combine them into shapes and parts, later layers into objects. No single layer does much, but the full stack builds from raw data up to meaning. This is why deep networks (many layers) can handle far messier, more complex tasks than shallow ones, depth gives room to build abstraction step by step, which is why it's called deep learning.
Are transformers neural networks? Yes. A transformer is a neural network, the same fundamental idea of learned weights, stacked layers, non-linear activations, and training by backpropagation. What makes it a transformer is the particular way its neurons are wired: it uses attention, which forms data-dependent connections letting any element influence any other, rather than simple fixed connections. But underneath, it's still a neural network learning weights by the standard loop. Nearly every modern AI architecture, CNNs, transformers, diffusion models, is a neural network with a different wiring pattern.
What is an activation function? An activation function is a small nonlinear step applied to each neuron's output, and it is what lets a neural network learn complex patterns rather than only straight-line relationships. Without it, stacking layers would collapse into a single linear transformation no matter how deep the network, because a chain of linear steps is still linear. The activation function bends the output, so each layer can build on the last to represent curves, combinations, and intricate structure. A common choice applies a simple rule like passing positive values through and zeroing negatives, which is enough to give the network its expressive power.
Sources & further reading
The primary literature behind the claims above, drawn from the concept entries this post links to, so a claim carries the same source here as it does there.
- Vaswani et al. (2017), Attention Is All You Need — the original, and still readable. :: https://arxiv.org/abs/1706.03762 Transformer
- Alammar (2018), The Illustrated Transformer — the explanation most practitioners actually learned from. Transformer
- Gu & Dao (2023), Mamba: Linear-Time Sequence Modeling with Selective State Spaces — the most credible challenger to attention's quadratic cost. Transformer
- Rumelhart, Hinton & Williams (1986), Learning representations by back-propagating errors — the algorithm everything still runs on. :: https://doi.org/10.1038/323533a0 Neural Network
- Grinsztajn, Oyallon & Varoquaux (2022), Why do tree-based models still outperform deep learning on tabular data? — the paper to cite when someone reaches for a neural net on a spreadsheet. Neural Network
- LeCun, Bengio & Hinton (2015), Deep Learning (Nature) — the field's own summary of why depth mattered. Neural Network
- Nair & Hinton (2010), Rectified Linear Units Improve Restricted Boltzmann Machines — where ReLU enters. Activation Function
- Glorot, Bordes & Bengio (2011), Deep Sparse Rectifier Neural Networks — why the simplest option beat the elegant ones. Activation Function
Related articles
- What is deep learning? The complete guideAlmost every AI system that impresses today, from chatbots to image generators to voice assistants, runs on deep learning. Its core idea is a single powerful shift: instead of humans hand-crafting the features a model uses, deep networks learn their own layered representations of data, from simple edges to whole objects. This guide explains what deep learning is, how it works, its architectures, and its limits.
- AI vs machine learning vs deep learning: the differenceThese three terms are used interchangeably and are not interchangeable. They are nested: deep learning sits inside machine learning, which sits inside artificial intelligence. Knowing which circle you are in tells you what to expect about data, cost, transparency, and how the system will fail.
- Mechanistic interpretability: opening the AI black boxWe built AI systems that work without fully understanding how they work. We have every number inside them, yet the numbers do not obviously mean anything. Mechanistic interpretability is the effort to reverse-engineer that black box, and it has started to succeed, revealing why you cannot just read a neuron and how researchers now extract readable concepts from the tangle.
- How quantization shrinks AI models without breaking themA 70-billion-parameter model needs about 140 GB of memory at full precision. Your laptop has 16. Quantization is how the model fits anyway, by storing each weight in far fewer bits, and the surprising part is that you can throw away most of that precision and the model barely notices. Here is why, and where it finally breaks.