# Local Kernel Renormalization as a mechanism for feature learning in
overparametrized Convolutional Neural Networks

R. Aiudi  Dipartimento di Scienze Matematiche, Fisiche e Informatiche,
Università degli Studi di Parma, Parco Area delle Scienze, 7/A 43124 Parma,
Italy  INFN, Gruppo Collegato di Parma, Parco Area delle Scienze 7/A, 43124
Parma, Italy  R. Pacelli  Dipartimento di Scienza Applicata e Tecnologia,
Politecnico di Torino, 10129 Torino, Italy  Artificial Intelligence Lab,
Bocconi University, 20136 Milano, Italy  A. Vezzani  Istituto dei Materiali
per l’Elettronica ed il Magnetismo (IMEM-CNR), Parco Area delle Scienze,
37/A-43124 Parma, Italy  Dipartimento di Scienze Matematiche, Fisiche e
Informatiche, Università degli Studi di Parma, Parco Area delle Scienze, 7/A
43124 Parma, Italy  INFN, Gruppo Collegato di Parma, Parco Area delle Scienze
7/A, 43124 Parma, Italy  R. Burioni  Dipartimento di Scienze Matematiche,
Fisiche e Informatiche, Università degli Studi di Parma, Parco Area delle
Scienze, 7/A 43124 Parma, Italy  INFN, Gruppo Collegato di Parma, Parco Area
delle Scienze 7/A, 43124 Parma, Italy  P. Rotondo  Dipartimento di Scienze
Matematiche, Fisiche e Informatiche, Università degli Studi di Parma, Parco
Area delle Scienze, 7/A 43124 Parma, Italy  INFN, Gruppo Collegato di Parma,
Parco Area delle Scienze 7/A, 43124 Parma, Italy

###### Abstract

Feature learning, or the ability of deep neural networks to automatically
learn relevant features from raw data, underlies their exceptional capability
to solve complex tasks. However, feature learning seems to be realized in
different ways in fully-connected (FC) or convolutional architectures (CNNs).
Empirical evidence shows that FC neural networks in the infinite-width limit
eventually outperform their finite-width counterparts. Since the kernel that
describes infinite-width networks does not evolve during training, whatever
form of feature learning occurs in deep FC architectures is not very helpful
in improving generalization. On the other hand, state-of-the-art architectures
with convolutional layers achieve optimal performances in the finite-width
regime, suggesting that an effective form of feature learning emerges in this
case. In this work, we present a simple theoretical framework that provides a
rationale for these differences, in one hidden layer networks. First, we show
that the generalization performance of a finite-width FC network can be
obtained by an infinite-width network, with a suitable choice of the Gaussian
priors (technically, this result holds in the asymptotic limit where the size
of the training set $P$ and the size of the hidden layer $N_{1}$ are taken to
infinity keeping their ratio $\alpha_{1}=P/N_{1}$ fixed). Second, we derive a
finite-width effective action for an architecture with one convolutional
hidden layer and compare it with the result available for FC networks.
Remarkably, we identify a completely different form of kernel renormalization:
whereas the kernel of the FC architecture is just globally renormalized by a
single scalar parameter, the CNN kernel undergoes a local renormalization,
meaning that the network can select the local components that will contribute
to the final prediction in a data-dependent way. This finding highlights a
simple mechanism for feature learning that can take place in overparametrized
shallow CNNs, but not in shallow FC architectures or in locally connected
neural networks without weight sharing.

##  I Introduction

Deep learning achieves state-of-the-art performances on a variety of pattern
recognition tasks, ranging from computer vision to natural language processing
[1]. A minimal theory of deep learning should be able (at least) to predict
practically relevant scores, such as the training and test accuracy, from
knowledge of the training data. Another even more fundamental aspect that such
a theory should quantitatively address is the so-called _feature learning
regime_ [2, 3], i.e. the capability of deep networks to automatically detect
useful representations from raw data.

Concerning the first aspect, fundamental theoretical progress has been
achieved in the so-called _infinite-width limit_ [4, 5, 6, 7, 8, 9, 10, 11,
12], which is informally defined as the regime where the size of each hidden
layer $N_{\ell}$ ($\ell=1,\dots,L$, $L$ being the (finite) depth of the
network) is much larger than the size of the training set $P$. Here, one shows
that the stochastic process that describes information flow in the deep neural
network is a familiar Gaussian process, which is completely determined by a
non-linear kernel.

A fundamental consequence of this finding is that learning in the infinite-
width limit is equivalent to kernel learning [13, 14, 15, 16] with a static
kernel, completely fixed by the statistics of the weights at initialization,
that does not evolve during training. This last observation suggests that
feature learning is essentially absent in infinite-width networks [17].
Notably, whereas original work on the infinite-width limit considered deep
architectures with FC hidden layers only, the generalization to architectures
with convolutional layers is straightforward [9], if one replaces neurons in
the FC hidden layers with the channels/convolutional filters of the CNN.

Figure 1: Global and local kernels in FC and convolutional one hidden layer
networks. Our calculations in the proportional limit $P,N_{1}\to\infty$ at
fixed $\alpha_{1}=P/N_{1}$ reveal a striking difference between FCNs and CNNs.
In the first case, the NNGP kernel $K_{\mu\nu}$ that enters into the Bayesian
effective action is a global one, which is only capable of tracking global
correlations between different training patterns $(\mu,\nu)$ (left). A FCN
network in this regime will use the information contained in the dataset to
fine-tune a single parameter, $\bar{Q}$, that will globally rescale the kernel
matrix $K_{\mu\nu}$. On the other hand, in the CNN case, we identify a local
kernel with two additional (spatial) indices. If we consider $2d$ images, the
effect of the local components is to track local correlations between
different patches $i$ and $j$ of (possibly) different pairs of images
$(\mu,\nu)$ (right). The spatial information contained in these correlations
allows the CNN to optimize a matrix of parameters $\bar{Q}_{ij}$, which will
renormalize the kernel matrix $K^{ij}_{\mu\nu}$ in a non-trivial way. In the
figure, we display the four-index local kernel $K_{\mu\nu}^{ij}$ as a matrix
using the multi-index notation $K_{(\mu,i),(\nu,j)}$ and choosing an ordering
for the multi-index $(\mu,i)$. Global and local kernels are computed for a
subset of $P=10$ gray-scaled CIFAR10 images down-sized to $N_{0}=784$. The
local kernels are empirically evaluated for $2d$ convolutions with linear size
of the filter mask $M=14$ and stride $S=14$ (non-overlapping filters).

Recently, the authors of Ref. [18] conducted a large-scale empirical study
comparing finite-width FC networks, CNNs with finite number of channels and
their infinite-width limit kernel counterparts, where they explore a plenitude
of possible settings to improve generalization. This analysis prompts a few
striking empirical observations: (i) infinite-width kernels systematically
outperform their finite-width counterpart in the case of FC deep neural
networks; (ii) CNNs with finite number of channels often outperform their
corresponding infinite-width kernel performance.

Several similar observations have been reported in the literature: the authors
of Ref. [19] very recently pointed out that infinite-width deep FC neural
networks eventually outperform their finite-width counterpart as the size of
the training set grows. In one of the seminal papers dealing with the
infinite-width limit [7], the authors observe that increasing the hidden
layers size leads to optimal test accuracy on deep FC architectures trained on
MNIST and on CIFAR10, two of the benchmark datasets for computer vision
learning problems. In Ref. [9] this observation is extended to _locally
connected networks_ without weight sharing (LCNs). The interplay between the
lazy training regime and the mean field limit [20] has been the subject of a
thorough investigation in [21, 22].

These observations suggest that CNNs leverage a better feature-learning
mechanism at finite width than FCNs and LCNs, and prompt at least two
conceptual questions: (i) why is it ultimately convenient to employ large-
width architectures when only FC layers are available? (ii) Why is this not
the case when convolutional layers are employed? And how does a CNN
operatively exploit the finite-width regime for efficient feature learning?
Preliminary theoretical work in the direction of understanding the feature
learning regime of deep nets was carried out in Refs. [23, 24, 25, 26, 27, 28,
29, 30, 31, 32, 33, 34]. The authors of Refs. [35, 36] analytically
investigated the advantages of employing convolutional neural tangent kernels
in the infinite-width limit and understood why infinite-width FCNs perform
worse in the mean field regime than in the lazy-training one [37].

In this work, we try to rationalize the aforementioned empirical observations
through the lens of _kernel renormalization_. This represents a physical
consequence of a recently-derived effective action for Bayesian learning in
finite-width deep neural networks [38] (formally speaking, the finite-width
regime is defined as the thermodynamic limit where the size of the FC hidden
layers and of the training set are taken to infinity, $N_{\ell},P\to\infty$
and their ratio $\alpha_{\ell}=P/N_{\ell}$ is kept finite). First, we show
that the theoretical framework of Ref. [38] provides a simple, yet very
instructive answer to question (i) for one hidden layer networks, by showing
that the performance of a finite-width shallow network can be obtained with
the corresponding infinite-width kernel and a suitable choice of the Gaussian
priors over the weights of each layer. Second, we derive an effective action
for a simple architecture with one convolutional hidden layer, and we compare
the result with the one available for FCNs. We find a striking difference in
the way the kernel of the two architectures renormalize at finite width:
whereas the FC kernel is just globally renormalized by a scalar parameter, the
CNN kernel undergoes a local renormalization, meaning that many more free
parameters are allowed to be fine-tuned during training (see also Fig. 1). We
employ this finding to provide preliminary insight to question (ii): we
highlight a simple mechanism for feature learning that can take place in
finite-width shallow CNNs, but neither in shallow FC architectures nor in LCNs
without weight sharing.

## Results

##  II Finite-width one hidden layer FC NNs cannot outperform infinite-width
kernels in the overparametrized regime

We consider a supervised regression problem with training set
$\mathcal{T}_{P}=\\{x^{\mu},y^{\mu}\\}_{\mu=1}^{P}$, where each
$x^{\mu}\in\mathbb{R}^{N_{0}}$ and the corresponding labels
$y^{\mu}\in\mathbb{R}$. We also restrict our analysis to quadratic loss
function $\mathcal{L}$. For a generic one hidden layer network that implements
the function $f_{\mathrm{1HL}}(x)$, we define the loss function as:

$\mathcal{L}=\frac{1}{2}\sum_{\mu}\left[y^{\mu}-f_{\mathrm{1HL}}(x^{\mu})\right]^{2}+\frac{T\,\lambda_{0}}{2}\|W\|^{2}+\frac{T\,\lambda_{1}}{2}\|v\|^{2}$
(1)

where $W$ and $v$ are respectively the first and last layer weights, and $T$
is the temperature. The parameters $\lambda_{0},\lambda_{1}$ can be
equivalently thought as Gaussian priors over the weights of each layer, or as
$L^{2}$ regularization terms rescaled by the temperature $T$. A neural network
with one FC hidden layer is formally defined starting from the pre-activations
at the first layer:

$h_{i_{1}}(x)=\frac{1}{\sqrt{N_{0}}}\sum_{i_{0}=1}^{N_{0}}W_{i_{1}i_{0}}x_{i_{0}}+b_{i_{1}}\,,$
(2)

where $b$ are the first-layer biases. Since we are interested in regression
problems, we add one last readout layer, and we define the function
implemented by the one hidden layer FCN as:

$f_{\textrm{FCN}}(x)=\frac{1}{\sqrt{N_{1}}}\sum_{i_{1}=1}^{N_{1}}v_{i_{1}}\sigma\\!\left[h_{i_{1}}(x)\right]\,,$
(3)

where $\sigma$ is a non-linear activation function. An effective action arises
in this setting when one considers the canonical partition function at
temperature $T=1/\beta$ associated to the train loss function $\mathcal{L}$
and the thermodynamic limit $N_{1},P\to\infty$ at fixed ratios
$\alpha_{1}=P/N_{1}$. The calculation amounts to reduce the integral over the
weights of the network to a form suitable to saddle-point integration over two
order parameters $\\{Q,\bar{Q}\\}$, $Z=\int
dQd\bar{Q}e^{-N_{1}/2S_{\textrm{FCN}}(\\{Q,\bar{Q}\\})}$. In the case of odd-
activation function, the action is given by [38]:

$\displaystyle S_{\textrm{FCN}}$ $\displaystyle=-Q\bar{Q}+\log(1+Q)$
$\displaystyle+\frac{\alpha_{1}}{P}\text{Tr}\log\beta\left(\frac{\mathbb{1}}{\beta}+K^{(\mathrm{R})}(\bar{Q})\right)$
$\displaystyle+\frac{\alpha_{1}}{P}y^{T}\left(\frac{\mathbb{1}}{\beta}+K^{(\mathrm{R})}(\bar{Q})\right)^{-1}y\,,$
(4)

where $y$ is the vector of labels $y=(y^{1},\dots,y^{P})$. The renormalized
kernel $K^{(\mathrm{R})}(\bar{Q})$ is a $P\times P$ matrix that processes
pairs of input training data $(x^{\mu},x^{\nu})$ and it is given by:

$\displaystyle
K^{(\mathrm{R})}(\bar{Q})=\frac{\bar{Q}}{\lambda_{1}}K(C)\,,\,\,\,\quad
C_{\mu\nu}=\frac{1}{\lambda_{0}}\frac{x^{\mu}\cdot x^{\nu}}{N_{0}}\,.$ (5)

The non-linear operator $K$ takes as input any (symmetric) $P\times P$ matrix
$M$ and computes a new matrix in the following way:

$\displaystyle K_{\mu\nu}(M)$ $\displaystyle=\int
d^{2}t\,\mathcal{N}_{t}\left(0,\tilde{M}_{\mu\nu}\right)\sigma(t_{1})\sigma(t_{2})\,,$
(6) $\displaystyle\tilde{M}_{\mu\nu}$
$\displaystyle=\begin{pmatrix}M_{\mu\mu}&M_{\mu\nu}\\\
M_{\mu\nu}&M_{\nu\nu}\end{pmatrix}\,.$ (7)

Here and in the following we are denoting normalized Gaussians as
$\mathcal{N}_{x}\left(0,\Sigma\right)\equiv\textrm{exp}\left(-x^{\top}\Sigma^{-1}x/2\right)/\sqrt{\mathrm{det}2\pi\Sigma}$.

It is worth noticing that the minimization of the effective action in Eq. (4)
is straightforward if $\alpha_{1}\to 0$, since one easily finds that
$Q^{*}=0$, $\bar{Q}=1$ and recovers the well-known infinite-width limit Neural
Network Gaussian Process (NNGP) kernel. At finite $\alpha_{1}$, one finds
data-dependent solutions for the order parameters that produce a
renormalization of the infinite-width kernel, as expressed by Eq. (5).

The effective action at finite width presented in Eq. (4) has been firstly
derived for deep linear networks in Ref. [39]. The non-asymptotic evaluation
of the partition function in the linear case is given in Ref. [40] in terms of
Meyer-G functions. An effective action for globally gated deep linear networks
has also been derived [41]. In Ref. [38] we obtained the effective action for
one FC hidden layer networks with generic activation function leveraging on a
Gaussian equivalence [42, 43, 44, 45] informally justified via a generalized
central limit theorem due to Breuer and Major [46]. A result for $L$ layers
can be somewhat bootstrapped from the observation that the stochastic process
that describes information flow in shallow non-linear and deep linear networks
in the proportional limit is related to a Student’s $t$-process [47] (see also
[38] for a more detailed discussion). Recent work considers the proportional
setting in a teacher-student scenario, averaging over the data distribution
using the replica method [48, 49] and a first preliminary rigorous result in
an almost-proportional limit [50] appeared very recently, leveraging the
interpolation method [51, 52].

We now highlight a straightforward consequence of the theoretical framework
presented above. First, we notice that the renormalized kernel
$K^{(\mathrm{R})}$ enters into the predictor’s statistics for a new unseen
test element exactly in the same way the NNGP kernel does in the infinite-
width limit, and thus it completely determines the generalization performance
at finite width, once the saddle-point equations for the parameter $\bar{Q}$
are solved [38]. Second, we observe that the scalar parameter $\bar{Q}$ always
appears in combination with the corresponding Gaussian prior $\lambda_{1}$ as
$\bar{Q}/\lambda_{1}$, meaning that, once evaluated on the saddle-point,
$\bar{Q}$ is just a data-dependent scalar renormalization of the Gaussian
prior. This implies that, once the size of the training set and the activation
function $\sigma$ are fixed, it is always possible to re-obtain the
performance of any finite-width network just by carefully fine-tuning the
Gaussian prior $\lambda_{1}$ in the corresponding infinite-width kernel.
Therefore, the generalization performance of any finite-width one hidden layer
FC network is bounded by the one of a suitable infinite-width kernel with
optimal choice of the Gaussian prior.

