Neural network

Also known as: artificial neural network

On this page 7

A neural network, or artificial neural network, is a machine learning model composed of layers of simple computing units (neurons) connected by weighted links. Each unit computes a weighted sum of its inputs, adds a bias and applies a nonlinear activation function; stacking many such layers lets the network represent highly complex functions that map inputs such as pixels, words or sensor readings to outputs such as labels, values or generated text.

Neural networks are the foundation of deep learning and of nearly all modern artificial intelligence systems, from image recognition to large language models. They learn by adjusting millions to trillions of parameters with gradient-based optimization so that their predictions match training data. Architectures such as convolutional networks, recurrent networks and the transformer are specialized neural networks.

How a neural network computes

In a feedforward network, data flows from an input layer through one or more hidden layers to an output layer. A layer multiplies its input vector by a weight matrix, adds a bias vector and applies an activation function elementwise. Without the nonlinearity, any stack of layers would collapse into a single linear transformation; with it, a network with enough units can approximate a very wide class of functions, a result known as the universal approximation theorem.

The output layer is shaped by the task: a softmax over classes for classification, a linear unit for regression, or a distribution over a vocabulary for language generation. The table below summarizes the building blocks.

ComponentFunctionTypical choice
Neuron (unit)Weighted sum plus bias, then activationThousands to millions per model
Weights and biasesLearnable parametersInitialized randomly with scaled variance
Activation functionIntroduces nonlinearityReLU, GELU, sigmoid, tanh
Hidden layerBuilds intermediate representationsFew in small models, hundreds in deep ones
Output layerProduces the predictionSoftmax, sigmoid or linear
Loss functionMeasures prediction errorCross-entropy, mean squared error
Building blocks of a neural network

How neural networks learn

Training minimizes a loss function over examples. For each mini-batch, the network performs a forward pass to compute predictions and loss, then backpropagation applies the chain rule to compute the gradient of the loss with respect to every weight. An optimizer such as stochastic gradient descent or Adam then updates the weights a small step against the gradient. Repeating this over many passes through the data, called epochs, gradually reduces the error.

HyperparameterTypical rangeEffect
Learning rateAbout 1e-5 to 1e-1, depending on optimizerToo high diverges, too low trains slowly
Batch sizeAbout 16 to several thousand examplesGradient noise, memory use, throughput
Number of epochsOne to hundredsUnderfitting versus overfitting
Weight decayAbout 0 to 0.1Penalizes large weights to improve generalization
Dropout rateAbout 0.1 to 0.5Randomly disables units to reduce overfitting
Depth and widthFrom a few layers to hundredsCapacity, compute cost, trainability
Key training hyperparameters

Deep networks once suffered from vanishing and exploding gradients, where gradients shrink or grow exponentially across layers. Practical fixes include ReLU-family activations, careful initialization, normalization layers and residual connections, which add a layer’s input to its output and let very deep models train stably.

Main neural network architectures

Architectures differ in how neurons are connected, which builds assumptions about the data into the model. Choosing an architecture that matches the structure of the data, such as spatial grids, sequences or sets, reduces the amount of data needed to learn well.

ArchitectureKey mechanismTypical data and tasks
Multilayer perceptronFully connected layersTabular data, small prediction tasks
Convolutional neural networkShared local filters over gridsImages, video, spectrograms
Recurrent neural network and LSTMHidden state carried across time stepsTime series, older speech and text systems
TransformerAttention mechanism across all positionsLanguage, code, images, multimodal models
AutoencoderCompress then reconstruct inputRepresentation learning, anomaly detection
Graph neural networkMessage passing between connected nodesMolecules, networks, recommendations
Neural network architectures and their typical data

Large modern systems often combine these elements, for example an encoder-decoder architecture built from transformer blocks, or a mixture of experts in which a router activates only a subset of subnetworks for each input to increase capacity without a proportional rise in compute.

Neural networks compared with other machine learning models

Neural networks excel when data is large and unstructured, such as images, audio and text, because they learn useful features automatically. On small or tabular datasets, gradient-boosted decision trees frequently match or beat them with less tuning and better interpretability.

SituationRecommended modelReason
Millions of labeled imagesConvolutional network or vision transformerLearns visual features directly
Natural language understanding or generationTransformer-based modelCaptures long-range context
Few thousand rows of tabular dataGradient-boosted treesStrong accuracy with little data
Strict explainability requirementLinear model or shallow treeTransparent decision logic
Limited compute at the edgeSmall or quantized networkFits memory and latency limits
When to choose a neural network

Limitations and common misconceptions

  • Not a model of the brain: artificial neurons are loosely inspired by biology but work very differently.
  • Data hunger: large networks need large, representative training sets and overfit small ones.
  • Opacity: learned weights are hard to interpret, which complicates auditing and debugging.
  • Brittleness: performance can drop sharply under distribution shift or adversarial inputs.
  • Compute cost: training and inference of large models require substantial hardware and energy.
  • Overconfidence: output probabilities are often poorly calibrated without explicit correction.

Put simply

A neural network is a large set of adjustable dials connected in layers. Data goes in one side and an answer comes out the other. At first the dials are set randomly, so the answers are wrong.

During training, the network sees many examples with the correct answers. After each mistake, every dial is nudged slightly in the direction that would have helped. After millions of small corrections, the network gives good answers on examples it has never seen.

In practice

A manufacturer of circuit boards inspects every board with a camera at the end of the line. Rule-based inspection missed subtle solder defects and raised many false alarms. The quality team trained a convolutional neural network on about 50,000 labeled images of good and defective boards, using data augmentation such as small rotations and lighting changes.

The network runs on a small accelerator next to the line and classifies each image in a few milliseconds. Boards it scores as uncertain go to a human inspector. Over the following months, false alarms fell substantially while defect detection improved, and new defect types were handled by retraining with a few hundred additional examples rather than rewriting inspection rules.