Change and uncertainty / 7 of 7

Mathematical foundations of neural networks

8 minOpening your notebook…

What you’ll learn

  • Explain the main idea of “Mathematical foundations of neural networks” in your own words.
  • Trace a concrete example and identify the assumptions behind it.
  • Apply the principle in a practice problem and recognize a common failure.

The idea, intuitively

A dense neural layer combines an affine transformation (a weighted sum plus a bias) with an activation. Stacking affine layers without nonlinear activations still produces a single affine transformation. Nonlinearity gives a network the ability to model more complex relationships.

Use small numbers first and work one operation at a time. Track the shape and units of every quantity before doing algebra. The equations here describe idealized objects; implementing them on a computer introduces finite precision and resource constraints. You can understand the mechanism before learning every proof.

Under the hood

A dense layer computes h=σ(Wx+b). Parameters include every weight and bias. With n inputs and m outputs, a dense layer has nm+m parameters, independent of batch size.

h=σ(Wx+b)h=\sigma(Wx+b)
W and b are shared across examples. The activation σ acts on the result Wx + b to produce h.
A useful caution

Activation values depend on inputs; parameters are learned across examples.

A worked example

A layer with 4 inputs and 3 outputs has 12 weights and 3 biases: 15 trainable parameters.

How to use this way of thinking

Check a symbolic result with a numeric example, then consider an edge case such as zero, a very large value, or an incompatible shape. Explain what each symbol means rather than memorizing the equation. If a result surprises you, inspect the assumptions and the units first.

See the mechanism

Educational simulationRuns in your browser with simplified rules and example settings.
Try this

Set the network to 5 hidden units and both inputs to 0. Which units still have a nonzero activation? Check the bias column in the weights table.

Opening the experiment…

Try it yourself

Explain why two dense layers with biases and no activation can be merged.

Key takeaways

  • 15
  • Activation values depend on inputs; parameters are learned across examples.
  • Check the assumptions with a small example before applying this idea to a larger system.

Check your understanding

0/2 checked

Use feedback to learn. Quiz scores and lesson completion are tracked separately.

1How many parameters are in a dense 2-to-5 layer with bias?
2True or false: Stacking affine layers without nonlinear activation remains an affine transformation.
Go to lesson completion

Further reading

Original papers and reference material for this school. External resources may be in English and require internet access.

Mathematics for Machine Learning (open textbook) (opens a new tab)

Finish this lesson

Mark this lesson complete when you’re ready to continue.

Start with a question

Introduction to AIAI FoundationsA brief history of AIAI FoundationsTypes of AIAI FoundationsAI, ML, and deep learningAI FoundationsUnderstanding generative AIAI FoundationsEthics, limitations, and responsibilityAI FoundationsLinear algebra for learning systemsMathematics for AIVectors, matrices, and similarityMathematics for AICalculus: measuring changeMathematics for AIDerivatives and gradientsMathematics for AIProbability and statisticsMathematics for AIOptimization and objectivesMathematics for AI
K to open · Escape to close