The empirical observation that infinite-width one hidden layer FCNs seem to
systematically outperform their finite-width counterpart –which now finds a
possible explanation in this framework– points to the somewhat disappointing
consequence that feature learning is not particularly effective in networks
with FC layers alone at finite width.

We stress here that the aforementioned observation is not ruling out at all
other possible forms of feature learning in FC architectures: (i)
Renormalization of the infinite-width kernel is not the only source of feature
learning possible. Higher order kernels, irrelevant in the infinite-width
limit, may play a role in feature learning, especially as long as one
considers the case where the size of the dataset $P$ roughly scales as the
number of parameters $\sim L\times N^{2}$ ($N_{\ell}=N$ $\forall\ell$) of the
FC deep neural network. The recent work [53] is a notable example of how a FC
network can learn a convolutional structure in special settings; (ii) Our
result holds for Bayesian learning, i.e. when the weights of the networks are
sampled from the canonical Gibbs ensemble. This is only obtained if training
is governed by a Markov chain Monte Carlo. Practical learning algorithms with
state-of-the-art optimizers may behave differently and possibly activate
alternative forms of feature learning; (iii) we are limiting our analysis to
the standard parametrization setting where the last layer is normalized as
$1/\sqrt{N_{1}}$, and we cannot describe the mechanism for feature learning
that may occur in the mean field regime [20] where the last layer is
normalized as $1/N_{1}$ (we note that the framework of [23] seems more
suitable to deal with this case). Nonetheless, it must be also said that the
empirical evidence provided in Refs. [19, 7, 9, 18, 22] is quite against the
fact that these forms of feature learning can play a significant role in
improving the generalization performance of FC networks.

We now move to the second question raised in the Introduction of this
manuscript. How –contrarily to what occurs in deep nets with FC layers only–
do deep architectures with convolutional layers exploit the finite-width
regime for efficient feature learning? In view of the previous discussion, one
possibility is that CNNs at finite width could be able, in some way, to break
the global (trivial) renormalization of the infinite-width kernel that occurs
in FC deep networks. In order to test this hypothesis, in the next section we
investigate a simple model of CNN with one convolutional hidden layer.

##  III Finite-width effective action for a shallow convolutional network

The two fundamental ingredients of a convolutional layer are _local
connectivity_ and _weight sharing_ : whereas a given neuron in a FC hidden
layer receives input from all the neurons in the previous layer, neurons in a
CNN are arranged in a $d$-dimensional array that reflects the corresponding
$d$-dimensional arrangement of the input data (e.g. $d=2$ for images). Each
neuron in a given layer here interacts only with a local neighborhood of
neurons in the previous layer, in a translational invariant way implemented
via a shared (usually small) $d$-dimensional mask of learnable weights. These
operations define a single convolutional channel that takes as input a
$d$-dimensional array and outputs another $d$-dimensional array, whose
dimensions are determined by technical details (such as the stride, padding
and dimension of the filter mask). Usually, many of these channels are piled
up in a convolutional layer to form, overall, a $(d+1)$-dimensional array.

Let us now define a simple architecture with one hidden convolutional layer.
For simplicity, we will restrict our analysis to one-dimensional convolutions,
but the model can be easily generalized to $d$-dimensional convolutions. Pre-
activations in the hidden layer are given by:

$h_{i}^{a}(x)=\frac{1}{\sqrt{M}}\sum_{m=-\lfloor M/2\rfloor}^{\lfloor
M/2\rfloor}W_{m}^{a}x_{Si+m}\,.$ (8)

Here $M$ is the dimension of the channel mask, $S$ is the stride, the index
$i=1,\dots,\lfloor N_{0}/S\rfloor$ runs over the input coordinates, the index
$a=1,\dots,N_{c}$ runs over the channels and the index $m$ moves through the
spatial mask of the convolutional filter. For simplicity, we define periodic
boundary conditions (PBCs) over the input coordinates, and we consider odd
values of $M$. As for the one hidden layer FC network, we add one readout
layer. In conclusion, the function implemented by the CNN is given by:

$f_{\textrm{CNN}}(x)=\frac{1}{\sqrt{N_{c}\lfloor
N_{0}/S\rfloor}}\sum_{i=1}^{\lfloor
N_{0}/S\rfloor}\sum_{a=1}^{N_{c}}v_{i}^{a}\sigma\left[h_{i}^{a}(x)\right]\,,$
(9)

where $\sigma$ is a odd activation function and the $v$’s are the learnable
weights of the readout layer. Our goal is to derive an effective action in the
same setting of Refs. [38], in the thermodynamic limit where
$(N_{c},P)\to\infty$ and their ratio $\alpha_{c}=P/N_{c}$ is finite.

The partition function for the learning problem with the aforementioned simple
CNN can be approximated as an integral over an ensemble of $\lfloor
N_{0}/S\rfloor\times\lfloor N_{0}/S\rfloor$ matrices $Q$ and $\bar{Q}$:
$Z_{\textrm{CNN}}=\int\mathcal{D}Q\mathcal{D}\bar{Q}e^{-N_{c}/2S_{\textrm{CNN}}(Q,\bar{Q})}$
(see Appendices for more details on the derivation), where the effective
action is given by:

$\displaystyle S_{\textrm{CNN}}({Q},{\bar{Q}})\equiv$
$\displaystyle-\textrm{Tr}\,Q\bar{Q}+\textrm{Tr}\log(\mathbb{1}+{Q})+$
$\displaystyle+\frac{\alpha_{c}}{P}\textrm{Tr}\log\beta\Big{(}\frac{\mathbb{1}}{\beta}+{K}_{\textrm{CNN}}^{(\mathrm{R})}\Big{)}+$
$\displaystyle+\frac{\alpha_{c}}{P}{y}^{\top}\Big{(}\frac{\mathbb{1}}{\beta}+{K}_{\textrm{CNN}}^{(\mathrm{R})}\Big{)}^{-1}{y}\,.$
(10)

The trace in the first two terms is over $\lfloor N_{0}/S\rfloor\times\lfloor
N_{0}/S\rfloor$ operators, whereas the renormalized kernel
$K_{\textrm{CNN}}^{(\mathrm{R})}$ is a $P\times P$ matrix and therefore the
trace in the third term and the scalar products with the output labels lie in
a $P$-dimensional vectorial space. The matrix elements of the renormalized
kernel are given by:

$\left[{K}_{\textrm{CNN}}^{(\mathrm{R})}({\bar{Q}})\right]_{\mu\nu}=\frac{1}{\lambda_{1}\lfloor
N_{0}/S\rfloor}\sum_{ij=1}^{\lfloor
N_{0}/S\rfloor}\bar{Q}_{ij}K_{\mu\nu}^{ij}\,,$ (11)

where the kernel $K_{\mu\nu}^{ij}$ is given in terms of the elements of the
following local covariance matrix

$C_{\mu\nu}^{ij}=\frac{1}{\lambda_{0}M}\sum_{m=-\lfloor M/2\rfloor}^{\lfloor
M/2\rfloor}x^{\mu}_{Si+m}x^{\nu}_{Sj+m},$ (12)

with $\lambda_{0}$ being the hidden layer Gaussian prior, via the same
functional relations of the FC case:

$\displaystyle K_{\mu\nu}^{ij}$ $\displaystyle=\int
d^{2}t\,\mathcal{N}_{t}\left(0,\tilde{C}_{\mu\nu}^{ij}\right)\sigma(t_{1})\sigma(t_{2})\,,$
$\displaystyle\tilde{C}_{\mu\nu}^{ij}$
$\displaystyle=\begin{pmatrix}C_{\mu\mu}^{ii}&C_{\mu\nu}^{ij}\\\
C_{\mu\nu}^{ij}&C_{\nu\nu}^{jj}\,.\end{pmatrix}\,.$ (13)

It is worth noticing that such a local kernel has been already found in the
seminal work on the Gaussian process limit of infinite-width CNNs [9].
However, one finds that in the limit of infinitely many channels $N_{c}\gg P$,
the CNN evolves according to the following averaged kernel:

$\bar{K}_{\mu\nu}=\frac{1}{\lambda_{1}\lfloor
N_{0}/S\rfloor}\sum_{i=1}^{\lfloor N_{0}/S\rfloor}K_{\mu\nu}^{ii}\,.$ (14)

In our effective action framework we recover this result by solving the
saddle-point equations for the matrix $\bar{Q}$ in the limit of $\alpha_{c}\to
0$, where one finds $\bar{Q}_{ij}=\delta_{ij}$ and only the diagonal
components of the local kernel contribute to the prediction.

Note that the derivation of this result is based on a Gaussian equivalence
that is informally justified using a general class of central limit theorems
(such as the Breuer-Major theorem in [38]). This suggests that the dimension
of the input $N_{0}$ should scale to infinity at the same rate as the size of
the dataset $P$. If this is the case, as it was in [38], the stride $S$ should
be chosen to scale extensively in $N_{0}$, so that the final effective action
will depend on a finite number of order parameters.

##  IV A simple mechanism for feature learning in finite-width CNNs: Local
Kernel renormalization

Architecture | Kernel type | IW Kernel | Renormalized Kernel
---|---|---|---
FC | $K_{\mu\nu}$ | $K_{\mu\nu}$ | $\bar{Q}K_{\mu\nu}$
LCN | $K_{\mu\nu}^{ii}$ | $\sum_{i}K^{ii}_{\mu\nu}$ | $\sum_{i}\bar{Q}_{i}K^{ii}_{\mu\nu}$
CNN | $K_{\mu\nu}^{ij}$ | $\sum_{i}K^{ii}_{\mu\nu}$ | $\sum_{ij}\bar{Q}_{ij}K^{ij}_{\mu\nu}$
Table 1: Summary of the analytical results for one hidden layer networks. We
identify three different types of kernels in the Bayesian effective action for
FC, LC and convolutional networks: a global kernel in the FC case, a local
diagonal kernel in LCNs and a local (with additional non-diagonal components)
in CNNs. The infinite-width kernel that describes LCNs and CNNs is the same,
as shown in [9]. In the proportional limit, the renormalization of the FC
kernel is scalar, i.e. the NNGP kernel is only globally rescaled by a data-
dependent number $\bar{Q}$. In LCNs, we can adjust a vector of components
$\bar{Q}_{i}$, which determines how much the self-correlations of the $i$-th
patch of the diagonal local kernel do contribute to the final prediction. In
CNNs, due to locality and weight-sharing, we can fine-tune a full matrix
$\bar{Q}_{ij}$, which controls how much the local correlations of patches $i$
and $j$ will enter the effective kernel learned by the network after training.
This is what we call _local kernel renormalization_.

Let us now analyze the saddle-point equations deriving from Eq. (10). We can
gain analytical insight in the zero temperature limit, where we find the
following matrix equations that determine $Q$ and $\bar{Q}$:

$\displaystyle\bar{Q}_{ij}=(\mathbb{1}+{Q})^{-1}_{ij}$ (15) $\displaystyle
Q_{ij}=\frac{\alpha_{c}}{P}\textrm{Tr}\Big{(}K^{ij}\left[K_{\textrm{CNN}}^{(\mathrm{R})}(\bar{Q})\right]^{-1}\Big{)}+$
$\displaystyle-\frac{\alpha_{c}}{P}{y}^{T}\Big{(}\left[K_{\textrm{CNN}}^{(\mathrm{R})}(\bar{Q})\right]^{-1}K^{ij}\left[K_{\textrm{CNN}}^{(\mathrm{R})}(\bar{Q})\right]^{-1}\Big{)}{y}\,$
(16)

where the shortcut $K^{ij}$ has been introduced to indicate the partial trace
over indices $(\mu,\nu)$ in the local kernel defined in Eq. (11). More
explicitly, given a matrix $O$ with elements $O_{\mu\nu}$, the partial trace
is defined as
$\textrm{Tr}(K^{ij}O):=\sum_{\mu\nu=1}^{P}K^{ij}_{\mu\nu}O_{\mu\nu}$. The
exact solution of these matrix equations cannot be obtained in closed form.
However, it is possible to compute it perturbatively around the infinite-width
limit $\alpha_{c}\to 0$. Parametrizing the solution of the first equation as
$\bar{Q}_{ij}=\delta_{ij}+\alpha_{c}\delta\bar{Q}_{ij}+o(\alpha_{c})$, we find
the simple result:

$\delta\bar{Q}_{ij}=\frac{1}{P}\tilde{y}^{T}K^{ij}\tilde{y}-\frac{1}{P}\textrm{Tr}\left(K^{ij}\bar{K}^{-1}\right)\,,$
(17)

where $\tilde{y}^{\mu}=\sum_{\mu=1}^{P}\bar{K}^{-1}_{\mu\nu}y^{\mu}$ and
$\bar{K}$ is the infinite-width CNN averaged kernel defined in Eq. (14). We
now provide a physical interpretation of this finding.

Our claim is that the matrix $\bar{Q}$ provides a compact description of
feature learning in the CNN model under consideration: the feature matrix
elements $\bar{Q}_{ij}$ that are optimized during training are in fact in one-
to-one correspondence with the combinations of pairs of the $\lfloor
N_{0}/S\rfloor$ patches of the local covariance matrix, which is defined from
the trainset elements $x^{\mu}$. From the first term of the r.h.s. of Eq. (17)
we can notice that whenever the local kernel of the CNN at the spatial
locations $(i,j)$ will have a significant overlap with the effective label
vector $\tilde{y}$, the element $\bar{Q}_{ij}$ of the feature matrix $\bar{Q}$
will differ from one. In other words, this is a measure of the relative
importance of the pairwise spatial correlations in the input dataset wrt the
labels. From Eq. (11), we can now interpret the matrix $\bar{Q}$ as a feature,
data-dependent matrix that tells us how much a given component of the local
kernel contribute to the renormalized kernel
$K_{\textrm{CNN}}^{(\mathrm{R})}$.

The local kernel renormalization that takes place in this CNN model in the
proportional limit is completely different from the trivial global one that
occurs in the corresponding FC one hidden layer network. At this point one can
wonder whether both the ingredients in CNNs design, local connectivity and
weight sharing, are needed to observe the phenomenon of local kernel
renormalization. The answer is affirmative: local kernel renormalization does
not occur in a shallow network with local connectivity only, as we explicitly
check in the appendix. In that case, only the diagonal components of the local
kernel enter the effective action, and the network is not sensible to spatial
correlations between different patches (see also Table 1 for a summary of the
analytical results).

##  V Empirical evidence for global and local kernel renormalization

Figure 2: Predicting the effect of global and local kernel renormalization on
the internal representations of FCNs and CNNs. A finite-size scaling analysis.
Here we show the results of numerical experiments performed in order to check
the predictions of Eqs. (19), (20) for the difference $\Delta K_{\mu\nu}$
between the similarity matrix after and before training. In particular, we
train architectures with a single hidden FC/$1d$-convolutional layer with tanh
activation (see details in Appendix D) on a learning task with random Gaussian
inputs and zero/one labels given by a linear teacher. We perform a finite-size
scaling analysis by keeping $\alpha_{1}=1$ and choosing increasing values of
$P,N_{1}$. In panel (a) we observe that the variance of the empirical
distribution of the matrix elements of the zero-one block $\Delta
K_{\mu\nu}^{\textrm{FC}}|_{01}$ rapidly converges to zero as $N_{1}$ grows and
$\alpha_{1}$ is kept fixed to one, in agreement with the prediction of Eq.
(19) (top). In particular, the variance goes to zero as $1/N_{1}^{2}$
(middle). The fact that the similarity matrices after and before training are
more and more similar in the thermodynamic limit is also clearly visible in
the explicit array plot of a subsample of the zero-one block $\Delta
K_{\mu\nu}^{\textrm{FC}}|_{01}$ (bottom). In panel (b) we display the
histogram of the distribution of the matrix elements of the one-one block
$\Delta K_{\mu\nu}^{\textrm{FC}}|_{11}$ (top). As predicted by Eq. (19), the
distribution shrinks while drifting towards zero at a rate $\sim 1/N_{1}$
(middle). Overall, (a) and (b) represent a clear indication that the change in
the after-training internal representations in one hidden layer FCNs is a
finite-size effect. In (c) and (d) we repeat the same experiment for an
architecture with a $1d$-convolutional hidden layer. The striking difference
wrt the FC case is that the variance of the empirical distribution of the
matrix elements $\Delta K_{\mu\nu}^{\textrm{CNN}}$ does not shrink to zero as
$N_{c}$ grows and $\alpha_{c}$ is kept fixed to one, as one can also
appreciate by directly looking at the array plot of a subsample of the block
matrices $\Delta K_{\mu\nu}^{\textrm{CNN}}|_{01}$ and $\Delta
K_{\mu\nu}^{\textrm{CNN}}|_{11}$.

