Skip to content
AI.info

Neural networks

Neural Networks as Differentiable Programs

Build a precise mental model of neural networks as parameterized functions whose internal representations are shaped by data and an objective.

By the end you can

A network is a program whose numbers are learned

Ordinary software stores instructions chosen directly by a programmer. A neural network stores a computational structure plus many adjustable numbers called parameters.

Training does not invent arbitrary code. It searches parameter values that make the fixed computation behave better on examples. An objective supplies the measurement.

That the structure comes first is a theorem rather than a slogan, and the theorem has a number in it. Four units decide the question. Lu and four co-authors stated it in 2017: “We show a universal approximation theorem for width-bounded ReLU networks: width-(n + 4) ReLU networks, where n is the input dimension, are universal approximators. Moreover, except for a measure zero set, all functions cannot be approximated by width-n ReLU networks, which exhibits a phase transition.” Above the line, the parameters can be set to reach anything. Below it, except on a set of measure zero, no parameter setting reaches the target at all. No quantity of data or training changes that.

The width-bounded case was proved independently in 2020 by Kidger and Lyons. Take any nonaffine continuous activation with a continuous nonzero derivative at some point — ReLU included. Networks of arbitrary depth and width n+m+2 are then dense in C(K;R^m) for compact K ⊆ R^n, with n the number of input neurons and m the number of output neurons. Two groups, two proofs, the same shape of conclusion. A choice made before the first example arrives fixes which functions are reachable.

Width n+4 is universal and width n is not: the architecture decides what can be computed, and training only chooses values inside that design.

Case

One program learned chess, shogi and Go from the rules alone

How far one fixed computation can be carried by its numbers alone has been measured. A single algorithm, AlphaZero, “convincingly defeated a world champion program in the games of chess and shogi (Japanese chess), as well as Go”, “starting from random play and given no domain knowledge except the game rules”. Silver and twelve co-authors reported that in Science in 2018. DeepMind's own account of the result puts the training at roughly nine hours for chess, twelve for shogi and thirteen days for Go. Three players, three sets of learned numbers, one program.

Visual

Four ingredients behind every neural network

The word “network” hides several distinct objects. Keeping them separate prevents most beginner confusion.

The winning entry in the 2012 ImageNet challenge puts numbers on all four at once. Krizhevsky and two co-authors described it in a single sentence: “The neural network, which has 60 million parameters and 650,000 neurons, consists of five convolutional layers, some of which are followed by max-pooling layers, and three fully-connected layers with a final 1000-way softmax.” Read that sentence as a parts list. The eight layers, the max-pooling and the 1000-way softmax are the architecture, chosen by hand and fixed before training began. The 60 million numbers are the parameters, and they are what training changed. The 650,000 unit outputs are activations, recomputed for every image and stored for none of them. The softmax and the loss attached to it are where the objective enters.

The objective's verdict on that parameter setting is on the public record. The challenge organisers list team SuperVision at a five-guess error of 0.15315 and the runner-up ISI submission at 0.26172 — 15.3% against 26.2%, in the same table, on the same test set.

FigureHierarchy · 4 levels
  • Architecture

    The graph of operations, connections, shapes, and information paths chosen before training.

    • Parameters

      Trainable tensors such as weight matrices, biases, embedding tables, and normalization gains.

      • Activations

        Temporary values produced for a particular input during the forward pass.

        • Objective

          A rule that scores outputs and supplies the direction used to adjust parameters.

Example

The same architecture can learn very different functions

Architecture alone does not determine behavior. Data, initialization, objective, optimization, and stopping choices all shape the learned function.

The clearest documented case of one architecture serving many behaviours is BERT. Devlin and three co-authors reported it in 2019: “As a result, the pre-trained BERT model can be fine-tuned with just one additional output layer to create state-of-the-art models for a wide range of tasks, such as question answering and language inference, without substantial task-specific architecture modifications.” Eleven natural language processing tasks, one pre-trained parameter set, no substantial change to the shape of the computation. The scores were GLUE 80.5, MultiNLI 86.7%, SQuAD v1.1 test F1 93.2, SQuAD v2.0 test F1 83.1. They are not only the authors' own. Stanford's independently maintained SQuAD 2.0 leaderboard carries the matching row: “Nov 08, 2018 | BERT (single model) | Google AI Language | 80.005 | 83.061”.

