arXiv:2611.02152cs.CLNov 2026

Manuscript Offprint

arXiv:2611.02152

Detailed Derivation of The Backpropagation Algorithm

Faris Alasmary

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

1 Notation

Here are some notation conventions:

LL = the number of layers in the network (the input layer is not counted).

nln_l = the number of nodes (neurons) in the lthl^{th} layer. The input layer is called layer 0, so n0n_0 is the number of input values (features).

Z[l]Z^{[l]} = a vector of the weighted sums of all the nodes in the lthl^{th} layer (before applying the activation function).

Zj[l]Z_j^{[l]} = a scalar that represents the weighted sum of the jthj^{th} node in the lthl^{th} layer.

A[l]A^{[l]} = a vector of the outputs (activations) of all the nodes in the lthl^{th} layer.

Aj[l]A_j^{[l]} = a scalar that represents the output of the jthj^{th} node in the lthl^{th} layer.

W[l]W^{[l]} = a matrix of the weights that connect the layer (l−1l-1) to the layer ll.

Wjk[l]W_{jk}^{[l]} = a scalar that represents the weight that connects the kthk^{th} node of the layer (l−1l-1) to the jthj^{th} node of the layer ll.

b[l]b^{[l]} = a vector of the biases of the lthl^{th} layer and bj[l]b_j^{[l]} is the bias of its jthj^{th} node.

x(i)x^{(i)} = a vector of features of the ithi^{th} example and y(i)y^{(i)} is the vector of its target values.

y^(i)\hat{y}^{(i)} = a vector of the predicted values of the ithi^{th} example, i.e., the outputs of the last layer A[L]A^{[L]}.

mm = the number of examples in the dataset.

Note: the square brackets [l][l] always refer to a layer, the parentheses (i)(i) always refer to an example, and the curly braces {t}\{t\} always refer to a minibatch (Section(4)). When we work with a single example, we will drop the superscript (i)(i) and simply write xx, yy, and y^\hat{y}.

Note: for the subscripts, we will always use jj for a node of the current layer ll, kk for a node of the previous layer (l−1)(l-1), and pp for a node of the next layer (l+1)(l+1).

Note: the numbers under braces show the dimensions of matrices, i.e., rows ×\times columns.

Each layer ll takes the outputs of the previous layer A[l−1]A^{[l-1]} as its input. It multiplies them by its weights, adds its biases, and then passes the result to an activation function σ\sigma (we will define it in Section(2.1)). The equation of a single layer is:

Z[l]⏟nl×1=W[l]⏟nl×nl−1⋅A[l−1]⏟nl−1×1+b[l]⏟nl×1A[l]⏟nl×1=σ(Z[l]⏟nl×1)(1)\begin{aligned}\underbrace{Z^{[l]}}_{n_{l}\times1}&=\underbrace{W^{[l]}}_{n_{l}\times n_{l-1}}\cdot\underbrace{A^{[l-1]}}_{n_{l-1}\times1}+\underbrace{b^{[l]}}_{n_{l}\times1}\\ \underbrace{A^{[l]}}_{n_{l}\times1}&=\sigma\left(\underbrace{Z^{[l]}}_{n_{l}\times1}\right)\end{aligned} \tag{1}

If we look at a single node j of the layer l, equation(1) becomes:

Zj[l]=Wj1[l]A1[l−1]+Wj2[l]A2[l−1]+⋯+Wjnl−1[l]Anl−1[l−1]+bj[l]=(∑k=1nl−1Wjk[l]Ak[l−1])+bj[l]Aj[l]=σ(Zj[l])\begin{align*}Z_{j}^{[l]}&=W_{j1}^{[l]}A_{1}^{[l-1]}+W_{j2}^{[l]}A_{2}^{[l-1]}+\cdots+W_{jn_{l-1}}^{[l]}A_{n_{l-1}}^{[l-1]}+b_{j}^{[l]}\\&=\left(\sum_{k=1}^{n_{l-1}}W_{jk}^{[l]}A_{k}^{[l-1]}\right)+b_{j}^{[l]}\\A_{j}^{[l]}&=\sigma\left(Z_{j}^{[l]}\right)\end{align*}

(2)

i.e., the node jj computes a weighted sum of all the outputs of the previous layer, exactly like the equation of a line in linear regression [1], and then applies the activation function to it. We will explain these equations in detail in Section(2.4).

The weights matrix W[l]W^{[l]} that is used in equation(1) is:

W[l]=[W11[l]W12[l]W13[l]…W1nl−1[l]W21[l]W22[l]W23[l]…W2nl−1[l]W31[l]W32[l]W33[l]…W3nl−1[l]⋮⋮⋮⋱⋮Wnl1[l]Wnl2[l]Wnl3[l]…Wnlnl−1[l]]⏟nl×nl−1W^{[l]}=\underbrace{\left[\begin{matrix}{W_{11}^{[l]}}&{W_{12}^{[l]}}&{W_{13}^{[l]}}&{\ldots}&{W_{1n_{l-1}}^{[l]}}\\ {W_{21}^{[l]}}&{W_{22}^{[l]}}&{W_{23}^{[l]}}&{\ldots}&{W_{2n_{l-1}}^{[l]}}\\ {W_{31}^{[l]}}&{W_{32}^{[l]}}&{W_{33}^{[l]}}&{\ldots}&{W_{3n_{l-1}}^{[l]}}\\ {\vdots}&{\vdots}&{\vdots}&{\ddots}&{\vdots}\\ {W_{n_{l}1}^{[l]}}&{W_{n_{l}2}^{[l]}}&{W_{n_{l}3}^{[l]}}&{\ldots}&{W_{n_{l}n_{l-1}}^{[l]}}\\ \end{matrix}\right]}_{n_{l}\times n_{l-1}}

In equation(2), the weight Wjk[l]W_{jk}^{[l]} multiplies the output Ak[l−1]A_{k}^{[l-1]} of the kthk^{th} node of the layer (l−1)(l-1) and the result is added to Zj[l]Z_{j}^{[l]} of the jthj^{th} node of the layer l. Hence, the first index j of Wjk[l]W_{jk}^{[l]} is the row number and it tells us where the weight goes to (the jthj^{th} node of the layer l). The second index k is the column number and it tells us where the weight comes from (the kthk^{th} node of the layer (l−1)(l-1)). This is the reason why the matrix W[l]W^{[l]} has nln_{l} rows and nl−1n_{l-1} columns. For example, W21[3]W_{21}^{[3]} is the weight that connects the 1st1^{st} node of the layer 2 to the 2nd2^{nd} node of the layer 3.

All the vectors in this paper are column-vectors. For example, the outputs of the layer (l−1)(l-1) are:

A[l−1]=[A1[l−1]A2[l−1]A3[l−1]⋮Anl−1[l−1]]⏟nl−1×1A^{[l-1]}=\underbrace{\begin{bmatrix}A_{1}^{[l-1]}\\ A_{2}^{[l-1]}\\ A_{3}^{[l-1]}\\ \vdots\\ A_{n_{l}-1}^{[l-1]}\end{bmatrix}}_{n_{l-1}\times1}

Throughout this paper, we will use the network shown in Figure(1) as a running example. It has 3 input values, two hidden layers with 5 and 4 nodes, respectively, and an output layer with 3 nodes, i.e., L=3L=3, n0=3n_0=3, n1=5n_1=5, n2=4n_2=4, and n3=3n_3=3. Each output node jj has its own error EjE_j that we will define in Section(2.5).

Figure

Figure 1: the running example network. The bold path connects the 1st1^{st} node of every layer to the error E1E_1 of the 1st1^{st} output node.