Extracting the renormalized kernel from the measure of a physical observable
is not straightforward, and we have no way, at the moment, to directly access
it in numerical experiments. One indirect experimental blueprint of the form
of kernel renormalization at finite width in different architectures is given
by the similarity matrix of the internal representations before and after
training. We define this observable for both FCNs and CNNs as:

$O_{\mu\nu}\equiv\frac{1}{N_{1}}\sum_{i=1}^{N_{1}}\sigma\left(h^{\mu}_{i}\right)\sigma\left(h^{\nu}_{i}\right)\,,$
(18)

where $N_{1}$ denotes the number of neurons in the last layer (for CNNs we
have $N_{1}=N_{c}\lfloor N_{0}/S\rfloor$). We can track the effect of training
by taking the difference between the similarity matrix at initialization,
which is by definition the NNGP kernel (up to the Gaussian prior
$\lambda_{1}$), and the same quantity after training: $\Delta
K_{\mu\nu}\equiv\langle O_{\mu\nu}\rangle-K_{\mu\nu}$, where the average is
done over the Gibbs ensemble of the weights. We analytically compute this
observable for FCNs and CNNs, as shown in appendix C. The final result in the
two cases respectively reads (at zero temperature):

$\displaystyle\Delta
K^{\textrm{FCN}}_{\mu\nu}=-\frac{1}{N_{1}}\left[K_{\mu\nu}-\frac{\lambda_{1}}{\bar{Q}}y^{\mu}y^{\nu}\right];$
(19) $\displaystyle\Delta
K^{\textrm{CNN}}_{\mu\nu}=-\frac{1}{\lambda_{1}N_{1}}\sum_{ij,\lambda\rho=1}^{\lfloor
N_{0}/S\rfloor,P}\bar{Q}_{ij}P^{ij}_{\mu\lambda\nu\rho}$
$\displaystyle\,\,\,\times\left[\left(K^{(\mathrm{R})}_{\textrm{CNN}}\right)^{-1}_{\lambda\rho}-\sum_{\epsilon\omega=1}^{P}\left(K^{(\mathrm{R})}_{\textrm{CNN}}\right)^{-1}_{\lambda\epsilon}\left(K^{(\mathrm{R})}_{\textrm{CNN}}\right)^{-1}_{\rho\omega}y^{\epsilon}y^{\omega}\right],$
(20)

where
$P^{ij}_{\mu\lambda\nu\rho}\equiv\frac{1}{2}\sum_{k}\Big{[}K^{ik}_{\mu\lambda}K^{kj}_{\nu\rho}+K^{ki}_{\mu\lambda}K^{jk}_{\nu\rho}\Big{]}$.
Let us now highlight a few interesting physical implications that directly
follow from these formulas and can be checked with numerical experiments:

  1. (i)

the difference between the trained and untrained similarity matrix $\Delta
K^{\textrm{FCN}}_{\mu\nu}$ converges to zero in the thermodynamic limit
$P,N_{1}\rightarrow\infty$ at fixed $\alpha_{1}=P/N_{1}$, as long as the terms
in the square brackets are of order $o(N_{1})$. This means that in the
proportional regime under consideration the effect of training on the internal
representations is just a finite-size correction $O(1/N_{1})$ and the trained
similarity matrix stays very close to its value at initialization. In
particular, we expect that the empirical distribution of the elements of the
matrix $\Delta K^{\textrm{FCN}}_{\mu\nu}$ will be increasingly peaked around
zero in finite-size scaling experiments where we consider increasing values of
$P$ and $N_{1}$ keeping their ratio $\alpha_{1}=P/N_{1}$ fixed;

  2. (ii)

by choosing a learning task with labels $y^{\mu}=0,1$ and input patterns
$x^{\mu}$ such that the matrix elements of the kernel $K_{\mu\nu}$ are on
average centered in zero, the distribution of the matrix elements of the block
$\Delta K^{\textrm{FCN}}_{\mu\nu}|_{11}$ (corresponding to the subset of
training patterns with label one) should drift towards zero at a rate
$1/N_{1}$, if one performs experiments at constant $\alpha_{1}$, while
increasing $P$ and $N_{1}$. Interestingly, the remaining blocks of the matrix
$\Delta K^{\textrm{FCN}}_{\mu\nu}$ should not be affected by this drift;

  3. (iii)

the difference between the trained and untrained convolutional similarity
matrix $\Delta K^{\textrm{CNN}}_{\mu\nu}$ displays a different behavior, due
to local kernel renormalization. For instance, even if we restrict our
analysis to the learning setting outlined in bullet (ii), the elements of the
block $\Delta K^{\textrm{CNN}}_{\mu\nu}|_{01}$ should not identically converge
to zero in the thermodynamic proportional limit. A straightforward scaling
analysis in fact shows that the contribution due to the term in the square
bracket does not vanish in the proportional limit.

In Fig. 2 we present the results of a finite-size scaling analysis to check
the aforementioned predictions, where we trained one hidden layer FCNs and
CNNs ($1d$ convolutions) on a synthetic dataset composed of random Gaussian
patterns whose labels are given by a linear teacher function, i.e.
$y=\frac{1}{2}\left[1+\textrm{sign}(t\cdot x)\right]$, where $t$ is an
$N_{0}$-dimensional vector with unitary entries. Overall, the fact that the
change in the internal representations of FCNs is a finite-size effect is
confirmed by the experiments. On the other hand, the same numerical
simulations with CNNs clearly identify a genuine change in the internal
representations that occurs also in the thermodynamic proportional limit. We
note that such a clean signature of the differences between FCNs and CNNs
derive also from our choice of working close to zero temperature (where the
architectures can precisely fit the training data). Equations at finite $T$
are more involved, and measuring the indirect effects of global and local
kernel renormalization in this case is more difficult. Interestingly, even
though our theory should be valid only in the Bayesian setting, it turns out
to be also predictive for a learning algorithm that does not explicitly sample
from the Gibbs posterior distribution: the aforementioned experiments were
carried out using gradient descent and the so-called ADAM optimizer [54] (see
Appendix D for more details).

Another empirical evidence for the local renormalization in CNNs can be found
analyzing the bias/variance decomposition of the generalization error over a
new example $(\mathbf{x}^{0},y^{0})$:

$\begin{split}\braket{\epsilon_{\text{g}}(\mathbf{x}^{0},y^{0})}&=(y^{0}-\Gamma)^{2}+\sigma^{2}\end{split}$
(21)

with:

$\displaystyle\Gamma=\sum_{\mu\nu=1}^{P}\kappa^{\mathrm{(R)}}_{\mu}\left(\frac{\mathbb{1}}{\beta}+K^{\mathrm{(R)}}(\\{\bar{Q}\\})\right)^{-1}_{\mu\nu}\;y_{\nu},$
(22)
$\displaystyle\sigma^{2}=\kappa^{(\mathrm{R})}_{0}-\sum_{\mu\nu=1}^{P}\kappa^{(\mathrm{R})}_{\mu}\left(\frac{\mathbb{1}}{\beta}+K^{(\mathrm{R})}(\\{\bar{Q}\\})\right)^{-1}_{\mu\nu}\kappa^{(\mathrm{R})}_{\nu}$
(23)

These expressions are valid for FCNs, and can be easily extended to CNNs with
the substitution:

$K^{(\mathrm{R})}\to
K^{(\mathrm{R})}_{\mathrm{CNN}}\quad\kappa^{(\mathrm{R})}\to\kappa^{(\mathrm{R})}_{\mathrm{CNN}}\,,$
(24)

where the renormalized kernel matrices $K^{(\mathrm{R})}$ and
$K^{(\mathrm{R})}_{\mathrm{CNN}}$ are given respectively in equations (5) and
(11). We recall the definition of the additional kernel integrals that depend
on the new example $x^{0}$, that is $\kappa_{\mu}^{(\mathrm{R})}$, where the
index $\mu=0,\ldots,P$ covers both the dataset and the new test element
$x^{0}$:

$\displaystyle\kappa_{\mu}=\int\mathop{}\\!\mathrm{d}t\mathcal{N}_{t}\left(0,\tilde{C}_{\mu}\right)\sigma(t_{1})\sigma(t_{2})\,,$
(25)

where:

$\displaystyle\begin{gathered}\tilde{C}_{\mu}=\begin{pmatrix}C_{\mu\mu}&C_{\mu
0}\\\ C_{\mu 0}&C_{00}\end{pmatrix}\,,\,\,C_{\mu 0}=\frac{x^{\mu}\cdot
x^{0}}{\lambda_{0}N_{0}}\,,\end{gathered}$ (27)

In the CNN case, these quantities are computed starting from the local
covariance matrix $C^{ij}_{\mu\nu}$ defined in Eq. (12). These terms undergo
the same type of renormalization as the correspondent kernel matrices (see
table 1), that is:

$\displaystyle{\kappa}^{(\mathrm{R})}_{\mu}=\frac{\bar{Q}}{\lambda_{1}}\kappa_{\mu}\,,$
(28)
$\displaystyle\left[{\kappa}_{\textrm{CNN}}^{(\mathrm{R})}\right]_{\mu}=\frac{1}{\lambda_{1}\lfloor
N_{0}/S\rfloor}\sum_{ij=1}^{\lfloor
N_{0}/S\rfloor}\bar{Q}_{ij}\kappa_{\mu}^{ij}\,,$ (29)

The $\beta\to\infty$ limit of Eq. (22) yields different behaviors for the bias
in the two cases:

$\displaystyle\hphantom{{}^{2}}\Gamma^{\mathrm{FC}}=\sum_{\mu\nu=1}^{P}\kappa_{\mu}K^{-1}_{\mu\nu}\;y_{\nu}\,,$
(30)
$\displaystyle\hphantom{{}^{2}}\Gamma^{\mathrm{CNN}}=\sum_{\mu\nu=1}^{P}\left[\kappa^{\mathrm{(R)}}_{\mathrm{CNN}}\right]_{\mu}\left(K^{\mathrm{(R)}}_{\mathrm{CNN}}(\\{\bar{Q}\\})\right)^{-1}_{\mu\nu}\;y_{\nu},$
(31)

From these expressions one can make two observations: (i) as already discussed
in [38], $\Gamma^{\textrm{FC}}$ at finite width is independent of $\bar{Q}$,
and therefore the bias is identical to the infinite-width case for any
$N_{1}$. (ii) In CNNs, on the other hand, the dependence of the bias from the
renormalized Kernel does not disappear, and neither does the dependence on the
width $N_{1}$.

In the large Gaussian prior regime $\lambda_{1}\gg 1$, the previous
observations can be made into straightforward predictions that can be tested
with numerical experiments. It is easy to check that the variance is vanishing
in this regime, since it is always proportional to a term $1/\lambda_{1}$ both
in FCNs and CNNs. Moreover, when $\lambda_{1}\gg 1$, the analytical criterion
found in [38] to predict whether a finite-width FCN will outperform its
infinite-width counterpart, is never satisfied. This is a special case of the
general considerations already presented in section II. To summarize, in this
regime we expect that (i) the finite FC network can not outperform its
infinite-width counterpart. (ii) On the contrary, we expect CNNs to possibly
beat their infinite-width performance, since the bias can be reduced through
the optimization of the feature matrix $Q^{ij}$.

Figure 3: Test loss vs number of $2d$ convolutional filters for one hidden
layer CNNs with different filter sizes $M$. All the networks are trained on
the same binary regression task with $P=500$ examples from two classes of the
CIFAR10 dataset, ”cars” and ”planes”, respectively labeled $0$ and $1$. Error
bars represent one standard deviation. The images are gray-scaled and coarse-
grained to $N_{0}=28\times 28$. We choose the filter size $M$ to be an integer
divisor of $28$, and the filters to be non overlapping (taking stride $S=M$).
A sketch of how the images are parsed by filters is reported for each network.
With this choice, the FC network is retrieved setting $M=28$. The nets are
trained with a zero temperature Langevin dynamics (see appendix REF), and with
large Gaussian priors $\lambda_{1}$. In this bias-dominated regime, we observe
that: (i) in FCNs, the best possible performance is the infinite-width one.
Here the variance is monotonically decreasing with the width $N_{c}$, while
the bias is a constant. Therefore, the test loss approaches its minimum
monotonically from above, as predicted by our theory. (ii) finite width CNNs
can outperform their infinite-width counterpart. The local kernel
renormalization mechanism allows the CNN to optimize both bias and variance at
finite width, making it even convenient to have a small number of filters (the
minimum is reached for $N_{c}\sim 50$). Eventually, the CNNs reach their
asymptotic performance from below.

To test these predictions, we performed numerical simulations with $2d$ CNNs
trained on CIFAR10 examples, close to the zero-temperature limit and in the
bias-dominated setting where we let the Gaussian prior $\lambda_{1}$ be large.
As shown in Fig. 3, the test loss of the FCN is a monotonically decreasing
function of the hidden layer size $N_{1}$ and it does reach its asymptotic
(best) performance already for $\alpha\sim 1$. Compatibly to local kernel
renormalization, CNNs with finite number of channels best their infinite-width
counterpart, already for large filter sizes ($M=14,7$) and ultimately approach
the infinite-width limit performance from below.

##  VI Discussion

In this work we have derived an effective action in the proportional limit for
CNNs and LCNs with one hidden layer, and we have extensively compared these
results with the FC case found in [38].

We have highlighted a striking difference in the kernel renormalization
mechanism that the three different architectures undergo at finite width,
summarized in Table 1, and we have suggested a mechanism for feature learning
(local kernel renormalization) that can take place in CNNs, but not in
architectures with LC or FC layers alone.

We have made a preliminary study on the effect of global and local kernel
renormalization at the level of the internal representations of trained
networks, which is in agreement with our predictions. We have also
investigated the behavior of the generalization loss of one hidden layer
networks in a controlled Bayesian setting where the performance is dominated
by the bias, which confirms the observation that, in this regime, (i) finite-
width one hidden layer FC networks cannot outperform their infinite-width
counterpart; (ii) CNNs with finite number of channels can improve the
infinite-width performance, which is in qualitative agreement with our local
kernel renormalization hypothesis for the bias in Eq. (31).

We conclude by pointing out a number of possible follow-ups of this work: (i)
it would be interesting to extend our framework to $L$ convolutional layers,
following the same strategy proposed for FC layers in [38]; (ii) our current
approach cannot cover the mean-field regime, where the feature learning
mechanism for FCNs and CNNs may quantitatively change. We think that the
formalism presented in [23] might be more suited to investigate finite-width
effects in this case; (iii) we are writing a detailed open-source numerical
routine to extensively check the theoretical predictions of our effective
theory for FCNs, LCNs and CNNs, which will also serve to point out the
limitations of the present framework.

_Acknowledgements_.– R.B. and P.R. are supported by $\\#$NEXTGENERATIONEU
(NGEU) and funded by the Ministry of University and Research (MUR), National
Recovery and Resilience Plan (NRRP), project MNESYS (PE0000006) “A Multiscale
integrated approach to the study of the nervous system in health and disease”
(DN. 1553 11.10.2022). The authors thank F. Cagnetta for giving feedback on a
preliminary version of this manuscript and for pointing out interesting
related works, G. Naveh, Z. Ringel and I. Seroussi for discussions and
clarifications on their results in Refs. [23, 24] and P. Baglioni, M. Gherardi
and M. Pastore for discussions.