The converse experiment is sharper still, because it holds the architecture fixed and corrupts only the data. Zhang and four co-authors reported that “Specifically, our experiments establish that state-of-the-art convolutional networks for image classification trained with stochastic gradient methods easily fit a random labeling of the training data.” The same networks still fit when the real images are replaced by unstructured random noise. Arpit and ten co-authors examined the phenomenon independently in 2017, and concluded that “training data itself plays an important role in determining the degree of memorization”. Same graph of operations, same optimizer, same loss. What the labels were decided whether the result was a classifier or a lookup table.

  • Image classification: the same convolutional backbone can separate plant species, machine defects, or road signs after different training.
  • Language modeling: identical transformer shapes can learn different languages, styles, and domains from different corpora.
  • Risk scoring: one multilayer perceptron may estimate credit default, equipment failure, or churn from unrelated tabular features.
  • Representation learning: a network can expose embeddings rather than a final decision — the BERT recipe of one additional output layer per task, with the shared body untouched.
  • Multi-task learning: shared layers can support several output heads whose objectives pull the representation in different directions.

Why differentiability matters

A differentiable operation has a usable local sensitivity. A small input change implies a describable output change. Chain those sensitivities together across every step of the computation, and training can estimate how each parameter affected the final loss.

Neural networks also contain piecewise or nondifferentiable points. At those points the frameworks do not compute a derivative — they apply a convention. ReLU at zero is the standard case, and a 2021 paper by Bertoin and three co-authors opens by naming both the freedom and the choice: “A priori, any value in [0, 1] bears a variational sense as it corresponds to a subgradient [27]. Yet in most libraries s = 0 is chosen; it is the case for TensorFlow [2], PyTorch [26] or Jax [10].” One of the three states the convention in its own source code. The comment in TensorFlow's ReluGrad functor reads “NOTE: When the activation is exactly zero, we do not propagate the associated gradient value. This allows the output of the Relu to be used, as well as its input.”

How much that convention costs is itself a lesson in checking a number before repeating it. The published paper reported backward passes whose outputs differ “around half of the time in 32 bits precision”, and an ImageNet test-accuracy gain of “more than 10 points” for ReLU'(0)=0 over ReLU'(0)=1. The authors withdrew both figures themselves. Their erratum, in 2023, followed a bug that three other researchers found in the backward implementation of their modified ReLU.

With the bug fixed, the bifurcation zone survives: 43% of parameters at 32-bit precision, 100% at 16-bit, 0% at 64-bit. But the L2 magnitude of the difference falls by a factor of about 10^5. No effect on training loss or test accuracy appears for reasonable values of ReLU'(0) between 0 and 1. An effect appears only for unrealistically large values, around 1000 and above. The ImageNet ResNet50 experiment showed no qualitative change and is not reported. The convention is real and it is visible in the arithmetic. The dramatic reading of it did not survive someone else running the code.

How cheap is that credit assignment? A 2018 survey by Baydin and three co-authors puts a figure on it. Take a function of many inputs and one output. For that case, “only one application of the reverse mode is sufficient to compute the full gradient”, “compared with the n passes of the forward mode needed for populating the same”. The survey also bounds the overhead. Automatic differentiation “guarantees that the amount of arithmetic goes up by no more than a small constant factor”. That asymmetry is why gradient-trained networks are practical at all. Some of them carry hundreds of millions of parameters. The reason is not any resemblance to biology.

Differentiability makes credit assignment efficient; it does not make the objective correct or the result globally optimal.

Comparison

Three views of the same network

Engineers switch views depending on the question. No single view is sufficient for design, debugging, and explanation.

The representation view is the oldest of the three, and it arrived on a date. Back-propagation was published in Nature in the issue of 9 October 1986. The procedure repeatedly adjusts connection weights to minimise the difference between actual and desired output, and the abstract states the representation claim outright: “As a result of the weight adjustments, internal ‘hidden’ units which are not part of the input or output come to represent important features of the task domain, and the regularities in the task are captured by the interactions of these units.”

Notice what the founding sentence claims and what it does not. It claims that hidden values come to carry features of the task. That is the representation view, in its original wording. It does not claim that any one of them carries a single human-readable meaning, and the object it names is a unit. The Royal Swedish Academy of Sciences' 2024 Physics scientific background records the same paper as the pivotal step: “A key advance was the demonstration by David Rumelhart, Hinton and Ronald Williams in 1986 of how architectures with one or more hidden layers could be trained for classification using an algorithm known as backpropagation”.

FigureComparison · 3 columns

Function view

Treat the network as a mapping from input tensors to output tensors.

  • Best for reasoning about interfaces
  • Tracks shapes and task outputs
  • Hides internal execution details
  • Example: image tensor to class logits

Graph view

Treat each operation as a node connected by data dependencies.

  • Best for forward and backward flow
  • Makes branching and reuse visible
  • Supports automatic differentiation
  • Example: residual block with two paths

Representation view

