The Modern Mathematics of Deep Learningexplained for non-mathematicians

Backpropagation through two layers

Penguin learning project

The project uses 342 complete Palmer penguin records: 240 training-pool and 102 held-out rows. The selected training rows determine feature scaling and model parameters. Source CSV

This project trains weights with softmax, unlike the homepage lab, which uses nearest species averages. Same penguin measurements; different classification methods. Predictions can differ.

Functions and derivatives · Describe maps and how their outputs change.

Project vectors have two features; the training matrix has n rows and two columns. Mathematical tools may operate on these values when their assumptions apply.

Consider this concept alongside the project; its source assumptions may differ. These observations do not prove a theorem.

Input: 12 × 2; Held-out evaluation: 102 · #58 · 40.6 mm, 193 mm. Known answer: Adélie; Prediction: Adélie · [≈0.7383, ≈0.2444, ≈0.01737].

Used in these source sections: 2.3 The path matters

The chain rule multiplies how each stage responds to a small change. In a scalar example, these factors are ordinary numbers.

Take Φ(x)=v·ReLU(ux). Away from ux=0, the derivative with respect to u is v·ReLU′(ux)·x.

Backpropagation computes how parameters affect the output.

Source formula example

∇W(ℓ)Φ=ϱ(Φ(ℓ−1))∂Φ∂Φ(ℓ+1)∂Φ(ℓ+1)∂Φ(ℓ)=ϱ(Φ(ℓ−1))∂Φ∂Φ(ℓ+1)W(ℓ+1)diag⁡(ϱ′(Φ(ℓ))),\nabla_{W^{(\ell)}}\Phi=\varrho(\Phi^{(\ell-1)})\frac{\partial\Phi}{\partial\Phi^{(\ell+1)}}\frac{\partial\Phi^{(\ell+1)}}{\partial\Phi^{(\ell)}}=\varrho(\Phi^{(\ell-1)})\frac{\partial\Phi}{\partial\Phi^{(\ell+1)}}W^{(\ell+1)}\operatorname{diag}\big(\varrho^{\prime}(\Phi^{(\ell)})\big),

illustration · This scalar calculation is away from the ReLU breakpoint and does not compute the full matrix gradient of a general network.

Symbols

W(ℓ)W^{(ℓ)}
Weight matrix of layer ℓ.
ρ′ρ^{\prime}
Activation derivative, where defined.

Source formula example

This source example uses its own inputs and assumptions. Editing it does not change the project.

Edit a value or the code, then run the example. This is a finite demonstration, not a proof of the paper’s theorem.

This example’s data flow

You choose

  • input.u = 2
  • input.x = 1
  • input.v = 3

Calculated here

Result expression: { preactivation, activation, activationDerivative, output, gradientU, gradientMatrix: [[gradientU]], gradientShape: [1, 1], }

  • preactivation = input.u * input.x Uses: input.u, input.x
  • activation = Math.max(0, preactivation) Uses: preactivation
  • activationDerivative = preactivation > 0 ? 1 : 0 Uses: preactivation
  • output = input.v * activation Uses: input.v, activation
  • gradientU = input.x * input.v * activationDerivative Uses: input.x, input.v, activationDerivative

Returns

Example result
preactivation
2
activation
2
activationDerivative
1
output
6
gradientU
3
gradientMatrix
array (1 items): [array (1 items): [3]]
gradientShape
array (2 items): [1, 1]

Read numbers from input and return the result. JavaScript basics.

Result

Enable JavaScript to run this example.

Technical statement

The source applies the chain rule to a biasless scalar-output network. The source displays the gradient with shape N_(ℓ−1) by N_ℓ. The toy uses one scalar input and one hidden unit, so its displayed gradient shape is 1 by 1. ReLU has no unique derivative at zero and the code rejects that case.

Source: Source expression