## References

  * Goodfellow  _et al._ [2016] I. Goodfellow, Y. Bengio, and A. Courville,  _Deep Learning_ (MIT Press, 2016).
  * Bengio  _et al._ [2013] Y. Bengio, A. Courville, and P. Vincent, Representation learning: A review and new perspectives, IEEE Transactions on Pattern Analysis and Machine Intelligence 35, 1798 (2013).
  * Yu  _et al._ [2013] D. Yu, M. L. Seltzer, J. Li, J.-T. Huang, and F. Seide, Feature learning in deep neural networks-studies on speech recognition tasks, arXiv preprint arXiv:1301.3605 (2013).
  * Neal [1996] R. M. Neal, Priors for infinite networks, in  _Bayesian Learning for Neural Networks_ (Springer New York, New York, NY, 1996) pp. 29–53.
  * Williams [1996] C. Williams, Computing with infinite networks, in  _Advances in Neural Information Processing Systems_, Vol. 9, edited by M. Mozer, M. Jordan, and T. Petsche (MIT Press, 1996).
  * de G. Matthews  _et al._ [2018] A. G. de G. Matthews, J. Hron, M. Rowland, R. E. Turner, and Z. Ghahramani, Gaussian process behaviour in wide deep neural networks, in  _International Conference on Learning Representations_ (2018).
  * Lee  _et al._ [2018] J. Lee, J. Sohl-dickstein, J. Pennington, R. Novak, S. Schoenholz, and Y. Bahri, Deep neural networks as gaussian processes, in  _International Conference on Learning Representations_ (2018).
  * Garriga-Alonso  _et al._ [2019] A. Garriga-Alonso, C. E. Rasmussen, and L. Aitchison, Deep convolutional networks as shallow gaussian processes, in  _International Conference on Learning Representations_ (2019).
  * Novak  _et al._ [2019] R. Novak, L. Xiao, Y. Bahri, J. Lee, G. Yang, D. A. Abolafia, J. Pennington, and J. Sohl-dickstein, Bayesian deep convolutional networks with many channels are gaussian processes, in  _International Conference on Learning Representations_ (2019).
  * Jacot  _et al._ [2018] A. Jacot, F. Gabriel, and C. Hongler, Neural tangent kernel: Convergence and generalization in neural networks, in  _Advances in Neural Information Processing Systems_, Vol. 31, edited by S. Bengio, H. Wallach, H. Larochelle, K. Grauman, N. Cesa-Bianchi, and R. Garnett (Curran Associates, Inc., 2018).
  * Chizat  _et al._ [2019] L. Chizat, E. Oyallon, and F. Bach, On lazy training in differentiable programming, in  _Advances in Neural Information Processing Systems_, Vol. 32, edited by H. Wallach, H. Larochelle, A. Beygelzimer, F. d'Alché-Buc, E. Fox, and R. Garnett (Curran Associates, Inc., 2019).
  * Lee  _et al._ [2019] J. Lee, L. Xiao, S. Schoenholz, Y. Bahri, R. Novak, J. Sohl-Dickstein, and J. Pennington, Wide neural networks of any depth evolve as linear models under gradient descent, in  _Advances in Neural Information Processing Systems_, Vol. 32, edited by H. Wallach, H. Larochelle, A. Beygelzimer, F. d'Alché-Buc, E. Fox, and R. Garnett (Curran Associates, Inc., 2019).
  * Cortes and Vapnik [1995] C. Cortes and V. Vapnik, Support-vector networks, Machine Learning 20, 273 (1995).
  * Dietrich  _et al._ [1999] R. Dietrich, M. Opper, and H. Sompolinsky, Statistical mechanics of support vector networks, Phys. Rev. Lett. 82, 2975 (1999).
  * Bordelon  _et al._ [2020] B. Bordelon, A. Canatar, and C. Pehlevan, Spectrum dependent learning curves in kernel regression and wide neural networks, in  _Proceedings of the 37th International Conference on Machine Learning_, Proceedings of Machine Learning Research, Vol. 119, edited by H. D. III and A. Singh (PMLR, 2020) pp. 1024–1034.
  * Canatar  _et al._ [2021] A. Canatar, B. Bordelon, and C. Pehlevan, Spectral bias and task-model alignment explain generalization in kernel regression and infinitely wide neural networks, Nature communications 12, 1 (2021).
  * Vyas  _et al._ [2022] N. Vyas, Y. Bansal, and N. Preetum, Limitations of the ntk for understanding generalization in deep learning, arXiv preprint arXiv:2206.10012 (2022).
  * Lee  _et al._ [2020] J. Lee, S. Schoenholz, J. Pennington, B. Adlam, L. Xiao, R. Novak, and J. Sohl-Dickstein, Finite versus infinite neural networks: an empirical study, in  _Advances in Neural Information Processing Systems_, Vol. 33, edited by H. Larochelle, M. Ranzato, R. Hadsell, M. Balcan, and H. Lin (Curran Associates, Inc., 2020) pp. 15156–15172.
  * Atanasov  _et al._ [2022] A. Atanasov, B. Bordelon, S. Sainathan, and C. Pehlevan, The onset of variance-limited behavior for networks in the lazy and rich regimes, arXiv preprint arXiv:2212.12147 (2022).
  * Mei  _et al._ [2018] S. Mei, A. Montanari, and P.-M. Nguyen, A mean field view of the landscape of two-layer neural networks, Proceedings of the National Academy of Sciences 115, E7665 (2018), https://www.pnas.org/doi/pdf/10.1073/pnas.1806579115 .
  * Geiger  _et al._ [2021] M. Geiger, L. Petrini, and M. Wyart, Landscape and training regimes in deep learning, Physics Reports 924, 1 (2021), landscape and training regimes in deep learning.
  * Geiger  _et al._ [2020] M. Geiger, S. Spigler, A. Jacot, and M. Wyart, Disentangling feature and lazy training in deep neural networks, Journal of Statistical Mechanics: Theory and Experiment 2020, 113301 (2020).
  * Seroussi  _et al._ [2023] I. Seroussi, G. Naveh, and Z. Ringel, Separation of scales and a thermodynamic description of feature learning in some cnns, Nature Communications 14, 908 (2023).
  * Naveh and Ringel [2021] G. Naveh and Z. Ringel, A self consistent theory of gaussian processes captures feature learning effects in finite cnns, in  _Advances in Neural Information Processing Systems_, Vol. 34, edited by M. Ranzato, A. Beygelzimer, Y. Dauphin, P. Liang, and J. W. Vaughan (Curran Associates, Inc., 2021) pp. 21352–21364.
  * Zavatone-Veth  _et al._ [2021] J. Zavatone-Veth, A. Canatar, B. Ruben, and C. Pehlevan, Asymptotics of representation learning in finite bayesian neural networks, in  _Advances in Neural Information Processing Systems_, Vol. 34, edited by M. Ranzato, A. Beygelzimer, Y. Dauphin, P. Liang, and J. W. Vaughan (Curran Associates, Inc., 2021) pp. 24765–24777.
  * Zavatone-Veth  _et al._ [2022] J. A. Zavatone-Veth, W. L. Tong, and C. Pehlevan, Contrasting random and learned features in deep bayesian linear regression, Phys. Rev. E 105, 064118 (2022).
  * Zavatone-Veth and Pehlevan [2021] J. A. Zavatone-Veth and C. Pehlevan, Exact marginal prior distributions of finite bayesian neural networks, in  _Advances in Neural Information Processing Systems_, edited by A. Beygelzimer, Y. Dauphin, P. Liang, and J. W. Vaughan (2021).
  * Roberts  _et al._ [2022] D. A. Roberts, S. Yaida, and B. Hanin,  _The Principles of Deep Learning Theory_ (Cambridge University Press, 2022) https://deeplearningtheory.com, arXiv:2106.10165 [cs.LG] .
  * Hanin [2023] B. Hanin, Random fully connected neural networks as perturbatively solvable hierarchies (2023), arXiv:2204.01058 [math.PR] .
  * Antognini [2019] J. M. Antognini, Finite size corrections for neural network gaussian processes (2019), arXiv:1908.10030 [cs.LG] .
  * Yaida [2020] S. Yaida, Non-Gaussian processes and neural networks at finite widths, in  _Proceedings of The First Mathematical and Scientific Machine Learning Conference_, Proceedings of Machine Learning Research, Vol. 107, edited by J. Lu and R. Ward (PMLR, 2020) pp. 165–192.
  * Aitchison [2020] L. Aitchison, Why bigger is not always better: on finite and infinite neural networks, in  _Proceedings of the 37th International Conference on Machine Learning_, Proceedings of Machine Learning Research, Vol. 119, edited by H. D. III and A. Singh (PMLR, 2020) pp. 156–164.
  * Yang  _et al._ [2023] A. X. Yang, M. Robeyns, E. Milsom, N. Schoots, and L. Aitchison, A theory of representation learning in deep neural networks gives a deep generalisation of kernel methods (2023), arXiv:2108.13097 [stat.ML] .
  * Favaro  _et al._ [2023] S. Favaro, B. Hanin, D. Marinucci, I. Nourdin, and G. Peccati, Quantitative clts in deep neural networks, arXiv preprint arXiv:2307.06092 (2023).
  * Cagnetta  _et al._ [2023] F. Cagnetta, A. Favero, and M. Wyart, What can be learnt with wide convolutional neural networks? (2023).
  * Favero  _et al._ [2021] A. Favero, F. Cagnetta, and M. Wyart, Locality defeats the curse of dimensionality in convolutional teacher-student scenarios, in  _Advances in Neural Information Processing Systems_, edited by A. Beygelzimer, Y. Dauphin, P. Liang, and J. W. Vaughan (2021).
  * Petrini  _et al._ [2022] L. Petrini, F. Cagnetta, E. Vanden-Eijnden, and M. Wyart, Learning sparse features can lead to overfitting in neural networks, in  _Advances in Neural Information Processing Systems_, edited by A. H. Oh, A. Agarwal, D. Belgrave, and K. Cho (2022).
  * Ariosto  _et al._ [2022] S. Ariosto, R. Pacelli, M. Pastore, F. Ginelli, M. Gherardi, and P. Rotondo, Statistical mechanics of deep learning beyond the infinite-width limit, arXiv preprint arXiv:2209.04882 (2022).
  * Li and Sompolinsky [2021] Q. Li and H. Sompolinsky, Statistical mechanics of deep linear neural networks: The backpropagating kernel renormalization, Phys. Rev. X 11, 031059 (2021).
  * Hanin and Zlokapa [2023] B. Hanin and A. Zlokapa, Bayesian interpolation with deep linear networks, Proceedings of the National Academy of Sciences 120, e2301345120 (2023), https://www.pnas.org/doi/pdf/10.1073/pnas.2301345120 .
  * Li and Sompolinsky [2022] Q. Li and H. Sompolinsky, Globally gated deep linear networks, arXiv preprint arXiv:2210.17449 (2022).
  * Mei and Montanari [2019] S. Mei and A. Montanari, The generalization error of random features regression: Precise asymptotics and the double descent curve, Communications on Pure and Applied Mathematics (2019).
  * Goldt  _et al._ [2020] S. Goldt, B. Loureiro, G. Reeves, F. Krzakala, M. Mézard, and L. Zdeborová, The gaussian equivalence of generative models for learning with shallow neural networks, arXiv preprint arXiv:2006.14709 (2020).
  * Gerace  _et al._ [2021] F. Gerace, B. Loureiro, F. Krzakala, M. Mézard, and L. Zdeborová, Generalisation error in learning with random features and the hidden manifold model, Journal of Statistical Mechanics: Theory and Experiment 2021, 124013 (2021).
  * Loureiro  _et al._ [2021] B. Loureiro, C. Gerbelot, H. Cui, S. Goldt, F. Krzakala, M. Mezard, and L. Zdeborová, Learning curves of generic features maps for realistic datasets with a teacher-student model, Advances in Neural Information Processing Systems 34 (2021).
  * Breuer and Major [1983] P. Breuer and P. Major, Central limit theorems for non-linear functionals of gaussian fields, Journal of Multivariate Analysis 13, 425 (1983).
  * Shah  _et al._ [2014] A. Shah, A. Wilson, and Z. Ghahramani, Student-t Processes as Alternatives to Gaussian Processes, in  _Proceedings of the Seventeenth International Conference on Artificial Intelligence and Statistics_, Proceedings of Machine Learning Research, Vol. 33, edited by S. Kaski and J. Corander (PMLR, Reykjavik, Iceland, 2014) pp. 877–885.
  * Cui  _et al._ [2023] H. Cui, F. Krzakala, and L. Zdeborová, Optimal learning of deep random networks of extensive-width, arXiv preprint arXiv:2302.00375 (2023).
  * Schröder  _et al._ [2023] D. Schröder, H. Cui, D. Dmitriev, and B. Loureiro, Deterministic equivalent and error universality of deep random features learning, arXiv preprint arXiv:2302.00401 (2023).
  * Camilli  _et al._ [2023] F. Camilli, D. Tieplova, and J. Barbier, Fundamental limits of overparametrized shallow neural networks for supervised learning, arXiv preprint arXiv:2307.05635 (2023).
  * Guerra and Toninelli [2002] F. Guerra and F. L. Toninelli, The thermodynamic limit in mean field spin glass models, Communications in Mathematical Physics 230, 71 (2002).
  * Agliari  _et al._ [2020] E. Agliari, F. Alemanno, A. Barra, and A. Fachechi, Generalized guerra’s interpolation schemes for dense associative neural networks, Neural Networks 128, 254 (2020).
  * Ingrosso and Goldt [2022] A. Ingrosso and S. Goldt, Data-driven emergence of convolutional structure in neural networks, Proceedings of the National Academy of Sciences 119, e2201854119 (2022), https://www.pnas.org/doi/pdf/10.1073/pnas.2201854119 .
  * Kingma and Ba [2014] D. P. Kingma and J. Ba, Adam: A method for stochastic optimization, arXiv preprint arXiv:1412.6980 (2014).
  * Abadi  _et al._ [2015] M. Abadi, A. Agarwal, P. Barham, E. Brevdo, Z. Chen, C. Citro, G. S. Corrado, A. Davis, J. Dean, M. Devin, S. Ghemawat, I. Goodfellow, A. Harp, G. Irving, M. Isard, Y. Jia, R. Jozefowicz, L. Kaiser, M. Kudlur, J. Levenberg, D. Mané, R. Monga, S. Moore, D. Murray, C. Olah, M. Schuster, J. Shlens, B. Steiner, I. Sutskever, K. Talwar, P. Tucker, V. Vanhoucke, V. Vasudevan, F. Viégas, O. Vinyals, P. Warden, M. Wattenberg, M. Wicke, Y. Yu, and X. Zheng, TensorFlow: Large-scale machine learning on heterogeneous systems (2015), software available from tensorflow.org.

##  Appendix A Derivation of the effective action for a shallow Locally
Connected Network

Here we present the explicit computation of the effective action for one
hidden layer LCNs [9]. For simplicity, we consider one-dimensional local
interaction, but the calculation can be generalized to a $d$-dimensional
setting. For LCNs, the pre-activations of the hidden layer are given by:

$h_{i}^{a}(x)=\sum_{m=-\lfloor M/2\rfloor}^{\lfloor
M/2\rfloor}\frac{W_{im}^{a}x_{Si+m}}{\sqrt{M}}\,,$ (32)

where $M$ indicates the size of the filter and $S$ denotes the value of the
stride. The index $a=1\ldots N_{c}$ runs over the filters. From the pre-
activations, we can define the output of the LCN as:

$f_{\textrm{LCN}}(x)=\frac{1}{\sqrt{N_{c}\lfloor
N_{0}/S\rfloor}}\sum_{i=1}^{\lfloor
N_{0}/S\rfloor}\sum_{a=1}^{N_{c}}v_{i}^{a}\sigma\left(h_{i}^{a}\right).$ (33)

We recall the notation for the total number of weights in the last layer
$N_{1}=N_{c}\lfloor N_{0}/S\rfloor$. Note that in the special case $S=N_{0}$
we recover the FC architecture.

Our objective is to construct the data-dependent partition function for this
learning problem in the proportional limit:

$\displaystyle Z=$
$\displaystyle\int\prod_{i,a}dv_{i}^{a}\prod_{i,m,a}dW_{im}^{a}\,\exp\Big{\\{}-\frac{\lambda_{1}}{2}\|{v}\|^{2}-\frac{\lambda_{0}}{2}\|{W}\|^{2}-\frac{\beta}{2}\sum_{\mu=1}^{P}\left[y^{\mu}-f_{\textrm{LCN}}(x^{\mu})\right]^{2}\Big{\\}}\,.$
(34)

