

























Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!


























We now begin our study of deep learning. In this set of notes, we give an overview of neural networks, discuss vectorization and discuss training neural networks with backpropagation.
In the supervised learning setting (predicting y from the input x), suppose our model/hypothesis is hθ(x). In the past lectures, we have considered the cases when hθ(x) = θ>x (in linear regression) or hθ(x) = θ>φ(x) (where φ(x) is the feature map). A commonality of these two models is that they are linear in the parameters θ. Next we will consider learning a general family of models that are non-linear in both the parameters θ and the inputs x. The most common non-linear models are neural networks, which we will define starting from the next section. For this section, it suffices to think hθ(x) as an abstract non-linear model.^1 Suppose {(x(i), y(i))}ni=1 are the training examples. We will define the nonlinear model and the loss/cost function for learning it.
Regression problems. For simplicity, we start with the case where the output is a real number, that is, y(i)^ ∈ R, and thus the model hθ also outputs a real number hθ(x) ∈ R. We define the least square cost function for the
(^1) If a concrete example is helpful, perhaps think about the model hθ (x) = θ (^21) x (^21) + θ (^22) x (^22) + · · · + θ d^2 x^2 d in this subsection, even though it’s not a neural network.
i-th example (x(i), y(i)) as
J(i)(θ) =
(hθ(x(i)) − y(i))^2 , (7.1)
and define the mean-square cost function for the dataset as
J(θ) =
n
∑^ n
i=
J(i)(θ) , (7.2)
which is same as in linear regression except that we introduce a constant 1 /n in front of the cost function to be consistent with the convention. Note that multiplying the cost function with a scalar will not change the local minima or global minima of the cost function. Also note that the underlying parameterization for hθ(x) is different from the case of linear regression, even though the form of the cost function is the same mean-squared loss. Throughout the notes, we use the words “loss” and “cost” interchangeably.
Binary classification. Next we define the model and loss function for binary classification. Suppose the inputs x ∈ Rd. Let ¯hθ : Rd^ → R be a parameterized model (the analog of θ>x in logistic linear regression). We call the output ¯hθ(x) ∈ R the logit. Analogous to Section 2.1, we use the logistic function g(·) to turn the logit ¯hθ(x) to a probability hθ(x) ∈ [0, 1]:
hθ(x) = g(¯hθ(x)) = 1/(1 + exp(−¯hθ(x)). (7.3)
We model the conditional distribution of y given x and θ by
P (y = 1 | x; θ) = hθ(x) P (y = 0 | x; θ) = 1 − hθ(x)
Following the same derivation in Section 2.1 and using the derivation in Remark 2.1.1, the negative likelihood loss function is equal to:
J(i)(θ) = − log p(y(i)^ | x(i); θ) = `logistic(¯hθ(x(i)), y(i)) (7.4)
As done in equation (7.2), the total loss function is also defined as the average of the loss function over individual training examples, J(θ) = (^1) n
∑n i=1 J
(i)(θ).
Algorithm 1 Stochastic Gradient Descent
1: Hyperparameter: learning rate α, number of total iteration niter. 2: Initialize θ randomly. 3: for i = 1 to niter do 4: Sample j uniformly from { 1 ,... , n}, and update θ by
θ := θ − α∇θJ(j)(θ) (7.9)
Oftentimes computing the gradient of B examples simultaneously for the parameter θ can be faster than computing B gradients separately due to hardware parallelization. Therefore, a mini-batch version of SGD is most commonly used in deep learning, as shown in Algorithm 2. There are also other variants of the SGD or mini-batch SGD with slightly different sampling schemes.
Algorithm 2 Mini-batch Stochastic Gradient Descent
1: Hyperparameters: learning rate α, batch size B, # iterations niter. 2: Initialize θ randomly 3: for i = 1 to niter do 4: Sample B examples j 1 ,... , jB (without replacement) uniformly from { 1 ,... , n}, and update θ by
θ := θ −
α B
k=
∇θJ(jk^ )(θ) (7.10)
With these generic algorithms, a typical deep learning model is learned with the following steps. 1. Define a neural network parametrization hθ(x), which we will introduce in Section 7.2, and 2. write the backpropagation algorithm to compute the gradient of the loss function J(j)(θ) efficiently, which will be covered in Section 7.4, and 3. run SGD or mini-batch SGD (or other gradient-based optimizers) with the loss function J(θ).
Neural networks refer to a broad type of non-linear models/parametrizations ¯hθ(x) that involve combinations of matrix multiplications and other entry-
wise non-linear operations. To have a unified treatment for regression prob- lem and classification problem, here we consider ¯hθ(x) as the output of the neural network. For regression problem, the final prediction hθ(x) = ¯hθ(x), and for classification problem, ¯hθ(x) is the logits and the predicted probability will be hθ(x) = 1/(1+exp(−¯hθ(x)) (see equation 7.3) for binary classification or hθ(x) = softmax(¯hθ(x)) for multi-class classification (see equation 7.5). We will start small and slowly build up a neural network, step by step.
A Neural Network with a Single Neuron. Recall the housing price prediction problem from before: given the size of the house, we want to predict the price. We will use it as a running example in this subsection. Previously, we fit a straight line to the graph of size vs. housing price. Now, instead of fitting a straight line, we wish to prevent negative housing prices by setting the absolute minimum price as zero. This produces a “kink” in the graph as shown in Figure 7.1. How do we represent such a function with a single kink as ¯hθ(x) with unknown parameter? (After doing so, we can invoke the machinery in Section 7.1.) We define a parameterized function ¯hθ(x) with input x, parameterized by θ, which outputs the price of the house y. Formally, ¯hθ : x → y. Perhaps one of the simplest parametrization would be
¯hθ(x) = max(wx + b, 0), where θ = (w, b) ∈ R^2 (7.11)
Here ¯hθ(x) returns a single value: (wx+b) or zero, whichever is greater. In the context of neural networks, the function max{t, 0 } is called a ReLU (pro- nounced “ray-lu”), or rectified linear unit, and often denoted by ReLU(t) , max{t, 0 }. Generally, a one-dimensional non-linear function that maps R to R such as ReLU is often referred to as an activation function. The model ¯hθ(x) is said to have a single neuron partly because it has a single non-linear activation function. (We will discuss more about why a non-linear activation is called neuron.) When the input x ∈ Rd^ has multiple dimensions, a neural network with a single neuron can be written as
¯hθ(x) = ReLU(w>x + b), where w ∈ Rd, b ∈ R, and θ = (w, b) (7.12)
(family size, walkable, school quality), we may conclude that the price of the home ultimately depends on these three features.
Family Size
School Quality
Walkable
Size
Zip Code
Wealth
Price y
Figure 7.2: Diagram of a small neural network for predicting housing prices.
Formally, the input to a neural network is a set of input features x 1 , x 2 , x 3 , x 4. We denote the intermediate variables for “family size”, “walk- able”, and “school quality” by a 1 , a 2 , a 3 (these ai’s are often referred to as “hidden units” or “hidden neurons”). We represent each of the ai’s as a neu- ral network with a single neuron with a subset of x 1 ,... , x 4 as inputs. Then as in Figure 7.1, we will have the parameterization:
a 1 = ReLU(θ 1 x 1 + θ 2 x 2 + θ 3 ) a 2 = ReLU(θ 4 x 3 + θ 5 ) a 3 = ReLU(θ 6 x 3 + θ 7 x 4 + θ 8 )
where (θ 1 , · · · , θ 8 ) are parameters. Now we represent the final output ¯hθ(x) as another linear function with a 1 , a 2 , a 3 as inputs, and we get^3
¯hθ(x) = θ 9 a 1 + θ 10 a 2 + θ 11 a 3 + θ 12 (7.13)
where θ contains all the parameters (θ 1 , · · · , θ 12 ). Now we represent the output as a quite complex function of x with pa- rameters θ. Then you can use this parametrization ¯hθ with the machinery of Section 7.1 to learn the parameters θ.
Inspiration from Biological Neural Networks. As the name suggests, artificial neural networks were inspired by biological neural networks. The hidden units a 1 ,... , am correspond to the neurons in a biological neural net- work, and the parameters θi’s correspond to the synapses. However, it’s
(^3) Typically, for multi-layer neural network, at the end, near the output, we don’t apply
ReLU, especially when the output is not necessarily a positive number.
unclear how similar the modern deep artificial neural networks are to the bi- ological ones. For example, perhaps not many neuroscientists think biological neural networks could have 1000 layers, while some modern artificial neural networks do (we will elaborate more on the notion of layers.) Moreover, it’s an open question whether human brains update their neural networks in a way similar to the way that computer scientists learn artificial neural net- works (using backpropagation, which we will introduce in the next section.).
Two-layer Fully-Connected Neural Networks. We constructed the neural network in equation (7.13) using a significant amount of prior knowl- edge/belief about how the “family size”, “walkable”, and “school quality” are determined by the inputs. We implicitly assumed that we know the family size is an important quantity to look at and that it can be determined by only the “size” and “# bedrooms”. Such a prior knowledge might not be available for other applications. It would be more flexible and general to have a generic parameterization. A simple way would be to write the intermediate variable a 1 as a function of all x 1 ,... , x 4 :
a 1 = ReLU(w> 1 x + b 1 ), where w 1 ∈ R^4 and b 1 ∈ R (7.14) a 2 = ReLU(w> 2 x + b 2 ), where w 2 ∈ R^4 and b 2 ∈ R a 3 = ReLU(w> 3 x + b 3 ), where w 3 ∈ R^4 and b 3 ∈ R
We still define ¯hθ(x) using equation (7.13) with a 1 , a 2 , a 3 being defined as above. Thus we have a so-called fully-connected neural network because all the intermediate variables ai’s depend on all the inputs xi’s. For full generality, a two-layer fully-connected neural network with m hidden units and d dimensional input x ∈ Rd^ is defined as
∀j ∈ [1, ..., m], zj = w[1] j
> x + b[1] j where w j[1] ∈ Rd, b[1] j ∈ R (7.15) aj = ReLU(zj ), a = [a 1 ,... , am]>^ ∈ Rm ¯hθ(x) = w[2]>a + b[2]^ where w[2]^ ∈ Rm, b[2]^ ∈ R, (7.16)
Note that by default the vectors in Rd^ are viewed as column vectors, and in particular a is a column vector with components a 1 , a 2 , ..., am. The indices [1] (^) and [2] (^) are used to distinguish two sets of parameters: the w[1] j ’s (each of which is a vector in Rd) and w[2]^ (which is a vector in Rm). We will have more of these later.
We remark again that a vector in Rd^ in this notes, following the conventions previously established, is automatically viewed as a column vector, and can also be viewed as a d × 1 dimensional matrix. (Note that this is different from numpy where a vector is viewed as a row vector in broadcasting.) Computing the activations a ∈ Rm^ from z ∈ Rm^ involves an element- wise non-linear application of the ReLU function, which can be computed in parallel efficiently. Overloading ReLU for element-wise application of ReLU (meaning, for a vector t ∈ Rd, ReLU(t) is a vector such that ReLU(t)i = ReLU(ti)), we have
a = ReLU(z) (7.20)
Define W [2]^ = [w[2] > ] ∈ R^1 ×m^ similarly. Then, the model in equa- tion (7.16) can be summarized as
a = ReLU(W [1]x + b[1]) ¯hθ(x) = W [2]a + b[2]^ (7.21)
Here θ consists of W [1], W [2]^ (often referred to as the weight matrices) and b[1], b[2]^ (referred to as the biases). The collection of W [1], b[1]^ is referred to as the first layer, and W [2], b[2]^ the second layer. The activation a is referred to as the hidden layer. A two-layer neural network is also called one-hidden-layer neural network.
Multi-layer fully-connected neural networks. With this succinct no- tations, we can stack more layers to get a deeper fully-connected neu- ral network. Let r be the number of layers (weight matrices). Let W [1],... , W [r], b[1],... , b[r]^ be the weight matrices and biases of all the layers. Then a multi-layer neural network can be written as
a[1]^ = ReLU(W [1]x + b[1]) a[2]^ = ReLU(W [2]a[1]^ + b[2]) · · · a[r−1]^ = ReLU(W [r−1]a[r−2]^ + b[r−1]) ¯hθ(x) = W [r]a[r−1]^ + b[r]^ (7.22)
We note that the weight matrices and biases need to have compatible dimensions for the equations above to make sense. If a[k]^ has dimension mk, then the weight matrix W [k]^ should be of dimension mk × mk− 1 , and the bias b[k]^ ∈ Rmk^. Moreover, W [1]^ ∈ Rm^1 ×d^ and W [r]^ ∈ R^1 ×mr−^1.
The total number of neurons in the network is m 1 + · · · + mr, and the total number of parameters in this network is (d + 1)m 1 + (m 1 + 1)m 2 + · · · + (mr− 1 + 1)mr. Sometimes for notational consistency we also write a[0]^ = x, and a[r]^ = hθ(x). Then we have simple recursion that
a[k]^ = ReLU(W [k]a[k−1]^ + b[k]), ∀k = 1,... , r − 1 (7.23)
Note that this would have been true for k = r if there were an additional ReLU in equation (7.22), but often people like to make the last layer linear (aka without a ReLU) so that negative outputs are possible and it’s easier to interpret the last layer as a linear model. (More on the interpretability at the “connection to kernel method” paragraph of this section.)
Other activation functions. The activation function ReLU can be re- placed by many other non-linear function σ(·) that maps R to R such as
σ(z) =
1 + e−z^
(sigmoid) (7.24)
σ(z) =
ez^ − e−z ez^ + e−z^
(tanh) (7.25)
σ(z) = max{z, γz}, γ ∈ (0, 1) (leaky ReLU) (7.26)
σ(z) =
z 1 + e−βz^
, β > 0 (Swishβ ) (7.27)
σ(z) =
z 2
1 + erf(
z √ 2
σ(z) = max{z, 0 }^2 (ReLU^2 ) (7.29)
σ(z) =
β
log(1 + exp(βz)), β > 0 (Softplus) (7.30)
The activation functions are plotted in Figure 7.3. Sigmoid and tanh are less and less used these days as standalone hidden-layer activations partly be- cause they are bounded from both sides and their gradients vanish as z goes to both positive and negative infinity (whereas all the other activation func- tions above still have gradients as the input goes to positive infinity.) Sigmoid nevertheless remains important as a gating nonlinearity, for example in some mixture-of-experts routers [Nguyen et al., 2025] and gated attention mech- anisms [Qiu et al., 2025]. Softplus is not used very often in practice either and can be viewed as a smoothing of ReLU so that it has a proper second- order derivative. Swishβ was introduced by Ramachandran et al. [2017]; it
Suppose σ(z) = z, then for two-layer neural network, we have that
¯hθ(x) = W [2]a[1]^ (7.32)
= W [2]σ(z[1]) by definition (7.33) = W [2]z[1]^ since σ(z) = z (7.34) = W [2]W [1]x from Equation (7.18) (7.35) = W x˜ where W˜ = W [2]W [1]^ (7.36)
Notice how W [2]W [1]^ collapsed into W˜. This is because applying a linear function to another linear function will result in a linear function over the original input (i.e., you can construct a W˜ such that W x˜ = W [2]W [1]x). This loses much of the representational power of the neural network as often times the output we are trying to predict has a non-linear relationship with the inputs. Without non-linear activation functions, the neural network will simply perform linear regression.
Connection to the Kernel Method. In the previous lectures, we covered the concept of feature maps. Recall that the main motivation for feature maps is to represent functions that are non-linear in the input x by θ>φ(x), where θ are the parameters and φ(x), the feature map, is a handcrafted function non-linear in the raw input x. The performance of the learning algorithms can significantly depend on the choice of the feature map φ(x). Oftentimes people use domain knowledge to design the feature map φ(x) that suits the particular applications. The process of choosing the feature maps is often referred to as feature engineering. We can view deep learning as a way to automatically learn the right feature map (sometimes also referred to as “the representation”) as follows. Suppose we denote by β the collection of the parameters in a fully-connected neural networks (equation (7.22)) except those in the last layer. Then we can abstract right a[r−1]^ as a function of the input x and the parameters in β: a[r−1]^ = φβ (x). Now we can write the model as
¯hθ(x) = W [r]φβ (x) + b[r]^ (7.37)
When β is fixed, then φβ (·) can be viewed as a feature map, and therefore ¯hθ(x) is just a linear model over the features φβ (x). However, when we train
the neural networks, both the parameters in β and the parameters W [r], b[r] are optimized, and therefore we are not only learning a linear model in the feature space, but also learning a good feature map φβ (·) itself so that it’s
possible to predict accurately with a linear model on top of the feature map. Therefore, deep learning tends to depend less on the domain knowledge of the particular applications and often requires less feature engineering. The penultimate layer a[r]^ is often (informally) referred to as the learned features or representations in the context of deep learning. In the example of house price prediction, a fully-connected neural network does not need us to specify the intermediate quantity such as “family size”, and may automatically discover some useful features in the penultimate layer (the activation a[r−1]), and use them to linearly predict the housing price. Often the feature map / representation obtained from one dataset (that is, the function φβ (·)) can also be useful for other datasets, which indicates that it contains essential information about the data. However, oftentimes, the neural network will discover complex features which are very useful for predicting the output but may be difficult for a human to understand or interpret. This is why some people refer to neural networks as a black box, as it can be difficult to understand the features it has discovered.
The multi-layer neural network introduced in equation (7.22) of Section 7. is often called multi-layer perceptron (MLP) these days. Modern neural net- works used in practice are often much more complex and consist of multiple building blocks or multiple layers of building blocks. In this section, we will introduce some of the other building blocks and discuss possible ways to combine them. First, each matrix multiplication can be viewed as a building block. Con- sider a matrix multiplication operation with parameters (W, b) where W is the weight matrix and b is the bias vector, operating on an input z,
MMW,b(z) = W z + b. (7.38)
Note that we implicitly assume all the dimensions are chosen to be compat- ible. We will also drop the subscripts under MM when they are clear in the context or just for convenience when they are not essential to the discussion. Then, the MLP can be written as a composition of multiple matrix mul- tiplication modules and nonlinear activation modules (which can also be viewed as a building block):
MLP(x) = MMW [r],b[r] (σ(MMW [r−1],b[r−1] (σ(· · · MMW [1],b[1] (x)))). (7.39)
We note that the ResNet-S is still not the same as the ResNet architec- ture introduced in the seminal paper [He et al., 2016] because ResNet uses convolution layers instead of vanilla matrix multiplication, and adds batch normalization between convolutions and activations. We will introduce con- volutional layers and some variants of batch normalization below. ResNet-S and layer normalization are part of the Transformer architecture that are widely used in modern large language models.
Layer normalization. Layer normalization, denoted by LN in this text, is a module that maps a vector z ∈ Rm^ to a more normalized vector LN(z) ∈ Rm. It is oftentimes used after the nonlinear activations. We first define a sub-module of the layer normalization, denoted by LN-S.
LN-S(z) =
z 1 −μˆ z^ ˆσ 2 −μˆ ˆσ .. . zm−μˆ ˆσ
where μˆ =
∑m i=1 zi √ m^ is^ the^ empirical^ mean^ of^ the^ vector^ z^ and^ σˆ^ = 1 m
∑m i=1(zi^ −^ μˆ) (^2) is the empirical standard deviation of the entries of z.^4
Intuitively, LN-S(z) is a vector that is normalized to having empirical mean zero and empirical standard deviation 1. Oftentimes zero mean and standard deviation 1 is not the most desired normalization scheme, and thus layernorm introduces two learnable scalar parameters β and γ as the desired mean and standard deviation, and uses an affine transformation to turn the output of LN-S(z) into a vector with mean β and standard deviation γ.
LN(z) = β + γ · LN-S(z) =
β + γ
(z 1 −μˆ ˆσ
β + γ
(z 2 −μˆ ˆσ
β + γ
(zm−ˆμ ˆσ
Here the first occurrence of β should technically be interpreted as a vector whose entries are all equal to β. We also note that ˆμ and ˆσ are also functions
(^4) Note that we divide by m instead of m − 1 in the empirical standard deviation here because we are interested in making the output of LN-S(z) have empirical variance 1, or equivalently sum of squares equal to m (as opposed to estimating the standard deviation in statistics.)
of z and shouldn’t be treated as constants when computing the derivatives of layernorm. Moreover, β and γ are learnable parameters and thus layernorm is a parameterized module (as opposed to the activation layer which doesn’t have any parameters.)
Scaling-invariant property. One important property of layer normalization is that it will make the model invariant to scaling of the parameters in the following sense. Suppose we consider composing LN with MMW,b and get a subnetwork LN(MMW,b(z)). Then, we have that the output of this sub- network does not change when the parameter in MMW,b is scaled:
LN(MMαW,αb(z)) = LN(MMW,b(z)), ∀α > 0. (7.45)
To see this, we first know that LN-S(·) is scale-invariant
LN-S(αz) =
αz 1 −αμˆ αzαˆσ 2 −αμˆ αˆσ .. . αzm−αˆμ αˆσ
z 1 −μˆ z^ ˆσ 2 −μˆ ˆσ .. . zm−μˆ ˆσ
= LN-S(z). (7.46)
Then we have
LN(MMαW,αb(z)) = β + γLN-S(MMαW,αb(z)) (7.47) = β + γLN-S(αMMW,b(z)) (7.48) = β + γLN-S(MMW,b(z)) (7.49) = LN(MMW,b(z)). (7.50)
Due to this property, most of the modern DL architectures for large-scale computer vision and language applications have the following scale-invariant property w.r.t all the weights that are not at the last layer. Suppose the network f has last layer’ weights Wlast, and all the rest of the weights are denote by W. Then, we have fWlast,αW (x) = fWlast,W (x) for all α > 0. Here, the last layers weights are special because there are typically no layernorm or batchnorm after the last layer’s weights.
Other normalization layers. There are several other normalization layers that aim to normalize the intermediate layers of the neural networks to a more fixed and controllable scaling, such as batch-normalization [Ioffe and Szegedy, 2015], and group normalization [Wu and He, 2018]. Batch nor- malization and group normalization are more often used in computer vision applications whereas layer norm is used more often in language applications.
parameters: Conv1D-S(z) = Qz, where
Q =
w+1 · · · w 2+1 0 0 · · · · · · · · · · · · · · · · · · 0 w· · · w 2 w 2 +1 0 · · · · · · · · · · · · · · · · · · 0 .. . w 1 · · · w+1 · · · · · · · · · w 2 +1 0 · · · · · · · · · 0 0 w 1 · · · · · · · · · · · · w 2 w 2 +1 0 · · · · · · 0 .. . .. . 0 · · · · · · · · · · · · · · · 0 w 1 · · · · · · w 2+ .. . 0 · · · · · · · · · · · · · · · · · · · · · 0 w 1 · · · w`+
. (7.53)
Note that Qi,j = Qi− 1 ,j− 1 for all i, j ∈ { 2 ,... , m}, and thus convoluation is a matrix multiplication with parameter sharing. We also note that computing the convolution only takes O(km) times but computing a generic matrix multiplication takes O(m^2 ) time. Convolution has k parameters but generic matrix multiplication will have m^2 parameters. Thus convolution is supposed to be much more efficient than a generic matrix multiplication (as long as the additional structure imposed does not hurt the flexibility of the model to fit the data). We also note that in practice there are many variants of the convolutional layers that we define here, e.g., there are other ways to pad zeros or sometimes the dimension of the output of the convolutional layers could be different from the input. We omit some of this subtleties here for simplicity. The convolutional layers used in practice have also many “channels” and the simplified version above corresponds to the 1-channel version. Formally, Conv1D takes in C vectors z 1 ,... , zC ∈ Rm^ as inputs, where C is referred to as the number of channels. In other words, the more general version, denoted by Conv1D, takes in a matrix as input, which is the concatenation of z 1 ,... , zC and has dimension m×C. It can output C′^ vectors of dimension m, denoted by Conv1D(z) 1 ,... , Conv1D(z)C′ , where C′^ is referred to as the output channel, or equivalently a matrix of dimension m × C′. Each of the output is a sum of the simplified convolutions applied on various channels.
∀i ∈ [C′], Conv1D(z)i =
j=
Conv1D-Si,j (zj ). (7.54)
Note that each Conv1D-Si,j are modules with different parameters, and thus the total number of parameters is k (the number of parameters in a Conv1D-S) ×CC′^ (the number of Conv1D-Si.j ’s) = kCC′. In contrast, a generic linear mapping from Rm×C^ and Rm×C ′ has m^2 CC′^ parameters. The
parameters can also be represented as a three-dimensional tensor of dimen- sion k × C × C′.
2-D convolution (brief ). A 2-D convolution with one channel, denoted by Conv2D-S, is analogous to the Conv1D-S, but takes a 2-dimensional input z ∈ Rm×m^ and applies a filter of size k × k, and outputs Conv2D-S(z) ∈ Rm×m. The full 2-D convolutional layer, denoted by Conv2D, takes in a sequence of matrices z 1 ,... , zC ∈ Rm×m, or equivalently a 3-D ten- sor z = (z 1 ,... , zC ) ∈ Rm×m×C^ and outputs a sequence of matrices, Conv2D(z) 1 ,... , Conv2D(z)C′^ ∈ Rm×m, which can also be viewed as a 3D tensor in Rm×m×C ′
. Each channel of the output is sum of the outcomes of applying Conv2D-S layers on all the input channels.
∀i ∈ [C′], Conv2D(z)i =
j=
Conv2D-Si,j (zj ). (7.55)
Because there are CC′^ number of Conv2D-S modules and each of the Conv2D-S module has k^2 parameters, the total number of parameters is CC′k^2. The parameters can also be viewed as a 4D tensor of dimension C × C′^ × k × k. Further reading. See Mazet [2026] for discussions of basic properties, theoret- ical properties such as the convolution theorem, and the connection between correlation and convolution in image processing.
In this section, we introduce backpropagation or auto-differentiation, which computes the gradient of the loss ∇J(θ) efficiently. We will start with an informal theorem that states that as long as a real-valued function f can be efficiently computed/evaluated by a differentiable network or circuit, then its gradient can be efficiently computed in a similar time. We will then show how to do this concretely for neural networks. Because the formality of the general theorem is not the main focus here, we will introduce the terms with informal definitions. By a differentiable circuit or a differentiable network, we mean a composition of a sequence of differentiable arithmetic operations (additions, subtraction, multiplication, divisions, etc) and elementary differentiable functions (ReLU, exp, log, sin, cos, etc.). Let the size of the circuit be the total number of such operations and elementary functions. We assume that each of the operations and func-