Treat hidden activations as learned descriptions of the input.

  • Best for analyzing internal features
  • Connects layers to downstream tasks
  • Invites interpretation but not certainty
  • Example: an embedding used for retrieval

Analogy

A soundboard with trainable controls

A studio soundboard has fixed wiring and thousands of knobs that can move. Training repeatedly plays examples, measures the output, and nudges knobs that contributed to the error.

Parameters interact through nonlinear mathematics rather than as independent controls. Hidden units also lack human intent or semantic awareness.

How much artificial machinery one biological neuron is worth has been measured too, and the answer is not one unit. Beniaguev and colleagues built detailed biophysical models of cortical cells. They then trained deep networks to reproduce their input/output behaviour at millisecond resolution. They report in Neuron, in 2021, that “a temporally convolutional DNN with five to eight layers was required to capture the I/O mapping of a realistic model of a layer 5 cortical pyramidal cell (L5PC)”. Remove the NMDA receptors from the simulated cell and the cost drops. Then “a much simpler network (fully connected neural network with one hidden layer) was sufficient to fit the model”. A hidden unit is not a small neuron. It is a much smaller thing than a neuron.

A network is trainable because many small controls jointly shape one computation.

Position

A hidden unit is not a small neuron, and the vocabulary keeps saying it is

The course takes a side here, because the borrowed words are not neutral and they arrive first. Neuron, neural, learns, brain-inspired: each one carries an implication about what the thing is, and it reaches the reader before a single equation does.

The most authoritative body in the field has already backed away from them, in the very document that honoured the work. On 8 October 2024 the Royal Swedish Academy of Sciences awarded the Nobel Prize in Physics to John Hopfield and Geoffrey Hinton “FOR FOUNDATIONAL DISCOVERIES AND INVENTIONS THAT ENABLE MACHINE LEARNING WITH ARTIFICIAL NEURAL NETWORKS”. In the scientific background written for that award, the Nobel Committee for Physics puts the vocabulary in quotation marks and supplies the replacement in the same breath: “Inspired by biological neurons in the brain, ANNs are large collections of “neurons”, or nodes, connected by “synapses”, or weighted couplings, which are trained to perform certain tasks rather than asked to execute a predetermined set of instructions.” Nodes and weighted couplings. And the family of objects the committee places the structure in is not a neuroscientific one: it notes “close similarities with spin models in statistical physics applied to magnetism or alloy theory”. The laureates “used fundamental concepts from statistical physics to design artificial neural networks”, said Ellen Moons, the committee's chair, at the announcement. The prize for artificial neural networks is a physics prize. Its own citation document will not use the word neuron without holding it at arm's length.

The one measurement in this lesson that compares the two runs the other way. Beniaguev and colleagues needed a temporally convolutional network of five to eight layers to capture the input/output mapping of a realistic model of one layer 5 cortical pyramidal cell at millisecond resolution. Remove the NMDA receptors from the simulated cell and one hidden layer was enough. The exchange rate is not one for one. It is not even close. And which fraction of a cell a unit is worth depends on how much of the biology you leave in.

Nothing is lost by dropping the word. What this lesson described is a fixed computation with adjustable numbers, and the reason it is trainable at scale is arithmetic rather than resemblance: for a function of many inputs and one output, one reverse pass produces the whole gradient where forward mode needs n. That is a fact about the cost of credit assignment. When a claim about a system leans on the biology instead — it thinks, it recognises, it understands — the biology is not the evidence, and there is no evidence behind it. Ask what the program computes and what the objective rewarded.

Even the Nobel citation document keeps the word neuron in quotation marks, and glosses it as a node connected by weighted couplings.

Steps

Trace a network before discussing its intelligence

Use this trace whenever you meet an unfamiliar neural model. Every step asks for something a reader can go and check, in the way that eight layers, 60 million parameters and a five-guess error of 0.15315 can be checked.

FigureProcess · 5 steps
  1. 1. Name the input

    Record the tensor meaning, axes, units, and valid range.

  2. 2. Follow operations

    List transformations, branches, reused parameters, and shape changes.

  3. 3. Identify outputs

    Distinguish raw scores, probabilities, embeddings, or generated values.

  4. 4. Locate the objective

    State what signal determines a better parameter setting.

  5. 5. Check the workflow

    Ask how outputs become decisions and where human or software controls intervene.

Key idea

What this path will explain

This path focuses on the mechanics shared across many neural networks: layers, tensors, activations, forward computation, losses, gradients, backpropagation, stabilization, representations, and debugging.

Path 6 will survey specialized deep architectures in detail. Path 9 will examine optimizers, schedules, scaling, and training strategy more deeply.

The goal is to understand the engine before cataloging every vehicle built around it.

Key takeaways