Here, we employ the same notation of [38], where $\lambda_{0}$ and
$\lambda_{1}$ are respectively the Gaussian priors of the hidden and last
layer. We introduce two sets of Dirac deltas, corresponding to the pre-
activations of the hidden layer and the output of the network. We denote these
new degrees of freedom as $h_{ia}^{\mu}$ and $s^{\mu}$ respectively:

$\prod_{i,a,\mu}\delta\Big{(}h_{ia}^{\mu}-\frac{1}{\sqrt{M}}\sum_{m=-\lfloor\frac{M}{2}\rfloor}^{\lfloor\frac{M}{2}\rfloor}W_{im}^{a}x_{Si+m}^{\mu}\Big{)}\,,\qquad\prod_{\mu}\delta\Big{(}s^{\mu}-\frac{1}{\sqrt{N_{1}}}\sum_{i,a=1}^{\lfloor\frac{N_{0}}{S}\rfloor,N_{c}}v_{i}^{a}\sigma(h_{ia}^{\mu})\Big{)}\,.$
(35)

Expressing the deltas directly in their standard Fourier representation, we
have:

$\displaystyle Z=$
$\displaystyle\int\prod_{i,a,\mu}dh_{ia}^{\mu}d\bar{h}_{ia}^{\mu}\prod_{\mu}ds^{\mu}d\bar{s}^{\mu}e^{-\frac{\beta}{2}\sum_{\mu}(y^{\mu}-s^{\mu})^{2}+i\sum_{\mu}s^{\mu}\bar{s}^{\mu}+i\sum_{\mu,i}h_{ia}^{\mu}\bar{h}_{ia}^{\mu}}$
$\displaystyle\times\Bigg{\langle}e^{-i\sum_{\mu}\bar{s}^{\mu}\Big{(}\frac{1}{\sqrt{N_{1}}}\sum_{i}v_{i}^{a}\sigma(h_{ia}^{\mu})\Big{)}}\Bigg{\rangle}_{{v}}\Bigg{\langle}e^{-i\sum_{\mu,i,a}\bar{h}_{ia}^{\mu}\Big{(}\frac{1}{\sqrt{M}}\sum_{m}W_{im}^{a}x_{Si+m}^{\mu}\Big{)}}\Bigg{\rangle}_{{W}}\,.$
(36)

where the average is over the distribution of the weights. Performing these
integrals yield a simple expression for the quantities in brackets.
Respectively:

$\displaystyle\prod_{i,a}\exp\Bigg{\\{}-\frac{\left[\sum_{\mu=1}^{P}\bar{s}^{\mu}\sigma(h_{ia}^{\mu})\right]^{2}}{2\lambda_{1}N_{1}}\Bigg{\\}}\,,\qquad\prod_{i,a}\exp\Bigg{\\{}-\frac{\sum_{\mu,\nu=1}^{P}\bar{h}_{ia}^{\mu}C^{ii}_{\mu\nu}\bar{h}_{ia}^{\nu}}{2}\Bigg{\\}}\,,$
(37)

where the matrix $C^{ii}_{\mu\nu}$ is the diagonal part of the local
covariance matrix defined in Eq. (12), i.e.

$C^{ii}_{\mu\nu}=\frac{1}{\lambda_{0}M}\sum_{m=-\lfloor M/2\rfloor}^{\lfloor
M/2\rfloor}x^{\mu}_{Si+m}x^{\nu}_{Si+m}.$ (38)

This quantity provides information on the self-correlation of the local patch
in position $Si$ for any pair of training patterns $\mu,\nu$ in the dataset.
These steps allow to factorize the integrals on the $h$-$\bar{h}$ variables
over the patch indices $i$ and channel one $a$, leading to the following
equation for the partition function

$\displaystyle Z$
$\displaystyle=\int\prod_{\mu}ds^{\mu}d\bar{s}^{\mu}e^{-\frac{\beta}{2}\sum_{\mu=1}^{P}(y^{\mu}-s^{\mu})^{2}+i\sum_{\mu=1}^{P}s^{\mu}\bar{s}^{\mu}}$
$\displaystyle\,\,\,\times\Bigg{\\{}\int\prod_{i}d^{P}h_{i}\,d^{P}\bar{h}_{i}\,e^{-\frac{1}{2}\sum_{\mu\nu
i}\bar{h}_{i}^{\mu}C^{ii}_{\mu\nu}\bar{h}_{i}^{\nu}+i\sum_{\mu
i}h_{i}^{\mu}\bar{h}_{i}^{\mu}-\frac{1}{2\lambda_{1}N_{1}}\sum_{i}[\sum_{\mu=1}^{P}\bar{s}^{\mu}\sigma(h_{i}^{\mu})]^{2}}\Bigg{\\}}^{N_{c}}.$
(39)

After the integration over the $\bar{h}$-variables, the quantity in curly
brackets becomes:

$\prod_{i}\int
d^{P}h_{i}\,P_{1}^{i}(\\{h^{\mu}\\})e^{-\frac{1}{2\lambda_{1}N_{1}}[\sum_{\mu=1}^{P}\bar{s}^{\mu}\sigma(h_{i}^{\mu})]^{2}}\,,$
(40)

where the probability distribution $P_{1}^{(i)}$ is given by:

$P_{1}^{(i)}(\\{h^{\mu}\\})\equiv\frac{e^{-\frac{1}{2}{h}_{i}^{\top}(C^{ii})^{-1}{h}_{i}}}{\sqrt{(2\pi)^{P}\det
C^{ii}}},$ (41)

To proceed in the calculation, we introduce a new set of variables $q_{i}$
through Dirac’s $\delta$ identities. In this way Eq. (40) becomes:

$\displaystyle\qquad\prod_{i}\int
dq_{i}e^{-\frac{1}{2}q_{i}^{2}}P(q_{i})\,,\qquad P(q_{i})=\int
d^{P}h_{i}P_{1}^{i}(\\{h^{\mu}\\})\delta\Big{(}q_{i}-\frac{1}{\sqrt{\lambda_{1}N_{1}}}\sum_{\mu=1}^{P}\bar{s}^{\mu}\sigma(h^{\mu}_{i})\Big{)}$

Similarly to [38], we perform a Gaussian approximation on the limiting
distribution of $P(q_{i})$, heuristically justified by the Breuer-Major
theorem [46]:

$\displaystyle P(q_{i})\rightarrow$
$\displaystyle\mathcal{N}_{q_{i}}(0,Q_{i}),$ (43)

where the variances are:

$\displaystyle Q_{i}(\bar{s},C^{i})=$
$\displaystyle\frac{1}{\lambda_{1}N_{1}}\sum_{\mu\nu=1}^{P}\bar{s}^{\mu}\Big{[}\int
d^{P}hP_{1}^{i}(\\{h^{\mu}\\})\sigma(h^{\mu})\sigma(h^{\nu})\Big{]}\bar{s}^{\nu}\equiv\frac{1}{\lambda_{1}N_{1}}\sum_{\mu\nu=1}^{P}\bar{s}^{\mu}K_{\mu\nu}^{i}\bar{s}^{\nu}\,,$
(44)

here $K_{\mu\nu}^{i}\equiv K_{\mu\nu}^{ii}$ is a compact notation for the
diagonal part (in the spatial indices) of the kernel matrix defined in (13).
After performing the (Gaussian) integrals in the $q_{i}$ variables, we have:

$\Big{\\{}\prod_{i}(1+Q_{i}(\bar{s},C^{i}))^{-\frac{1}{2}}\Big{\\}}^{N_{c}}=e^{-\frac{N_{c}}{2}\sum_{i}\log{(1+Q_{i}(\bar{s},C^{i}))}}.$
(45)

We insert a new set of deltas to handle the $\bar{s}$ dependency in
$Q_{i}(\bar{s},C^{i}))$:

$1=\int
dQ_{i}\,\delta\Big{(}Q_{i}-\frac{1}{\lambda_{1}N_{1}}\sum_{\mu\nu=1}^{P}\bar{s}^{\mu}K_{\mu\nu}^{i}\bar{s}^{\nu}\Big{)}.$
(46)

In this way we are able to perform the Gaussian integration on the $\bar{s}$
variable, after a rescaling ${\bar{Q}}\rightarrow-i\frac{N_{c}}{2}{\bar{Q}}$,
obtaining:

$\displaystyle Z=$
$\displaystyle\int\prod_{i}dQ_{i}d\bar{Q}_{i}\prod_{\mu}ds^{\mu}\,\exp(-\frac{\beta}{2}\sum_{\mu=1}^{P}(y^{\mu}-s^{\mu})^{2})$
$\displaystyle\times\exp\left(-\frac{1}{2}{s}^{\top}\left[{K}_{\textrm{LCN}}^{(\mathrm{R})}\right]^{-1}{s}-\frac{1}{2}\log\det\left[{K}_{\textrm{LCN}}^{(\mathrm{R})}\right]-\frac{N_{c}}{2}\sum_{i}\left(Q_{i}\bar{Q}_{i}-\log(1+Q_{i})\right)\right)\,,$
(47)

where we have identified the renormalized kernel for the LCN:

$\displaystyle\left[K_{\textrm{LCN}}^{(\mathrm{R})}(\bar{Q})\right]_{\mu\nu}\equiv\frac{1}{\lfloor
N_{0}/S\rfloor}\sum_{i=1}^{\lfloor
N_{0}/S\rfloor}\bar{Q}_{i}K_{\mu\nu}^{i}\,.$ (48)

which contains only the diagonal elements of the local kernel matrix defined
in Eq. (11).

Finally, we perform this last Gaussian integral and we are left with a
partition function which depends only on ${Q}$ and ${\bar{Q}}$:

