What Are Neural Networks?
How artificial neural networks work: weighted sums, activation functions, layers, loss and backpropagation, plus the main architectures and their limits.
A neural network is a machine learning model built from layers of simple connected units, often called neurons. Each neuron multiplies its inputs by adjustable numbers called weights, adds them up, and passes the result through a simple nonlinear function. Stack enough of these layers and adjust the weights on examples, using a method called backpropagation, and the network learns to map inputs such as pixels, sounds or words to useful outputs. Neural networks are the engine of deep learning, which powers modern image recognition, speech recognition and chatbots.
The idea was loosely inspired by the brain. The Nobel committee, awarding the 2024 physics prize to John Hopfield and Geoffrey Hinton "for foundational discoveries and inventions that enable machine learning with artificial neural networks," described it this way: the brain's neurons are represented by nodes, and the connections between them, likened to synapses, can be made stronger or weaker [8]. The resemblance ends there. An artificial neuron is a few lines of arithmetic.
The artificial neuron
Every neuron does the same three things:
- Weighted sum. It takes several input numbers, multiplies each by its own weight, and adds them: z = wโxโ + wโxโ + โฆ + b. The extra term b, the bias, shifts the result up or down.
- Activation. It passes z through an activation function, which introduces nonlinearity. Without this step, any stack of layers would collapse into one big linear equation and couldn't model curves, edges or meaning.
- Output. The result becomes an input to neurons in the next layer.
One of the most common modern activations is the rectified linear unit (ReLU): f(z) = max(0, z). It outputs zero for negative inputs and passes positive ones unchanged. The 2012 AlexNet paper reported that deep convolutional networks using ReLUs "train several times faster than their equivalents with tanh units," an older S-shaped activation [5].
The weights and biases are the network's parameters. PyTorch's documentation describes a neural network as a collection of nested functions "defined by parameters (consisting of weights and biases)" [2]. Learning means finding good values for them.
Layers: from inputs to outputs
Neurons are organized into layers:
- Input layer: the raw data, such as pixel brightness values or numbers representing words.
- Hidden layers: intermediate layers that transform the data step by step. "Deep" learning simply means many hidden layers.
- Output layer: the answer, such as a probability for each possible label, or a score for the next word.
Hidden layers are where the interesting work happens. In their 1986 Nature paper, David Rumelhart, Geoffrey Hinton and Ronald Williams showed that when a network is trained, "internal 'hidden' units which are not part of the input or output come to represent important features of the task domain" [1]. In an image network, early layers tend to pick up edges and later layers combine them into parts and objects. Nobody hand-codes these features. They emerge from training.
How a neural network learns
PyTorch's tutorials break training into a loop [2][3]:
- Forward pass. Feed an example through the network, layer by layer, to get a prediction. PyTorch describes this as the network making "its best guess about the correct output" [2].
- Loss. Compare the prediction with the correct answer using a loss function, a single number for "how far is the output from being correct" [3].
- Backward pass (backpropagation). Work backward from the output, using calculus (the chain rule) to compute how much each weight contributed to the error. These values are gradients. In PyTorch's words, backprop traverses "backwards from the output, collecting the derivatives of the error with respect to the parameters" [2].
- Update. Nudge every weight a small step in the direction that reduces the error. The simplest rule, from PyTorch's tutorial, is: weight = weight โ learning_rate ร gradient [3]. This is gradient descent.
- Repeat over many examples, often millions, until the loss stops improving.
Backpropagation, popularized by that 1986 paper, is what made multilayer networks practical to train. The Nature paper describes a procedure that "repeatedly adjusts the weights of the connections in the network so as to minimize a measure of the difference between the actual output vector of the net and the desired output vector" [1]. Its key advantage over the earlier perceptron learning rule was the "ability to create useful new features" in hidden layers [1].
Once training ends, the weights are frozen and the network only runs forward passes. That's inference. For the difference in cost and hardware, see AI Model Training vs Inference.
A short history in five papers
Year | Milestone | Why it mattered |
|---|---|---|
1986 | Rumelhart, Hinton and Williams, "Learning representations by back-propagating errors," Nature [1] | Showed how to train hidden layers |
1989 | LeCun et al., "Backpropagation Applied to Handwritten Zip Code Recognition," Neural Computation [4] | Applied backprop to a real recognition task |
1998 | LeCun, Bottou, Bengio and Haffner, "Gradient-Based Learning Applied to Document Recognition," Proceedings of the IEEE [4] | Detailed convolutional networks for handwriting recognition (the LeNet family) |
2012 | Krizhevsky, Sutskever and Hinton, AlexNet, NeurIPS [5] | Won ILSVRC-2012 with a 15.3% top-5 error versus 26.2% for the runner-up, trained on two GPUs |
2017 | Vaswani et al., "Attention Is All You Need" [7] | Introduced the Transformer, now the basis of large language models |
AlexNet is often called the start of the deep learning boom. Its 60 million parameters took five to six days to train on two NVIDIA GTX 580 GPUs, and its authors wrote that results "can be improved simply by waiting for faster GPUs and bigger datasets" [5]. That turned out to be right. For why GPUs suit this math, see AI Chips vs CPUs vs GPUs vs TPUs.
Main types of neural networks
Architecture | How it's wired | Good at | Example |
|---|---|---|---|
Feedforward (multilayer perceptron) | Every neuron connects to every neuron in the next layer | Tabular data, simple classification | Small classifiers; the final layers of larger networks |
Convolutional neural network (CNN) | Small filters slide across the input, reusing the same weights | Images, video | LeNet [4], AlexNet [5] |
Residual network (ResNet) | Adds "shortcut" connections that skip layers | Very deep image models | ResNet, up to 152 layers on ImageNet [6] |
Recurrent neural network (RNN) | Feeds its own output back in, step by step | Sequences (older approach) | Pre-Transformer translation models [7] |
Transformer | Uses attention to relate every element to every other | Language, and increasingly images and audio | Large language models [7] |
Depth was a problem before ResNet. Its authors noted that "deeper neural networks are more difficult to train" and introduced residual connections, which let them train networks 8 times deeper than earlier VGG models [6]. Transformers then replaced recurrence with attention, making training "more parallelizable" [7]. See How Transformer Models Work.
Neural networks also learn embeddings, lists of numbers that represent things like words. Google's 2013 word2vec paper highlights a striking result from earlier work: such vectors capture relationships, so that vector("King") โ vector("Man") + vector("Woman") lands closest to the vector for "Queen" [10]. See Embedding Models Explained.
Where neural networks are used
- Computer vision: classifying images, detecting objects, reading medical scans. See Computer Vision Explained.
- Language: translation, search, chatbots. See How Large Language Models Work.
- Speech: voice assistants and transcription.
- Recommendations and forecasting: ranking content, predicting demand.
Neural networks are one family within machine learning, and not always the best one. For how they fit with other methods, see Machine Learning vs Deep Learning vs AI.
Limitations
- Data hunger. Large networks need large datasets. AlexNet trained on 1.2 million labeled images [5]. Small datasets often favor simpler models.
- Compute cost. Training big networks requires specialized hardware and significant energy.
- Opacity. A trained network is millions or billions of numbers, hard to inspect. NIST's AI Risk Management Framework lists "explainable and interpretable" as a property of trustworthy AI and warns that risk can stem from "the opaque nature of AI systems" [9].
- Brittleness. Networks can fail on inputs unlike their training data, sometimes with high confidence.
- Learned bias. A network reproduces patterns in its training data, including unfair ones [9].
How to decide if you need one
Use a neural network when you have lots of data and the input is unstructured: images, audio, free text. For a spreadsheet with a few thousand rows, a simpler model is usually cheaper, faster and easier to explain. And for many language and vision tasks, you no longer train from scratch at all: you adapt a large pretrained network. See What Are Foundation Models?
Frequently asked questions
Are neural networks the same as the human brain?
No. They were loosely inspired by neurons and synapses [8], but an artificial neuron is just a weighted sum followed by a simple function. Real neurons are far more complex, and brains don't learn by backpropagation in any established sense.
What is the difference between a neural network and deep learning?
Deep learning is the use of neural networks with many hidden layers. A network with one hidden layer is a neural network; a network with dozens or hundreds of layers is a deep neural network.
What is backpropagation in simple terms?
It's how a network figures out which weights to blame for an error. After a wrong prediction, it works backward from the output, computing how much each weight contributed, then adjusts each weight slightly to reduce the error [1][2].
What does an activation function do?
It adds nonlinearity, letting the network model complex patterns. Without it, many layers would behave like one linear layer. ReLU, which outputs max(0, z), is a widely used choice that trains faster than older S-shaped functions [5].
How many layers does a neural network need?
It depends on the task. LeNet-style digit recognizers used a handful of layers, while ResNet trained networks up to 152 layers deep on ImageNet [6]. More layers add capacity but also cost and training difficulty.
Sources
- Rumelhart, D. E., Hinton, G. E., and Williams, R. J. "Learning representations by back-propagating errors." Nature 323, 533 (October 1986). https://www.nature.com/articles/323533a0
- PyTorch. "A Gentle Introduction to torch.autograd." https://docs.pytorch.org/tutorials/beginner/blitz/autograd_tutorial.html
- PyTorch. "Neural Networks." https://docs.pytorch.org/tutorials/beginner/blitz/neural_networks_tutorial.html
- LeCun, Y., et al. "Backpropagation Applied to Handwritten Zip Code Recognition." Neural Computation 1(4):541โ551, 1989; LeCun, Y., Bottou, L., Bengio, Y., and Haffner, P. "Gradient-Based Learning Applied to Document Recognition." Proceedings of the IEEE 86(11):2278โ2324, November 1998. Listed at http://yann.lecun.com/exdb/publis/index.html
- Krizhevsky, A., Sutskever, I., and Hinton, G. E. "ImageNet Classification with Deep Convolutional Neural Networks." NeurIPS 2012. https://papers.nips.cc/paper_files/paper/2012/hash/c399862d3b9d6b76c8436e924a68c45b-Abstract.html
- He, K., et al. "Deep Residual Learning for Image Recognition." arXiv 1512.03385. https://arxiv.org/abs/1512.03385
- Vaswani, A., et al. "Attention Is All You Need." arXiv 1706.03762. https://arxiv.org/abs/1706.03762
- The Royal Swedish Academy of Sciences. "The Nobel Prize in Physics 2024." Press release, October 8, 2024. https://www.nobelprize.org/prizes/physics/2024/press-release/
- National Institute of Standards and Technology. "Artificial Intelligence Risk Management Framework (AI RMF 1.0), NIST AI 100-1." https://nvlpubs.nist.gov/nistpubs/ai/NIST.AI.100-1.pdf
- Mikolov, T., et al. "Efficient Estimation of Word Representations in Vector Space." arXiv 1301.3781. https://arxiv.org/abs/1301.3781