Backpropagation as a Linear Solve

In the previous post on backpropagation, we showed that backpropagation is a special case of the adjoint method. In this post we skip the adjoint description and instead derive the same result directly from the chain rule.

1. The forward relation

We denote the data by ๐‘ข0 and the parameters by ๐œƒโˆˆโ„๐‘. The network has ๐‘ layers, each of which is a function ฮฆ๐‘– that takes as input outputs from previous layers (๐‘ข๐‘–โˆ’1,โ€ฆ,๐‘ข0) as well as the parameters (๐œƒ), and produces the next layer output ๐‘ข๐‘–. The full forward pass, including all layer outputs, can be expressed as

[๐‘ข1๐‘ข2โ‹ฎ๐‘ข๐‘]โŸ๐‘ข(๐œƒ)=[ฮฆ1(๐‘ข0,๐œƒ)ฮฆ2(๐‘ข1,๐‘ข0,๐œƒ)โ‹ฎฮฆ๐‘(๐‘ข๐‘โˆ’1,โ€ฆ,๐‘ข0,๐œƒ)]โŸฮฆ(๐‘ข(๐œƒ),๐œƒ)โˆˆโ„๐‘‘,

(1)

where ๐‘‘=โˆ‘๐‘–=1๐‘๐‘›๐‘– and ๐‘›๐‘– is the size of ๐‘ข๐‘–.

We introduce the projection ๐‘ƒโˆˆโ„๐‘Ÿร—๐‘‘ that takes out relevant layer-outputs, i.e.11 Often ๐‘ƒ just picks out the last layer, i.e. ๐‘ข๐‘ƒ=๐‘ข๐‘=๐‘ƒ๐‘ข(๐œƒ),๐‘ƒ=(0โ€ฆ0๐ผ๐‘Ÿ).

๐‘ข๐‘ƒ(๐œƒ)=๐‘ƒ๐‘ข(๐œƒ).

(2)

Using this the loss function can be written as

๐’ฅ๏ธ€(๐œƒ)=โ„“(๐‘ข๐‘ƒ(๐œƒ))+๐œ‡โ„›๏ธ€(๐œƒ),

(3)

where โ„“ is the data loss and โ„›๏ธ€ is a regularization term.

2. Differentiating the network

Applying the chain rule to (1), we have

d๐‘ขd๐œƒ=๐œ•ฮฆ๐œ•๐‘ขd๐‘ขd๐œƒ+๐œ•ฮฆ๐œ•๐œƒ,henced๐‘ขd๐œƒ=(๐ผโˆ’๐œ•ฮฆ๐œ•๐‘ขโŸ๐ฟ)โˆ’1๐œ•ฮฆ๐œ•๐œƒโŸ๐‘€โŠค.

(4)

Applying the projection ๐‘ƒ, it further follows that

d๐‘ข๐‘ƒd๐œƒ=๐‘ƒ๐ฟโˆ’1๐‘€โŠค.

(5)

At this point it is worth looking at the structure of the matrices. As the ๐‘–th layer depends only on previous outputs, the matrix ๐ฟ is block lower-triangular with identity blocks on the diagonal22 The sparsity pattern of the strictly lower/upper part of a (block) triangular matrix is a directed acyclic graph (DAG), which is often how backpropagation is introduced.. The triangular structure makes it efficient to solve the linear system

๐ฟโŠคฮ›=๐‘ƒโŠค,ฮ›โˆˆโ„๐‘‘ร—๐‘Ÿ.

(6)

Using ฮ› it follows that

d๐‘ข๐‘ƒd๐œƒ=ฮ›โŠค๐‘€โŠค.

(7)

In practice, as seen in the next section, one rarely needs to form d๐‘ข๐‘ƒd๐œƒ as a full matrix; it suffices to define products with it.

3. A scalar loss

Applying the chain rule to (3), we have

โˆ‡๐œƒ๐’ฅ๏ธ€=(d๐‘ข๐‘ƒd๐œƒ)โŠคโˆ‡๐‘ข๐‘ƒโ„“+๐œ‡โˆ‡๐œƒโ„›๏ธ€=๐‘€๐ฟโˆ’โŠค๐‘ƒโŠคโˆ‡๐‘ข๐‘ƒโ„“+๐œ‡โˆ‡๐œƒโ„›๏ธ€.

(8)

Given that โˆ‡๐‘ข๐‘ƒโ„“ is a vector of length ๐‘Ÿ we have that the product ๐‘ƒโŠคโˆ‡๐‘ข๐‘ƒโ„“ is a vector of length ๐‘‘. It is therefore of interest to first form ๐‘ƒโŠคโˆ‡๐‘ข๐‘ƒโ„“ and then solve ๐ฟโŠค๐œ†=๐‘ƒโŠคโˆ‡๐‘ข๐‘ƒโ„“, so that

โˆ‡๐œƒ๐’ฅ๏ธ€=๐‘€๐œ†+๐œ‡โˆ‡๐œƒโ„›๏ธ€,

(9)

which is equivalent to the final result of the adjoint method (see the previous post on backpropagation). Note that ๐œ† here is the negative of the adjoint variable of the previous post, which absorbs the sign of ๐œ•๐‘“๐œ•๐œƒ=โˆ’๐‘€โŠค there.

Cite this post

bibtex
@misc{paltorp2026backpropagationlinearsolve,
author = {Paltorp, Mikkel},
title = {{Backpropagation as a Linear Solve}},
year = {2026},
month = oct,
url = {https://mipals.github.io/pdf/2026/10-05-backpropagation-linear-solve/backpropagation-linear-solve.pdf},
note = {Blog post}
}