$Z=\int\prod_{i}dQ_{i}d\bar{Q}_{i}e^{-\frac{N_{c}}{2}S_{\textrm{LCN}}(Q,\bar{(}Q)},$
(49)

where the LCN effective action $S_{\textrm{LCN}}$ is given by:

$\displaystyle S_{\textrm{LCN}}\equiv$
$\displaystyle-\sum_{i}(Q_{i}\bar{Q}_{i}-\log(1+Q_{i}))+\frac{\alpha_{c}}{P}\textrm{Tr}\log\beta\Big{(}\frac{\mathbb{1}}{\beta}+{K}_{\textrm{LCN}}^{(\mathrm{R})}\Big{)}+\frac{\alpha_{c}}{P}{y}^{\top}\Big{(}\frac{\mathbb{1}}{\beta}+{K}_{\textrm{LCN}}^{(\mathrm{R})}\Big{)}^{-1}{y}.$
(50)

We recall that
$\Big{(}\frac{\mathbb{1}}{\beta}+{K}_{\textrm{LCN}}^{(\mathrm{R})}\Big{)}$ is
a $P\times P$ matrix. Note that this action shares the same functional form as
the one for FCN found in [38].

##  Appendix B Derivation of the effective action for a shallow CNN

In this section we address the case of shallow CNN architectures, where there
is combination of locality and weight sharing. Using the same notation as the
previous section, the output of a CNN reads:

$f_{\textrm{CNN}}(x^{\mu})=\frac{1}{\sqrt{N_{1}}}\sum_{i=1}^{\lfloor
N_{0}/S\rfloor}\sum_{a=1}^{N_{c}}v_{i}^{a}\sigma\left(\sum_{m=-\lfloor
M/2\rfloor}^{\lfloor
M/2\rfloor}\frac{W_{m}^{a}x_{Si+m}^{\mu}}{\sqrt{M}}\right),$ (51)

Similarly to the LCN case, we need two sets of deltas, one for the
preactivations and one for the outputs, that we directly insert through their
standard Fourier representation:

$\displaystyle Z=$
$\displaystyle\int\prod_{i,a,\mu}dh_{ia}^{\mu}d\bar{h}_{ia}^{\mu}\prod_{\mu}ds^{\mu}d\bar{s}^{\mu}e^{-\frac{\beta}{2}\sum_{\mu=1}^{P}(y^{\mu}-s^{\mu})^{2}+i\sum_{\mu=1}^{P}s^{\mu}\bar{s}^{\mu}+i\sum_{\mu
ia}h_{ia}^{\mu}\bar{h}_{ia}^{\mu}}$
$\displaystyle\times\Bigg{\langle}e^{-i\sum_{\mu=1}^{P}\bar{s}^{\mu}\Big{(}\frac{1}{\sqrt{N_{1}}}\sum_{ia}v_{i}^{a}\sigma(h_{ia}^{\mu})\Big{)}}\Bigg{\rangle}_{{v}}\Bigg{\langle}e^{-i\sum_{i,a,\mu}\bar{h}_{ia}^{\mu}\Big{(}\frac{1}{\sqrt{M}}\sum_{m=-\lfloor\frac{M}{2}\rfloor}^{\lfloor\frac{M}{2}\rfloor}W_{m}^{a}x_{Si+m}^{\mu}\Big{)}}\Bigg{\rangle}_{{W}}\,.$
(52)

Similarly to the LCN case, we get simple contributions for the averaged
quantities:

$\displaystyle\prod_{a}\exp\Bigg{\\{}-\frac{1}{2\lambda_{1}N_{1}}\sum_{i}\left[\sum_{\mu=1}^{P}\bar{s}^{\mu}\sigma(h_{ia}^{\mu})\right]^{2}\Bigg{\\}}\,,\qquad\prod_{a}\exp\Bigg{\\{}-\frac{1}{2}\sum_{i,j}\sum_{\mu,\nu}\bar{h}_{ia}^{\mu}C_{\mu\nu}^{ij}\bar{h}_{ja}^{\nu}\Bigg{\\}}\,,$
(53)

where we have used the definition (12) of the local covariance matrix:

$C_{\mu\nu}^{ij}=\frac{1}{\lambda_{0}M}\sum_{m=-\lfloor M/2\rfloor}^{\lfloor
M/2\rfloor}x^{\mu}_{Si+m}x^{\nu}_{Sj+m},$ (54)

Factorizing over the channel index, the partition function reads:

$\displaystyle Z=$
$\displaystyle\int\prod_{\mu}ds^{\mu}d\bar{s}^{\mu}e^{-\frac{\beta}{2}\sum_{\mu=1}^{P}(y^{\mu}-s^{\mu})^{2}+i\sum_{\mu=1}^{P}s^{\mu}\bar{s}^{\mu}}$
$\displaystyle\times\Bigg{\\{}\int\prod_{i}d^{P}h_{i}\,d^{P}\bar{h}_{i}\,e^{-\frac{1}{2}\sum_{ij}\sum_{\mu,\nu}\bar{h}_{ia}^{\mu}C_{\mu\nu}^{ij}\bar{h}_{j}^{\nu}}\,e^{i\sum_{\mu
i}h_{i}^{\mu}\bar{h}_{i}^{\mu}-\frac{1}{2\lambda_{1}N_{1}}\sum_{i}[\sum_{\mu=1}^{P}\bar{s}^{\mu}\sigma(h_{i}^{\mu})]^{2}}\Bigg{\\}}^{N_{c}}.$
(55)

The Gaussian integral on the ${\bar{h}}$ variables can be performed. Inside
the curly brackets we have:

$\int\prod_{\mu
i}dh_{i}^{\mu}\,\mathcal{N}_{h}(0,{C})e^{-\frac{1}{2\lambda_{1}N_{1}}\sum_{i}[\sum_{\mu=1}^{P}\bar{s}^{\mu}\sigma(h_{i}^{\mu})]^{2}}\,,$
(56)

where the notation $\mathcal{N}_{h}(0,{C})$ indicates a multivariate
normalized Gaussian on the $h$ variables, with zero mean and covariance matrix
$C_{\mu\nu}^{ij}$ . In order to deal with the non linearity term, we define a
collection of $\lfloor N_{0}/S\rfloor$ deltas:

$1=\int\prod_{i}dq_{i}\,\delta\Big{(}q_{i}-\frac{1}{\sqrt{\lambda_{1}N_{1}}}\sum_{\mu=1}^{P}\bar{s}^{\mu}\sigma(h^{\mu}_{i})\Big{)}.$
(57)

Here again, we assume that the joint distribution of the variables $q_{i}$ can
be approximated by a multivariate Normal distribution with $0$ mean and
covariance matrix $Q$ with elements:

$Q_{ij}(\bar{{s}},{C})\equiv\langle
q_{i}q_{j}\rangle_{{h}}=\frac{1}{\lambda_{1}N_{1}}\sum_{\mu,\nu}\bar{s}^{\mu}\langle\sigma(h_{i}^{\mu})\sigma(h_{j}^{\nu})\rangle_{{h}}\bar{s}^{\nu}\equiv\frac{1}{\lambda_{1}N_{1}}\sum_{\mu,\nu}\bar{s}^{\mu}K^{ij}_{\mu\nu}\bar{s}^{\nu},$
(58)

Note that this would be heuristically justified by a multivariate version of
the Breuer-Major theorem. The quantity in curly brackets is again a
multidimensional Gaussian integral on the $q_{i}$ variables:

$\displaystyle\Big{\\{}\dots\Big{\\}}^{N_{c}}=$
$\displaystyle\Bigg{\\{}\int\prod_{i}dq_{j}\,\frac{e^{-\frac{1}{2}\sum_{ij}q_{i}(\delta_{ij}+Q_{ij}^{-1})q_{j}}}{\sqrt{\det
2\pi{Q}}}\Bigg{\\}}^{N_{c}}=\Big{\\{}\det(\mathbb{1}+{Q})\Big{\\}}^{-\frac{N_{c}}{2}}=e^{-\frac{N_{c}}{2}\textrm{Tr}\log(\mathbb{1}+{Q})}$
(59)

To deal with the implicit dependence of ${Q}$ on ${\bar{s}}$, we introduce one
last family of deltas:

$1=\int
dQ_{ij}\,\delta\Big{(}Q_{ij}-\frac{1}{\lambda_{1}N_{1}}\sum_{\mu\nu=1}^{P}\bar{s}^{\mu}K_{\mu\nu}^{ij}\bar{s}^{\nu}\Big{)}\,,$
(60)

that allow to perform the integration over $\bar{s}^{\mu}$ after the
transformation $\bar{Q}_{ij}\rightarrow-\frac{iN_{c}}{2}\bar{Q}_{ij}$:

$\displaystyle Z=$
$\displaystyle\int\prod_{ij}dQ_{ij}d\bar{Q}_{ij}\prod_{\mu}ds^{\mu}\,\exp\left(\frac{N_{c}}{2}\sum_{ij}Q_{ij}\bar{Q}_{ij}+\beta\sum_{\mu=1}^{P}s^{\mu}y^{\mu}-\frac{\beta}{2}\sum_{\mu=1}^{P}y^{\mu}y^{\mu}\right)$
$\displaystyle\times$
$\displaystyle\exp\left(-\frac{N_{c}}{2}\,\textrm{Tr}\log(\mathbb{1}+{Q})-\frac{1}{2}\log\det\left[{K}_{\textrm{CNN}}^{(\mathrm{R})}\right]-\frac{1}{2}\sum_{\mu\nu=1}^{P}s^{\mu}\Big{(}\beta\delta_{\mu\nu}+\left[{K}_{\textrm{CNN}}^{(\mathrm{R})}\right]_{\mu\nu}^{-1}\Big{)}s^{\nu}\right)\,,$
(61)

where $\left[{K}_{\textrm{CNN}}^{(\mathrm{R})}\right]_{\mu\nu}$ is the
renormalized CNN kernel defined in (11). After performing the last Gaussian
integral on $s^{\mu}$, we can finally write:

$Z=\int\prod_{ij}dQ_{ij}d\bar{Q}_{ij}e^{-\frac{N_{c}}{2}S_{\textrm{CNN}}({Q},{\bar{Q}})},$
(62)

where the CNN effective action $S_{\textrm{CNN}}$ reads:

$\displaystyle S_{\textrm{CNN}}({Q},{\bar{Q}})\equiv$
$\displaystyle-\sum_{ij}Q_{ij}\bar{Q}_{ij}+\textrm{Tr}\log(\mathbb{1}+{Q})+\frac{\alpha_{c}}{P}\textrm{Tr}\log\beta\Big{(}\frac{\mathbb{1}}{\beta}+{K}_{\textrm{CNN}}^{(\mathrm{R})}\Big{)}+\frac{\alpha_{c}}{P}{y}^{\top}\Big{(}\frac{\mathbb{1}}{\beta}+{K}_{\textrm{CNN}}^{(\mathrm{R})}\Big{)}^{-1}{y},$
(63)

where again
$\Big{(}\frac{\mathbb{1}}{\beta}+{K}_{\textrm{CNN}}^{(\mathrm{R})}\Big{)}$ is
a $P\times P$ matrix, while $\Big{(}\mathbb{1}+{Q}\Big{)}$ has dimensions
$\lfloor\frac{N_{0}}{S}\rfloor\times\lfloor\frac{N_{0}}{S}\rfloor$.

###  B.1 Saddle point equations from the CNN effective action

In this section we explicitly derive the saddle point equations of the
effective CNN action given in Eq. (63), that is:

$\displaystyle\frac{\partial}{\partial{Q_{ij}}}S_{\textrm{CNN}}({Q},{\bar{Q}})=0$
(64)
$\displaystyle\frac{\partial}{\partial{\bar{Q}_{ij}}}S_{\textrm{CNN}}({Q},{\bar{Q}})=0$
(65)

Recalling that $\textrm{Tr}\log(\mathbb{1}+{Q})\equiv\log\det(\mathbb{1}+{Q})$
and $\frac{\partial}{\partial{A_{ij}}}\det{A}=\textrm{adj}({A})_{ij}$, Eq.
(64) reads:

$0=-\bar{Q}_{ij}+(\textrm{adj}(\mathbb{1}+{Q}))_{ij}(\det(\mathbb{1}+{Q}))^{-1}.$
(66)

Using the identity ${A}^{-1}=\textrm{adj}({A})(\det{A})^{-1}$ we find

$\bar{Q}_{ij}=(\mathbb{1}+{Q})^{-1}_{ij},$ (67)

which holds for each element of ${\bar{Q}}$ and so
${\bar{Q}}=(\mathbb{1}+{Q})^{-1}$.

To compute the derivative in (64), one should observe that
$\left(\frac{\mathbb{1}}{\beta}+{K}_{\textrm{CNN}}^{(\mathrm{R})}\right)$ can
be thought as a $P\times P$ matrix field of the matrix variable $\bar{Q}$. We
use of the following identity for a generic matrix $A=A(x)$:

$\partial_{x_{i}}\det{A}=(\det{A})\cdot\textrm{Tr}({A}^{-1}\partial_{x_{i}}{A})\,,$
(68)

and obtain:

$\displaystyle
0=-Q_{ij}+\frac{\alpha_{c}}{P}\textrm{Tr}\left[\Big{(}\frac{\mathbb{1}}{\beta}+K^{(\mathrm{R})}\Big{)}^{-1}K^{ij}\right]-\frac{\alpha_{c}}{P}\sum_{\mu\rho\lambda\nu}y_{\mu}\Big{(}\frac{\mathbb{1}}{\beta}+K^{(\mathrm{R})}\Big{)}^{-1}_{\mu\rho}K^{ij}_{\rho\lambda}\Big{(}\frac{\mathbb{1}}{\beta}+K^{(\mathrm{R})}\Big{)}^{-1}_{\lambda\nu}y_{\nu},$
(69)

which reduces to Eq. (16) in the zero temperature limit.

##  Appendix C The similarity matrix of internal representations: differences
between FCNs and CNNs

The theoretical framework built so far allows us to predict statistical values
of observables. In this section, we will show how to analytically compute the
so-called similarity matrix, i.e. the covariance matrix of the hidden
representations of the trainset. The more general definition of this
observable can be found in the main text in Eq. 18. Specializing respectively
to FCNs and CNNs, we have:

$\displaystyle
O^{\textrm{FCN}}_{\mu\nu}=\frac{1}{N_{1}}\sum_{i=1}^{N_{1}}\sigma\left(h_{i}^{\mu}\right)\sigma\left(h_{i}^{\mu}\right),\qquad\qquad\qquad\qquad
h_{i}^{\mu}\equiv\frac{{W_{i}}\cdot{x}^{\mu}}{\sqrt{N_{0}}}$ (70)
$\displaystyle
O^{\textrm{CNN}}_{\mu\nu}=\frac{1}{N_{c}}\sum_{a=1}^{N_{c}}\frac{1}{\lfloor\frac{N_{0}}{S}\rfloor}\sum_{i=1}^{\lfloor
N_{0}/S\rfloor}\sigma(h^{a\mu}_{i})\sigma(h^{a\nu}_{i}),\qquad\,\,\,h_{i}^{a\mu}\equiv\frac{1}{\sqrt{M}}\sum_{m=-\lfloor
M/2\rfloor}^{\lfloor M/2\rfloor}W^{a}_{m}x^{\mu}_{Si+m}$ (71)

The average FCN similarity matrix turns out to have a simple form, and it
depends only on the NNGP kernel $K_{\mu\nu}$ and on a naive combination of the
labels $y^{\mu}$:

$\langle
O^{\textrm{FCN}}_{\mu\nu}\rangle=\left(1-\frac{1}{N_{1}}\right)K_{\mu\nu}+\frac{\lambda_{1}}{N_{1}\bar{Q}}y^{\mu}y^{\nu}.$
(72)

Note that our formalism allows to retrieve this observable for deep linear
networks, consistently finding the same result of [39], that is the same
expression with the replacement of the NNGP kernel with the data covariance
matrix $C_{\mu\nu}$.
The CNN case turns out to be more complicated. Indeed, there is again a
dependency on the NNGP kernel, but the convolutional architecture mixes
different labels in a non-trivial way:

$\displaystyle\langle O^{\textrm{CNN}}_{\mu\nu}\rangle=$
$\displaystyle\sum_{i}K^{ii}_{\mu\nu}-\frac{1}{\lambda_{1}N_{1}}\sum_{ij\lambda\rho}\bar{Q}_{ij}P^{ij}_{\mu\lambda\nu\rho}[(K^{(\mathrm{R})})^{-1}_{\lambda\rho}-\sum_{\epsilon\omega}(K^{(\mathrm{R})})^{-1}_{\lambda\epsilon}(K^{(\mathrm{R})})^{-1}_{\rho\omega}y^{\epsilon}y^{\omega}],$

where
$P^{ij}_{\mu\lambda\nu\rho}\equiv\frac{1}{2}\sum_{k}\Big{[}K^{ik}_{\mu\lambda}K^{kj}_{\nu\rho}+K^{ki}_{\mu\lambda}K^{jk}_{\nu\rho}\Big{]}$.
In this case, the labels are mixed through the application of the renormalized
kernel, incorporating the effect of training. In the next subsections, we will
present a sketch of the computation of the average similarity matrices.

###  C.1 FCN averaged similarity matrix

As a standard practice in statistical mechanics, to compute the averaged
similarity matrix, we need to define a modified partition function adding a
source term to one of the identical $N_{1}$ neurons of the last layer:
$\frac{1}{2N_{1}}\left(\sum_{\mu}J_{\mu}\sigma(h_{1}^{\mu})\right)^{2}$. Since
the variables $h^{\mu}_{i}$ are statistically identical, the choice $i=1$ will
not affect the result. The extended partition function reads:

$Z_{J}^{(\textrm{FCN})}=\int
P(\theta)\mathrm{d}\theta\,\exp\left(-\frac{\beta}{2}\sum_{\mu=1}^{P}\left[y^{\mu}-f_{\textrm{LCN}}(x^{\mu})\right]^{2}+\frac{1}{2N_{1}}\left(\sum_{\mu}J_{\mu}\sigma(h_{1}^{\mu})\right)^{2}\right)\,$
(73)

where we have reabsorbed the Gaussian priors $\lambda_{0},\lambda_{1}$ in the
term $P(\theta)\equiv P(v,W)$. The expected value of the observable in Eq.
(70) is easily computed from the derivatives of the partition function with
respect to the source $J_{\mu}$. It is easy to check that:

$\langle\sigma(h_{1}^{\mu})\sigma(h_{1}^{\nu})\rangle=-\lambda_{1}N_{1}\frac{1}{Z_{J}^{(\textrm{FCN})}}\frac{\partial^{2}Z_{J}^{(\textrm{FCN})}}{\partial
J^{\mu}\partial J^{\nu}}\Big{|}_{{J}=0},$ (74)

Let’s take the FCN partition function at the stage where we have already
integrated over $v$, $W$ and $\bar{h}$:

$\displaystyle Z_{J}^{(\textrm{FCN})}=$
$\displaystyle\int\prod_{\mu}ds^{\mu}d\bar{s}^{\mu}e^{-\frac{\beta}{2}\sum_{\mu}(y^{\mu}-s^{\mu})^{2}+i\sum_{\mu}s^{\mu}\bar{s}^{\mu}}\Bigg{\\{}\int
dP(h^{\mu})\,e^{-\frac{1}{2\lambda_{1}N_{1}}\left[\sum_{\mu}\bar{s}^{\mu}\sigma(h^{\mu})\right]^{2}}\Bigg{\\}}^{N_{1}-1}$
$\displaystyle\times\int
dP(h^{\mu}_{1})\,e^{-\frac{1}{2\lambda_{1}N_{1}}[\sum_{\mu}\bar{s}^{\mu}\sigma(h^{\mu}_{1})]^{2}}e^{-\frac{1}{2\lambda_{1}N_{1}}[\sum_{\mu}J^{\mu}\sigma(h^{\mu}_{1})]^{2}},$
(75)

where

$dP(h^{\mu})\equiv\prod_{\mu}\frac{dh^{\mu}}{\sqrt{\det{2\pi{C}}}}e^{-\frac{1}{2}\sum_{\mu\nu}h^{\mu}[C^{-1}]_{\mu\nu}h^{\nu}}.$
(76)

Here we have separated the $h_{1}$ integral, but we can immediately drop the
dummy index $i=1$, that was reported for the sake of clarity. The integral in
curly brackets is the same found in the calculation of the partition function
in [38]. Leveraging on the same Gaussian equivalence as in the previous
sections, we can write:

$\Bigg{\\{}\int
dP(h^{\mu})\,e^{-\frac{1}{2\lambda_{1}N_{1}}[\sum_{\mu}\bar{s}^{\mu}\sigma(h^{\mu})]^{2}}\Bigg{\\}}^{N_{1}-1}\to\left[Q(\bar{s})+1\right]^{-\frac{N_{1}-1}{2}}\,,$
(77)

where $Q(\bar{s})\equiv\frac{1}{\lambda_{1}N_{1}}{\bar{s}}^{\top}{K}{\bar{s}}$
and $K$ has components $K_{\mu\nu}=\int
dP(\\{h\\})\sigma(h^{\mu})\sigma(h^{\nu})$. To further proceed in the
calculation, we need to introduce two more delta function identities:

$1=\int
dq_{1}\delta\left(q_{1}-\frac{1}{\sqrt{\lambda_{1}N_{1}}}\sum_{\mu}\bar{s}^{\mu}\sigma(h^{\mu})\right)\,,\quad
1=\int
dq_{2}\delta\left(q_{2}-\frac{1}{\sqrt{\lambda_{1}N_{1}}}\sum_{\mu}J^{\mu}\sigma(h^{\mu})\right)$
(78)

Identifying a collective variable ${q}\equiv(q_{1},q_{2})$, the last integral
in (75) can be rewritten:

$\int d^{2}{q}\,P({q})\,e^{-\frac{1}{2}\|\ q\|^{2}}\,,\qquad P({q})=\int
dP(h^{\mu})\delta\left(q_{1}-\frac{1}{\sqrt{\lambda_{1}N_{1}}}\sum_{\mu}\bar{s}^{\mu}\sigma(h^{\mu})\right)\delta\left(q_{2}-\frac{1}{\sqrt{\lambda_{1}N_{1}}}\sum_{\mu}J^{\mu}\sigma(h^{\mu})\right)$
(79)

If the BM theorem’s hypotheses hold for $q_{1}$ and $q_{2}$, we can use it
again to justify a Gaussian equivalence for the distribution $P({q})$:

$P({q})\to\mathcal{N}_{q}(0,{\Sigma(\bar{s})})\equiv\frac{e^{-\frac{1}{2}{q}{\Sigma}^{-1}{q}^{\top}}}{\sqrt{(2\pi)^{2}\det({\Sigma(\bar{s})})}},$
(80)

where ${\Sigma(\bar{s})}$ is a $2\times 2$ covariance matrix defined as:

${\Sigma}=\frac{1}{\lambda_{1}N_{1}}\begin{pmatrix}{\bar{s}}^{\top}{K}{\bar{s}}&{\bar{s}}^{\top}{K}{J}\\\
{\bar{s}}^{\top}{K}{J}&{J}^{\top}{K}{J}\end{pmatrix}\,,$ (81)

where ${K}$ is the kernel matrix, with components $K_{\mu\nu}=\int
dP(h^{\rho})\sigma(h^{\mu})\sigma(h^{\nu})$. In this way, Eq. (75) becomes:

$Z_{J}^{(\textrm{FCN})}=\int\prod_{\mu}ds^{\mu}d\bar{s}^{\mu}e^{-\frac{\beta}{2}\sum_{\mu}(y^{\mu}-s^{\mu})^{2}+i\sum_{\mu}s^{\mu}\bar{s}^{\mu}}\left[Q(\bar{s})+1\right]^{-\frac{N_{1}-1}{2}}\left[\mathrm{det}\left(\mathbb{1}+\Sigma(\bar{s})\right)\right]^{-\frac{1}{2}}$
(82)

Let us focus on the determinant in the equation above, which is the only term
that depends on the source $J^{\mu}$. Firstly we point out that, when the
source is vanishing, equation (82) correctly reduces to the partition function
computed in [38]:

$\det(\mathbb{1}+{\Sigma})\Big{|}_{{J}=0}=Q(\bar{s})+1,$ (83)

To avoid heavy notation, we have dropped the explicit dependence
$\Sigma(\bar{s})$, which will be understood implicitly in the following. The
derivatives with respect to $J^{\mu}$ and $J^{\nu}$ can be computed using the
Jacobi identity in Eq. (68):

$\displaystyle\partial_{J^{\mu}}\partial_{J^{\nu}}\left[\det(\mathbb{1}+{\Sigma})\right]^{-\frac{1}{2}}=\left[\det(\mathbb{1}+{\Sigma})\right]^{-\frac{1}{2}}\Bigg{\\{}\frac{1}{4}\textrm{Tr}\Big{(}(\mathbb{1}+{\Sigma})^{-1}\partial_{J^{\nu}}{\Sigma}\Big{)}\textrm{Tr}\Big{(}(\mathbb{1}+{\Sigma})^{-1}\partial_{J^{\mu}}{\Sigma}\Big{)}+$
$\displaystyle-\frac{1}{2}\textrm{Tr}\Big{(}(\mathbb{1}+{\Sigma})^{-1}\partial_{J^{\mu}}{\Sigma}(\mathbb{1}+{\Sigma})^{-1}\partial_{J^{\nu}}{\Sigma}\Big{)}+\frac{1}{2}\textrm{Tr}\Big{(}(\mathbb{1}+{\Sigma})^{-1}\partial_{J^{\mu}}\partial_{J^{\nu}}{\Sigma}\Big{)}\Bigg{\\}}\,,$
(84)
$\displaystyle\frac{\partial{\Sigma}}{\partial{J^{\mu}}}\Big{|}_{{J}=0}=\frac{1}{\lambda_{1}N_{1}}\begin{pmatrix}0&({K}{\bar{s}})^{\mu}\\\
({K}{\bar{s}})^{\mu}&0\end{pmatrix}\,,\qquad\frac{\partial^{2}{\Sigma}}{\partial
J^{\mu}\partial
J^{\nu}}\Big{|}_{{J}=0}=\frac{2}{\lambda_{1}N_{1}}\begin{pmatrix}0&0\\\
0&K_{\mu\nu}\end{pmatrix}\,,$ (85)

where $(K\bar{s})^{\mu}\equiv\sum_{\rho}K_{\mu\rho}\bar{s}^{\rho}$. One can
see that the first term in curly brackets in Eq. (84) vanishes when ${J}=0$:

$(\mathbb{1}+{\Sigma})^{-1}\partial_{J^{\mu}}{\Sigma}\Big{|}_{{J}=0}=\frac{1}{\lambda_{1}N_{1}}\begin{pmatrix}0&(1+Q(\bar{s}))^{-1}({K}{\bar{s}})^{\mu}\\\
({K}{\bar{s}})^{\mu}&0\end{pmatrix}\,.$ (86)

The two non-zero contributions give:

$\displaystyle-$
$\displaystyle\frac{1}{2}\textrm{Tr}\Big{(}(\mathbb{1}+{\Sigma})^{-1}\partial_{J^{\mu}}{\Sigma}(\mathbb{1}+{\Sigma})^{-1}\partial_{J^{\nu}}{\Sigma}\Big{)}=-\frac{1}{(\lambda_{1}N_{1})^{2}}\frac{({K}{\bar{s}})^{\mu}({K}{\bar{s}})^{\nu}}{1+Q(\bar{s})}\,,$
(87)
$\displaystyle\frac{1}{2}\textrm{Tr}\Big{(}(\mathbb{1}+{\Sigma})^{-1}\partial_{J^{\mu}}\partial_{J^{\nu}}{\Sigma}\Big{)}=K_{\mu\nu}/(\lambda_{1}N_{1})\,,$
(88)

Collecting what we have computed so far, we have:

$\displaystyle-\lambda_{1}N_{1}\partial_{J^{\mu}}\partial_{J^{\nu}}(\det(\mathbb{1}+{\Sigma}))^{-\frac{1}{2}}\Big{|}_{{J}=0}=(1+Q(\bar{s}))^{-\frac{1}{2}}\Big{\\{}K_{\mu\nu}-\frac{1}{\lambda_{1}N_{1}}\frac{({K}{\bar{s}})^{\mu}({K}{\bar{s}})^{\nu}}{1+Q(\bar{s})}\Big{\\}}.$
(89)

The next step is to put back this result in Eq.(74), having already set $J=0$,
and to insert the usual Dirac’s delta for the $Q({\bar{s}})$. The integral on
$s$ is Gaussian, and dropping constant terms we get

$\displaystyle\langle\sigma(h^{\mu})\sigma(h^{\nu})\rangle=$
$\displaystyle\frac{1}{Z}\int
dQd\bar{Q}\,e^{-\frac{N_{1}}{2}\log(1+Q)+\frac{N_{1}}{2}Q\bar{Q}}$ (90)
$\displaystyle\,\times\int\prod_{\mu}d\bar{s}^{\mu}e^{-\frac{1}{2\beta}\sum_{\mu}(\bar{s}^{\mu})^{2}+i\sum_{\mu}y^{\mu}\bar{s}^{\mu}-\frac{\bar{Q}}{2\lambda_{1}}{\bar{s}}^{\top}{K}{\bar{s}}}\Big{[}K_{\mu\nu}-\frac{1}{\lambda_{1}N_{1}}\frac{({K}\cdot{\bar{s}})^{\mu}({K}\cdot{\bar{s}})^{\nu}}{1+Q}\Big{]}.$
(91)

The integral on $\bar{s}$ is again Gaussian and can be written as

$\displaystyle
e^{-\frac{1}{2}{y}^{\top}[{\tilde{K}}^{(\mathrm{R})}]^{-1}{y}}\int
d^{P}{\bar{s}}$
$\displaystyle\,\,e^{-\frac{1}{2}\big{(}{\bar{s}}+i[{\tilde{K}}^{(\mathrm{R})}]^{-1}\cdot{y}\big{)}^{\top}{\tilde{K}}^{(\mathrm{R})}\big{(}{\bar{s}}+i[{\tilde{K}}^{(\mathrm{R})}]^{-1}\cdot{y}\big{)}}\Big{[}K_{\mu\nu}-\frac{1}{\lambda_{1}N_{1}}\frac{({K}\cdot{\bar{s}})^{\mu}({K}\cdot{\bar{s}})^{\nu}}{1+Q}\Big{]},$
(92)

where we call
${\tilde{K}}^{(\mathrm{R})}\equiv\Big{(}\frac{\mathbb{1}}{\beta}+{K}^{(\mathrm{R})}\Big{)}$,
with ${K}^{(\mathrm{R})}\equiv\bar{Q}{K}/\lambda_{1}$ the renormalized kernel
matrix. Note that, in the zero-temperature limit, ${\tilde{K}}^{(\mathrm{R})}$
reduces to ${K}^{(\mathrm{R})}$. The first term in the square brackets does
not depend on $\bar{s}$ and so it will give us a term $K_{\mu\nu}Z$,
proportional to the partition function. After the transformation
$\bar{s}^{\mu}\rightarrow\bar{s}^{\mu}-i\big{(}[{\tilde{K}}^{(\mathrm{R})}]^{-1}\cdot{y}\big{)}^{\mu}$,
we have a zero-mean Gaussian integral, which reads:

$\displaystyle-\frac{[\det({\tilde{K}}^{(\mathrm{R})})]^{-\frac{1}{2}}}{\lambda_{1}N_{1}(1+Q)}\int
d^{P}{\bar{s}}\,\mathcal{N}_{\bar{s}}(0,({\tilde{K}}^{(\mathrm{R})})^{-1})\Big{[}({K}\cdot{\bar{s}})^{\mu}({K}\cdot{\bar{s}})^{\nu}-({K}\cdot[{\tilde{K}}^{(\mathrm{R})}]^{-1}\cdot{y})^{\mu}({K}\cdot[{\tilde{K}}^{(\mathrm{R})}]^{-1}\cdot{y})^{\nu}\Big{]}=$
(93)
$\displaystyle-\frac{[\det({\tilde{K}}^{(\mathrm{R})})]^{-\frac{1}{2}}}{\lambda_{1}N_{1}(1+Q)}\sum_{\rho\lambda}K_{\mu\rho}K_{\nu\lambda}\Big{[}([{\tilde{K}}^{(\mathrm{R})}]^{-1})_{\rho\lambda}-([{\tilde{K}}^{(\mathrm{R})}]^{-1}\cdot{y})^{\rho}([{\tilde{K}}^{(\mathrm{R})}]^{-1}\cdot{y})^{\lambda}\Big{]}.$
(94)

Then, we can write

$\displaystyle\langle\sigma(h^{\mu})\sigma(h^{\nu})\rangle=$ $\displaystyle
K_{\mu\nu}+\frac{1}{Z}\int
dQd\bar{Q}e^{-\frac{N_{1}}{2}S_{\textrm{FCN}}(Q,\bar{Q})}$
$\displaystyle\times\frac{1}{\lambda_{1}N_{1}(1+Q)}\Big{[}-\sum_{\lambda\rho}K_{\mu\lambda}K_{\nu\rho}([{\tilde{K}}^{(\mathrm{R})}]^{-1})_{\lambda\rho}+\sum_{\lambda\rho\epsilon\omega}K_{\mu\lambda}K_{\nu\rho}([{\tilde{K}}^{(\mathrm{R})}]^{-1})_{\lambda\epsilon}([{\tilde{K}}^{(\mathrm{R})}]^{-1})_{\rho\omega}\,y^{\epsilon}y^{\omega}\Big{]}\,.$
(95)

Finally, we can take the saddle point solution of the effective action, for
which $(1+Q)^{-1}=\bar{Q}$ and in the zero-temperature limit
$\beta\rightarrow\infty$, we get

$\langle\sigma(h^{\mu})\sigma(h^{\nu})\rangle=\Big{(}1-\frac{1}{N_{1}}\Big{)}K_{\mu\nu}+\frac{\lambda_{1}}{N_{1}\bar{Q}}y^{\mu}y^{\nu}\,.$
(96)

Since this result is independent on the index $i$, the average of the
observable in (70) is trivially retrieved:

$\langle
O^{\mathrm{FCN}}_{\mu\nu}\rangle=\langle\frac{1}{N_{1}}\sum_{i=1}^{N_{1}}\sigma\left(h^{\mu}_{i}\right)\sigma\left(h_{i}^{\nu}\right)\rangle\equiv\frac{1}{N_{1}}\sum_{i=1}^{N_{1}}\langle\sigma\left(h^{\mu}_{i}\right)\sigma\left(h_{i}^{\nu}\right)\rangle=\langle\sigma\left(h^{\mu}\right)\sigma\left(h^{\nu}\right)\rangle.$
(97)

###  C.2 CNN’s averaged similarity matrix

In this section, we extend the previous calculation to CNNs. We want to
compute the average $\langle O^{\mathrm{CNN}}_{\mu\nu}\rangle$, where the
observable $O^{\mathrm{CNN}}_{\mu\nu}$ is defined in (71). Similarly to the
previous section, we add a source term to the CNN’s partition function
$\frac{1}{\lambda_{1}N_{1}}\sum_{i}\left[\sum_{\mu}J^{\mu}\sigma(h^{\mu}_{i})\right]^{2}$.
Here $N_{1}=N_{c}\lfloor N_{0}/S\rfloor$ denotes the number of neurons in the
last layer of the CNN, reabsorbing the index $a$. The modified partition
function reads:

$\displaystyle
Z_{J}^{(\textrm{CNN})}=\int\prod_{\mu}ds^{\mu}d\bar{s}^{\mu}e^{-\frac{\beta}{2}\sum_{\mu}(y^{\mu}-s^{\mu})^{2}+i\sum_{\mu}s^{\mu}\bar{s}^{\mu}}\Bigg{\\{}\int
dP(h^{\mu}_{i})\,e^{-\frac{1}{2\lambda_{1}N_{1}}\sum_{i}[\sum_{\mu}\bar{s}^{\mu}\sigma(h^{\mu}_{i})]^{2}}\Bigg{\\}}^{N_{c}-1}$
$\displaystyle\,\,\,\times\int
dP(h^{\mu}_{i})\,e^{-\frac{1}{2\lambda_{1}N_{1}}\sum_{i}[\sum_{\mu}\bar{s}^{\mu}\sigma(h^{\mu}_{i})]^{2}}e^{-\frac{1}{2\lambda_{1}N_{1}}\sum_{i}[\sum_{\mu}J^{\mu}\sigma(h^{\mu}_{i})]^{2}},$
(98)

where:

$dP(h^{\mu}_{i})\equiv\prod_{\mu
i}\frac{dh^{\mu}_{i}}{\sqrt{\det{2\pi{C}}}}e^{-\frac{1}{2}\sum_{\mu\nu
ij}h^{\mu}_{i}[C^{-1}]^{ij}_{\mu\nu}h^{\nu}_{j}}.$ (99)

Analogously to the FCN case, one can check that:

$\Big{\langle}\frac{1}{\lfloor\frac{N_{0}}{S}\rfloor}\sum_{i=1}^{\lfloor
N_{0}/S\rfloor}\sigma(h^{a\mu}_{i})\sigma(h^{a\nu}_{i})\Big{\rangle}=-\lambda_{1}N_{c}\frac{1}{Z_{J}^{(\textrm{FCN})}}\frac{\partial^{2}Z_{J}^{(\textrm{FCN})}}{\partial
J^{\mu}\partial J^{\nu}}\Big{|}_{{J}=0}.$ (100)

The next step is to insert two families of Dirac’s $\delta$’s:

$\displaystyle\int\prod_{i}dq^{i}_{\bar{s}}\delta\big{(}q^{i}_{\bar{s}}-\frac{1}{\sqrt{\lambda_{1}N_{1}}}\sum_{\mu}\bar{s}^{\mu}\sigma(h^{\mu}_{i})\big{)}\,,\quad\int\prod_{i}dq^{i}_{J}\delta\big{(}q^{i}_{J}-\frac{1}{\sqrt{\lambda_{1}N_{1}}}\sum_{\mu}\bar{J}^{\mu}\sigma(h^{\mu}_{i})\big{)}\,,$
(101)

To make progress, we need again to make a Gaussian approximation for the joint
distribution of these new variables $P(q_{\bar{s}},q_{J})$:

$P({q_{\bar{s}}},{q_{J}})\to(\det{2\pi{\Sigma}})^{-1/2}\exp{\Big{(}-\frac{1}{2}({q_{\bar{s}}}\,|\,{q_{J}})^{\top}{\Sigma}^{-1}({q_{\bar{s}}}\,|\,{q_{J}})\Big{)}}\,,$
(102)

where we made use of the notation for the concatenation of two vectors:

$({q_{\bar{s}}}\,|\,{q_{J}})\equiv(q_{\bar{s}}^{(1)},\cdots,q_{\bar{s}}^{(\lfloor
N_{0}/S\rfloor)},q_{J}^{(1)},\cdots,q_{J}^{(\lfloor N_{0}/S\rfloor)}).$ (103)

Furthermore, the covariance matrix of this joint distribution is a block
matrix of the form

${\Sigma}=\frac{1}{\lambda_{1}N_{1}}\begin{pmatrix}{\bar{s}}^{\top}{K^{ij}}{\bar{s}}&\vline&{\bar{s}}^{\top}{K^{ij}}{J}\\\
\hline\cr{\bar{s}}^{\top}{K^{ij}}{J}&\vline&{J}^{\top}{K^{ij}}{J}\end{pmatrix}\,,$
(104)

where ${\bar{s}}^{\top}{K^{ij}}{\bar{s}}$ represents the $\lfloor
N_{0}/S\rfloor\times\lfloor N_{0}/S\rfloor$ matrix which remains after
contracting $K^{ij}_{\mu\nu}$ with two vectors on the pattern indices $\mu$
and $\nu$. The integral on the ${q}$ variables is Gaussian and gives the term
$\det(\mathbb{1}+{\Sigma})^{-1/2}$. Then, we have to compute the second
derivative of this term, analogously as was done for the FCN case, recovering
Eq. (84), obviously with a different definition of the matrix ${\Sigma}$.
Then, for the CNN case, we have

$\displaystyle(\mathbb{1}+{\Sigma})^{-1}\Big{|}_{{J}=0}=\begin{pmatrix}(\mathbb{1}+{Q}(\bar{s}))^{-1}&\vline&{0}\\\
\hline\cr{0}&\vline&\mathbb{1}\end{pmatrix}$
$\displaystyle(\mathbb{1}+{\Sigma})^{-1}\partial_{J^{\mu}}{\Sigma}\Big{|}_{{J}=0}=\frac{1}{\lambda_{1}N_{1}}\begin{pmatrix}{0}&\vline&\sum_{k}(\mathbb{1}+{Q}(\bar{s}))^{-1}_{ik}({K^{kj}}{\bar{s}})^{\mu}\\\
\hline\cr({K^{ij}}{\bar{s}})^{\mu}&\vline&{0}\end{pmatrix}$
$\displaystyle(\mathbb{1}+{\Sigma})^{-1}\partial_{J^{\mu}}{\Sigma}(\mathbb{1}+{\Sigma})^{-1}\partial_{J^{\nu}}{\Sigma}\Big{|}_{{J}=0}=\frac{1}{(\lambda_{1}N_{1})^{2}}\begin{pmatrix}\sum_{kl}(\mathbb{1}+{Q}(\bar{s}))^{-1}_{ik}({K^{kl}}{\bar{s}})^{\mu}({K^{lj}}{\bar{s}})^{\nu}&\vline&{0}\\\
\hline\cr{0}&\vline&\sum_{kl}({K^{ik}}{\bar{s}})^{\mu}(\mathbb{1}+{Q}(\bar{s}))^{-1}_{kl}({K^{lj}}{\bar{s}})^{\nu}\end{pmatrix}$
$\displaystyle(\mathbb{1}+{\Sigma})^{-1}\partial_{J^{\mu}}\partial_{J^{\nu}}{\Sigma}\Big{|}_{{J}=0}=\frac{2}{\lambda_{1}N_{1}}\begin{pmatrix}{0}&\vline&{0}\\\
\hline\cr{0}&\vline&K^{ij}_{\mu\nu}\end{pmatrix}\,,$ (105)

where we have defined
$[Q(\bar{s})]_{ij}\equiv\frac{1}{\lambda_{1}N_{1}}{\bar{s}}^{\top}{K^{ij}}{\bar{s}}$,
and $({K^{ij}}{\bar{s}})^{\mu}\equiv\sum_{\nu}K^{ij}_{\mu\nu}\bar{s}^{\nu}$.
In these equations, the second one has zero trace, while the trace of the
third reads

$\displaystyle\textrm{Tr}\Big{(}(\mathbb{1}+{\Sigma})^{-1}\partial_{J^{\mu}}{\Sigma}(\mathbb{1}+{\Sigma})^{-1}\partial_{J^{\nu}}{\Sigma}\Big{|}_{{J}=0}\Big{)}=\sum_{ij\lambda\rho}\frac{2}{(\lambda_{1}N_{1})^{2}}(\mathbb{1}+{Q(\bar{s}}))^{-1}_{ij}\bar{s}^{\lambda}\bar{s}^{\rho}P^{ij}_{\mu\lambda\nu\rho}\,,$
(106)

where

$P^{ij}_{\mu\lambda\nu\rho}=\frac{1}{2}\sum_{k}K^{ik}_{\mu\lambda}K^{kj}_{\nu\rho}+K^{ki}_{\mu\lambda}K^{jk}_{\nu\rho}\,.$
(107)

Now we are able to solve Eq. (84) and we get

$\displaystyle-\lambda_{1}N_{1}\partial_{J^{\mu}}\partial_{J^{\nu}}(\det(\mathbb{1}+{\Sigma}))^{-\frac{1}{2}}=\sum_{i}K^{ii}_{\mu\nu}-\frac{1}{\lambda_{1}N_{1}}\sum_{ij\lambda\rho}(\mathbb{1}+{Q(\bar{s})})^{-1}_{ij}\bar{s}^{\lambda}\bar{s}^{\rho}P^{ij}_{\mu\lambda\nu\rho},$
(108)

where $\sum_{i}K^{ii}_{\mu\nu}$ is the trace of ${K}$ along the $ij$ indices
and is a constant, then we can take it outside the integral. Thus, let’s
compute the second contribution, that we will call $P_{\mu\nu}$ for sake of
notation. First, we insert the deltas for the ${Q}$ variables, in order to get
rid of the explicit dependency on ${\bar{s}}$, and we make use again of the
Fourier representation of these deltas, with the variables ${\bar{Q}}$. Since
the new term depends only on ${\bar{s}}$, we can easily integrate on ${s}$,
obtaining (we write only the $\bar{s}$ integral)

$\displaystyle\int\prod_{\mu}d\bar{s}^{\mu}\,e^{-\frac{1}{2\beta}\sum_{\mu}\bar{s}^{\mu
2}+i\sum_{\mu}y^{\mu}\bar{s}^{\mu}-\frac{1}{2}\sum_{\mu\nu}K^{(\mathrm{R})}_{\mu\nu}\bar{s}^{\mu}\bar{s}^{\nu}}P_{\mu\nu}=$
$\displaystyle
e^{-\frac{1}{2}{y}^{\top}{\tilde{K}^{(\mathrm{R})}}{y}}\int\prod_{\mu}d\bar{s}^{\mu}\,e^{-\frac{1}{2}({\bar{s}}+i({\tilde{K}^{(\mathrm{R})}})^{-1}{y})^{\top}{K^{(\mathrm{R})}}({\bar{s}}+i({\tilde{K}^{(\mathrm{R})}})^{-1}{y})}P_{\mu\nu}\,,$
(109)

where $K^{(\mathrm{R})}$ is the renormalized kernel defined in (11) and
$\tilde{K}^{(\mathrm{R})}\equiv\frac{\mathbb{1}}{\beta}+K^{(\mathrm{R})}$.
This integral is easy to solve once we perform the transformation
$\bar{s}^{\mu}\rightarrow\bar{s}^{\mu}-i\sum_{\epsilon}[\tilde{K}^{(\mathrm{R})})^{-1}]_{\mu\epsilon}y^{\epsilon}$,
which implies that $P_{\mu\nu}$ becomes

$\sum_{ij\lambda\rho}\frac{1}{\lambda_{1}N_{1}}(\mathbb{1}+{Q(\bar{s})})^{-1}_{ij}P^{ij}_{\mu\lambda\nu\rho}[\bar{s}^{\lambda}\bar{s}^{\rho}-\sum_{\epsilon\omega}(\tilde{K}^{(\mathrm{R})})^{-1}_{\lambda\epsilon}(\tilde{K}^{(\mathrm{R})})^{-1}_{\rho\omega}y^{\epsilon}y^{\omega}].$
(110)

With this change of variables, we can perform the Gaussian integral, and we
are left only with the partition function having only the ${Q},{\bar{Q}}$
terms. Finally, we take all the contribution at the saddle-point solution and
at the zero-temperature regime, which means

$\displaystyle(\mathbb{1}+{Q})^{-1}\rightarrow{\bar{Q}},$
$\displaystyle\tilde{K}^{(\mathrm{R})}\rightarrow{K}^{(\mathrm{R})}.$ (111)

Collecting what we have so far and noting that Eq. (100) is independent wrt to
the channel index, we get the final form of the similarity matrix for a CNN
shallow architecture

$\displaystyle\langle
O^{\textrm{CNN}}_{\mu\nu}\rangle=\langle\frac{1}{N_{c}}\sum_{a=1}^{N_{c}}\frac{1}{\lfloor\frac{N_{0}}{S}\rfloor}\sum_{i=1}^{\lfloor
N_{0}/S\rfloor}\sigma(h^{a\mu}_{i})\sigma(h^{a\nu}_{i})\rangle\equiv\frac{1}{N_{c}}\sum_{a=1}^{N_{c}}\langle\frac{1}{\lfloor\frac{N_{0}}{S}\rfloor}\sum_{i=1}^{\lfloor
N_{0}/S\rfloor}\sigma(h^{a\mu}_{i})\sigma(h^{a\nu}_{i})\rangle=$
$\displaystyle\sum_{i}K^{ii}_{\mu\nu}-\frac{1}{\lambda_{1}N_{1}}\sum_{ij\lambda\rho}\bar{Q}_{ij}P^{ij}_{\mu\lambda\nu\rho}[(K^{(\mathrm{R})})^{-1}_{\lambda\rho}-\sum_{\epsilon\omega}(K^{(\mathrm{R})})^{-1}_{\lambda\epsilon}(K^{(\mathrm{R})})^{-1}_{\rho\omega}y^{\epsilon}y^{\omega}].$

##  Appendix D Numerical experiments

We perform numerical experiments both with shallow FCNs, and CNNs with 1d and
2d convolutions. The networks are trained on two different regression tasks.
Respectively: (i) a synthetic random dataset, whose elements have entries
sampled from a Gaussian distribution $\mathcal{N}(0,1)$, with labels given by
a linear teacher function with unitary weights $t=\\{1\ldots 1\\}$:

$y^{\mu}=\frac{1}{2}\left(1+\mathrm{sign}\left(t\cdot x^{\mu}\right)\right)$
(112)

(ii) a computer vision task: we use the 0 and 1 classes of the CIFAR10
datasets, respectively corresponding to the labels “cars” and “planes”. The
images are coarse grained to $N_{0}=28\times 28=D^{2}$ pixels and converted to
grayscale.

###  D.1 Experiments with 1d convolutions

The finite-width analysis presented in Fig. 2 was carried out training a one
hidden layer network with 1d convolutional filters on the synthetic dataset
described in the previous section. The network implements exactly the function
reported in Eq. (9), with activation function $\sigma(x)=\mathrm{tanh}(x)$.
The FC architecture is retrieved setting both the filter size $M$ and the
stride $S$ equal to the input dimension $N_{0}=M=S$. This correctly implements
the function given in Eq. (3). Here the networks are trained using full-batch
gradient descent, with ADAM optimizer, implemented with TensorFlow (TF) [55].
We train using a large value of the last layer Gaussian prior $\lambda_{1}$,
until the loss reaches a value of $O(10^{-10})$. We employed a scheduler for
the learning rate, reducing its value from $10^{-3}$ to $10^{-7}$ with the so-
called ReduceLROnPlateau scheduler of TF. The experiments shown in Fig. (2)
were performed fixing the value of $\alpha_{1}=P/N_{1}=1$ with increasing
values of $N_{1}$. The input size is set to $N_{0}=6400$ and we choose non-
overlapping convolutional filters, taking the size of the mask and the stride
equal to $M=S=400$. We built a statistical sample of $O(10^{2})$ networks,
trained independently, over which we average each result. In Fig. 4 and 5 we
show the result for $\alpha_{1}=10$ and $\alpha_{1}=0.1$, respectively. In
order to test the consistency of our results, we carried out the same
experiments for a smaller value of $N_{0}$, in particular we chose
$N_{0}=1600$ and the same values of $P$ and $N_{1}$.

$N_{0}$ | $\alpha_{1/c}=P/N_{1/c}$ | Fully-connected network | Convolutional network
---|---|---|---
$\sigma^{2}(\Delta K_{\mu\nu}|_{01})$ | $\overline{\Delta K_{\mu\nu}}|_{11}$ | $\sigma^{2}(\Delta K_{\mu\nu}|_{01})$ | $\overline{\Delta K_{\mu\nu}}|_{11}$
6400 | 0.1 | $-2.01\pm 0.11$ | $1.221\pm 0.009$ | $-0.51\pm 0.03$ | $-1.212\pm 0.352$
1 | $-2.15\pm 0.01$ | $1.153\pm 0.011$ | $-0.2\pm 0.01$ | $-1.045\pm 0.355$
10 | $-1.81\pm 0.05$ | $-0.980\pm 0.014$ | $-0.36\pm 0.06$ | $0.998\pm 0.409$
1600 | 0.1 | $-1.34\pm 0.23$ | $-1.278\pm 0.018$ | $-0.014\pm 0.046$ | $-0.9\pm 2.9$
1 | $-1.43\pm 0.22$ | $-1.154\pm 0.017$ | $0.008\pm 0.051$ | $-0.9\pm 2.8$
10 | $-1.35\pm 0.13$ | $-1.003\pm 0.021$ | $-0.087\pm 0.029$ | $-0.9\pm 2.8$
Table 2: Additional finite-size scaling experiments on the similarity matrix.
In this table we summarize the results of the various fit for
$\alpha_{1/c}=0.1,1,10$, with two choices of $N_{0}=6400,1600$. The values of
$P$ used in all experiments are $P=200,400,800,1600$. The column denoted by
$\sigma^{2}(\Delta K_{\mu\nu}|_{01})$ shows the trend of the variance of the
elements in the submatrix with labels $0,1$, while in the one denoted by
$\Delta\bar{K}_{\mu\nu}|_{11}$ we put the fit of the mean value of the
elements in the submatrix with labels $11$. Figure 4: Predicting the effect of
global and local kernel renormalization on the internal representations of
FCNs and CNNs. A finite-size scaling analysis. Additional experiments at
$\alpha_{1}=10$. Figure 5: Predicting the effect of global and local kernel
renormalization on the internal representations of FCNs and CNNs. A finite-
size scaling analysis. Additional experiments at $\alpha_{1}=0.1$

###  D.2 Experiments with 2d convolutions

The results shown in Fig. 3 are obtained training a one hidden layer
architecture with Erf activation and $2d$ non-overlapping convolutional
filters on the CIFAR10 binary task discussed above. This is achieved setting
the stride $S$ to be equal to the filter mask size $M$. To avoid information
loss, we choose $M$ to be an integer divisor of the linear input size $d=28$.
To ensure convergence of the posterior weights distribution to the Gibbs
ensemble, we train our networks using a discretized Langevin dynamics,
similarly to what is done in [39, 23, 38]. At each training step $t$ the
parameters $\theta=\\{W,v\\}$ are updated according to:

$\theta(t+1)=\theta(t)-\eta\nabla_{\theta}\mathcal{L}(\theta(t))+\sqrt{2T\eta}\epsilon(t)$
(113)

where $T=1/\beta$ is the temperature, $\eta$ is the learning rate,
$\epsilon(t)$ is a white Gaussian noise vector with entries drawn from a
standard normal distribution, and the loss is the one defined in equation (1).
We employ $T=\eta=2\cdot 10^{-3}$ throughout all these experiments. This is
sufficient to approximate the $T=0$ dynamics in the regime we are considering.
This dynamics requires $\sim 10^{6}$ steps to reach thermalization, in
particular we run the experiment for $5\cdot 10^{6}$ epochs. When possible, we
extract the generalization loss within a single run: after the train error has
reached its minimum and the test loss is thermalized, we average test loss
values every $10^{3}$ epochs. In the case of FC architecture in Fig. 3, we
averaged over $n=3$ samples to reduce the error.