Mechanism of feature learning in convolutional neural networks
Understanding the mechanism of how convolutional neural networks learn
features from image data is a fundamental problem in machine learning and
computer vision. In this work, we identify such a mechanism. We posit the
Convolutional Neural Feature Ansatz, which states that covariances of filters
in any convolutional layer are proportional to the average gradient outer
product (AGOP) taken with respect to patches of the input to that layer. We
present extensive empirical evidence for our ansatz, including identifying high
correlation between covariances of filters and patch-based AGOPs for
convolutional layers in standard neural architectures, such as AlexNet, VGG,
and ResNets pre-trained on ImageNet. We also provide supporting theoretical
evidence. We then demonstrate the generality of our result by using the
patch-based AGOP to enable deep feature learning in convolutional kernel
machines. We refer to the resulting algorithm as (Deep) ConvRFM and show that
our algorithm recovers similar features to deep convolutional networks
including the notable emergence of edge detectors. Moreover, we find that Deep
ConvRFM overcomes previously identified limitations of convolutional kernels,
such as their inability to adapt to local signals in images and, as a result,
leads to sizable performance improvement over fixed convolutional kernels.
Daniel Beaglehole, Adityanarayanan Radhakrishnan, Parthe Pandit, Mikhail Belkin
# Mechanism of feature learning in convolutional neural networks

###### Abstract

Understanding the mechanism of how convolutional neural networks learn features from image data is a fundamental problem in machine learning and computer vision. In this work, we identify such a mechanism. We posit the Convolutional Neural Feature Ansatz, which states that covariances of filters in any convolutional layer are proportional to the average gradient outer product (AGOP) taken with respect to patches of the input to that layer. We present extensive empirical evidence for our ansatz, including identifying high correlation between covariances of filters and patch-based AGOPs for convolutional layers in standard neural architectures, such as AlexNet, VGG, and ResNets pre-trained on ImageNet. We also provide supporting theoretical evidence. We then demonstrate the generality of our result by using the patch-based AGOP to enable deep feature learning in convolutional kernel machines. We refer to the resulting algorithm as (Deep) ConvRFM and show that our algorithm recovers similar features to deep convolutional networks including the notable emergence of edge detectors. Moreover, we find that Deep ConvRFM overcomes previously identified limitations of convolutional kernels, such as their inability to adapt to local signals in images and, as a result, leads to sizable performance improvement over fixed convolutional kernels.

## 1 Introduction

Neural networks have achieved impressive empirical results across various tasks in natural language processing [8], computer vision [39], and biology [50]. Yet, our understanding of the mechanisms driving the successes of these models is still emerging. One such mechanism of central importance is that of _neural feature learning_, which is the ability of networks to automatically learn relevant input transformations from data [37, 43, 55, 56].

An important line of work [5, 14, 23, 32, 35, 43, 52, 55] has demonstrated how feature learning in fully connected neural networks provides an advantage over classical, non-feature-learning models such as kernel machines. Recently, the work [37] identified a connection between a mathematical operator, known as average gradient outer product (AGOP) [17, 21, 47, 48], and feature learning in fully connected networks. This work subsequently demonstrated that the AGOP could be used to enable similar feature learning in kernel machines operating on tabular data. In contrast to the case for fully connected networks, there are few prior works [3, 24] analyzing feature learning in convolutional networks, which have been transformative in computer vision [19, 39]. The work [24] demonstrates an advantage of feature learning in convolutional networks by showing that these models are able to threshold noise and identify signal in image data unlike convolutional kernel methods including Convolutional Neural Tangent Kernels [4]. The work [3] analyzes how deep convolutional networks can correct features in early layers by simultaneous training of all layers. While these prior works identify advantages of feature learning in convolutional networks, they do not identify a general operator that captures such feature learning. The connection between AGOP and feature learning
in fully connected neural networks [37] suggests that a similar connection should exist for feature learning in convolutional networks. Moreover, such a mechanism could be used to learn analogous features with any machine learning model such as convolutional kernel machines.

In this work, we establish a connection between convolutional neural feature learning and the AGOP, which we posit as the Convolutional Neural Feature Ansatz (CNFA). Unlike the fully connected case from [37] where feature learning is characterized by AGOP with respect to network inputs, we demonstrate that convolutional feature learning is characterized by AGOP with respect to patches of network inputs. We present empirical evidence for the CNFA by demonstrating high average Pearson correlation (in most cases \(>.9\)) between AGOP on patches and the covariance of filters across all layers of pre-trained convolutional networks on ImageNet [40] and across all layers of SimpleNet [18] trained on several standard image classification datasets. We additionally prove that the CNFA holds for one step of gradient descent for deep convolutional networks. To demonstrate the generality of our identified convolutional feature learning mechanism, we leverage the AGOP on patches to enable feature learning in convolutional kernel machines. We refer to the resulting algorithm as ConvRFM. We demonstrate that ConvRFM captures features similar to those learned by the first layer of convolutional networks. In particular, on various image classification benchmark datasets such as SVHN [33] and CIFAR10 [26], we observe that ConvRFM recovers features corresponding to edge detectors. We further enable deep feature learning with convolutional kernels by developing a layerwise training scheme with ConvRFM, which we refer to as Deep ConvRFM. We demonstrate that Deep ConvRFM learns features similar to those learned by deep convolutional neural networks. Furthermore, we show that Deep ConvRFM overcomes limitations of convolutional kernels identified in [24] and exhibits _local feature adaptivity_. Lastly, we demonstrate that Deep ConvRFM provides improvement over CNTK and ConvRFM on several standard image classification datasets, indicating a benefit to deep feature learning. Our results advance understanding of how convolutional networks automatically learn features from data and provide a path toward integrating convolutional feature learning into general machine learning models.

## 2 Convolutional Neural Feature Ansatz (CNFA)

Let \(f:\mathbb{R}^{c\times P\times Q}\rightarrow\mathbb{R}\) denote a convolutional neural network (CNN) operating on \(P\times Q\) resolution images with \(c\) color channels. The \(\ell^{th}\) convolutional layer of a CNN involves applying a function \(h_{\ell}:\mathbb{R}^{c_{\ell-1}\times P_{\ell-1}\times Q_{\ell-1}}\rightarrow \mathbb{R}^{c_{\ell}\times P_{\ell}\times Q_{\ell}}\) defined recursively as \(h_{\ell}(x)=\phi(\widetilde{W}_{\ell}*h_{\ell-1}(x))\) with \(h_{1}=x\), \(\widetilde{W}_{\ell}\in\mathbb{R}^{c_{\ell}\times c_{\ell-1}\times q\times q}\) denoting \(c_{\ell}\) filters of size \(c_{\ell-1}\times q\times q\), \(*\) denoting the convolution operation, and \(\phi\) denoting an elementwise activation function. To understand how features emerge in convolutional networks, we abstract a convolutional network to a function of the form

\[f(x)=g(W_{1}x[1,1],\ldots,W_{1}x[i,j],\ldots,W_{1}x[P,Q]),\quad i \in[P],j\in[Q]\ ; \tag{1}\]

where \(W_{1}\in\mathbb{R}^{c_{1}\times cq^{2}}\) is a matrix of \(c_{1}\) stacked filters of size \(cq^{2}\) and \(x[i,j]\in\mathbb{R}^{cq^{2}}\) denotes the patch of \(x\) centered at coordinate \((i,j)\). This abstraction is helpful since it allows us to consider feature learning in convolutional networks with arbitrary architecture (e.g., pooling layers, batch normalization, etc.) after any given convolutional layer. Up to rotation and reflection by the left singular vectors, the feature extraction properties of \(W_{1}\) are determined by the singular values and right singular vectors of \(W_{1}\). These singular values and vectors can be recovered from the matrix \(W_{1}^{T}W_{1}\), which is the empirical (uncentered) covariance of filters in the first layer. This argument extends to analyze features selected at layer \(\ell\) of a CNN by considering a function of the form \(f(x)=g_{\ell}(W_{\ell}h_{\ell-1}(x)[1,1],\ldots,W_{\ell}h_{\ell-1}(x)[P_{\ell- 1},Q_{\ell-1}])\). We refer to the matrix \(W_{\ell}^{T}W_{\ell}\) as a _Convolutional Neural Feature Matrix_ (CNFM) and note that this matrix is proportional to the (uncentered) empirical covariance matrix of filters in layer \(\ell\).

We use the form of convolutional networks presented in Eq. (1) to state our Convolutional Neural Feature Ansatz (CNFA). Let \(G_{\ell}(x):=g_{\ell}(W_{\ell}h_{\ell-1}(x)[1,1],\ldots,W_{\ell}h_{\ell-1}(x)[P _{\ell-1},Q_{\ell-1}])\). Then, after training \(f\) for at least one epoch of (stochastic) gradient descent on standard loss functions:

\[W_{\ell}^{\top}W_{\ell}\propto\sum_{p=1}^{n}\sum_{(i,j)\in S} \nabla_{h_{\ell-1}(x)[i,j]}G_{\ell}(x)\left(\nabla_{h_{\ell-1}(x)[i,j]}G_{ \ell}(x)\right)^{\top}; \tag{2}\]

where \(S=\{(i,j)\}_{i\in[P_{\ell-1}],j\in[Q_{\ell-1}]}\) denotes the set of indices of patches utilized in the convolution operation in layer \(\ell\). The CNFA (Eq. 2) mathematically implies that the convolutional neural feature matrices are
proportional to the average gradient outer product (AGOP) with respect to the patches of the input to layer \(\ell\). The CNFA implies that the structure of covariance matrices of filters in convolutional networks, an object studied in prior work [49], corresponds to AGOP over patches. Intuitively, the CNFA implies that convolutional features are constructed by identifying and amplifying those pixels in any patch that most change the output of the network. We now present extensive empirical evidence corroborating our ansatz. We subsequently present supporting theoretical evidence.

### Empirical evidence for CNFA

We now provide empirical evidence for the ansatz by computing the correlation between CNFMs and the AGOP for each convolutional layer in various CNNs. We provide three lines of evidence by computing correlations for the following models: (1) AlexNet [27], all VGGs [46], and all ResNet [19] models pre-trained on ImageNet [40] ; (2) SimpleNet models [18] trained on SVHN [33], GTSRB [20], CIFAR10 [26], CIFAR100, and ImageNet32 [10]; and (3) shallow CNNs across 10 standard computer vision datasets from PyTorch upon varying pooling and patch size of convolution operations. The first set of experiments provides evidence for the ansatz in large-scale state-of-the-art models on ImageNet. The second set provides evidence for the ansatz across standard computer vision datasets. The last set provides evidence for the ansatz holding across architecture choices.

CNFA verification for pre-trained state-of-the-art models on ImageNet.

We begin by providing evidence for the ansatz on pre-trained state-of-the-art models on ImageNet. In Fig. 1, we present these correlations for AlexNet, all VGG models and all ResNet models pre-trained on ImageNet, which are available for download from the PyTorch library [36].4 As a control, we verify that weights at the end of training are far from initialization (see the red bars in Fig. 1A). Note that despite the complexity involved in training these models (e.g., batch normalization, skip connections, custom optimization procedures, data augmentation) the Pearson correlation between the AGOP and CNFMs are remarkably high (\(>.9\) for each layer of AlexNet and VGG13). In Fig. 1B, we additionally visualize the AGOP and CNFM for the first convolutional layer in AlexNet, VGG11, and ResNet18 to demonstrate the qualitative similarity between these matrices. In addition, in Appendix Fig. 7, we verify that these correlations are lower at initialization than at the end of training indicating that the ansatz is, in fact, a consequence of training.

Footnote 4: We evaluate all correlations between AGOP and CNFMs for all convolutional layers of AlexNet and all VGGs. To simplify computation on ResNets, we evaluate correlations between AGOP and CNFMs for the first layer in each BasicBlock and each Bottleneck, as defined in PyTorch. We note that for ResNet152, this computation involves computing correlation between matrices in 50 Bottleneck blocks.

CNFA verification for SimpleNet on CIFAR10, CIFAR100, ImageNet32, SVHN, GTSRB.To verify the ansatz on other datasets, we also trained the SimpleNet model on five datasets including

Figure 1: **A.** Correlation between initial CNFM and trained CNFM (red) and trained CNFM with AGOP (green) for convolutional layers in VGG, AlexNet, and ResNet on ImageNet (\(224\times 224\) resolution color images). **B.** Initial CNFM, trained CNFM, and AGOP matrices for the first convolutional layer of ResNet18, VGG11, and AlexNet on ImageNet.
CIFAR10/100, ImageNet32, SVHN, and GTSRB. We note SimpleNet had achieved state-of-the-art results on several of these tasks at the time of its release (e.g., \(>95\%\) test accuracy on CIFAR10). We train SimpleNet models using the same optimization procedure provided from [18] (i.e., Adadelta [57] with weight decay and manual learning rate scheduling). We use a small initialization scheme of normally distributed weights with a standard deviation of \(10^{-4}\) for convolutional layers. We note that we were able to recover high test accuracies across all datasets consistent with the results from [18] (see test accuracies for these trained SimpleNet models in Appendix Fig. 8). As shown in Appendix Fig. 8, we observe consistently high correlation between AGOPs and CNFMs across layers of SimpleNet.

CNFA is robust to hyperparameter choices.We lastly study the effect of patch size and architecture choices on the CNFA for networks trained using the Adam optimizer [25]. We generally observe that larger patch sizes slightly reduce the correlation between AGOP and CNFMs, and that max pooling layers (in contrast to no pooling or average pooling) lead to higher correlation (Appendix Fig. 9). Interestingly, these results indicate that the choices used in state-of-the-art CNNs (max pooling layers and patch size of 3) are consistent with those that lead to highest correlation between AGOP and CNFMs.

### Visualizing features captured by CNFM and AGOP

We now visualize how the CNFM operates on patches of images to select features and demonstrate that AGOP over patches captures similar features. Both the CNFM and AGOP yield an operator on patches of images. Thus, to visualize how these matrices select features, we expand input images into individual patches, then apply either the CNFM or the AGOP to each patch. We then reduce the expanded image back to its original size by taking the norm over the spatial dimensions of each expanded patch. Formally, the

Figure 2: Comparison of features extracted by CNFMs and AGOPs across layers of VGG11 and AlexNet for two input images. These visualizations provide further supporting evidence that the CNFMs and AGOPs of early layers are performing an operation akin to edge detection.
value for each coordinate \((i,j)\in P_{\ell-1}\times Q_{\ell-1}\) is replaced with \(\|M_{\ell}^{\frac{1}{2}}h_{\ell-1}(X)[i,j]\|\) where \(M_{\ell}:=W_{\ell}^{T}W_{\ell}\). Our visualization reflects the magnitude of the patch in the image of the patch transformation. For example, if \(M_{\ell}\) is an edge detector, then \(\|M_{\ell}^{\frac{1}{2}}h_{\ell-1}(X)[i,j]\|\) will be large, if and only if the patch centered at coordinate \((i,j)\) contains an edge.

This visualization technique emerges naturally from the convolution operation in CNNs, where a post-activation hidden unit is generated by applying a filter to each patch independently of the others. Further, this visualization characterizes how a trained CNN extracts features across patches of any image. This is in contrast to visualization techniques based on saliency maps [41, 44, 45, 59], which consider gradients with respect to an entire input image and for a single sample.

In addition to the high correlation between AGOP and CNFMs in the previous section, in Fig. 2, we observe that the AGOP and CNFMs transform input images similarly at any given layer of the CNN. For \(224\times 224\) images from ImageNet, CNFMs and AGOPs extracted from a pre-trained VGG11 model both emphasize objects and their edges in the image. We note these visualizations corroborate hypotheses from prior work that the first layer weights of deep CNNs learn an operator corresponding to edge detection [58]. Moreover, our results imply that the mathematical origin of edge detectors in convolutional neural networks is the average gradient outer product. In the following section, we will corroborate this claim by demonstrating that such edge detectors can be recovered without the use of any neural network through estimating the average gradient outer product of convolutional kernel machines.

### Supporting Theoretical Evidence for CNFA

The following theorem (proof in Appendix A) proves the ansatz for general convolutional networks after 1 step of full-batch gradient descent.

**Theorem 1**.: _Let \(f\) denote a function that operates on \(m\) patches of size \(q\), i.e., let \(f(v_{1},v_{2},\ldots,v_{m}):\mathbb{R}^{q}\times\ldots\times\mathbb{R}^{q} \rightarrow\mathbb{R}\) with \(f(v_{1},v_{2},\ldots,v_{m})=g(Wv_{1},Wv_{2},\ldots,Wv_{m})\) where \(W\in\mathbb{R}^{k\times q}\) and \(g(z_{1},\ldots,z_{m}):\mathbb{R}^{k}\times\ldots\times\mathbb{R}^{k} \rightarrow\mathbb{R}\). Assume \(g(\mathbf{0})=0\) and \(\frac{\partial g(\mathbf{0})}{\partial z_{\ell}}=\frac{\partial g(\mathbf{0} )}{\partial z_{\ell^{\prime}}}\neq 0\) for all \(\ell,\ell^{\prime}\in[m]\). If \(W\) is trained for one step of gradient descent with mean squared loss on data \(\{((v_{1}^{(p)},\ldots v_{m}^{(p)}),y_{p})\}_{p=1}^{n}\) from initialization \(W^{(0)}=\mathbf{0}\), then for the point \((u_{1},\ldots,u_{m})\):_

\[{W^{(1)}}^{T}W^{(1)}\propto\sum_{r=1}^{m}\frac{\partial f^{(1)}(u_{1},\ldots, u_{m})}{\partial v_{r}}\frac{\partial f^{(1)}(u_{1},\ldots,u_{m})}{\partial v _{r}}^{T}\;; \tag{3}\]

_where \(f^{(1)}(v_{1},v_{2},\ldots v_{m}):=g(W^{(1)}v_{1},W^{(1)}v_{2},\ldots,W^{(1)}v _{m})\)._

We note the assumptions of Theorem 1 hold for several types of convolutional networks. As a simple example, the assumptions hold for convolutional networks with activation function \(\phi\) satisfying \(\phi(0)=0\) and \(\phi^{\prime}(0)\neq 0\) (e.g., tanh activation) with remaining layers initialized as constant matrices. Furthermore, we note that while the above theorem is stated for the first layer of a convolutional network, the same proof strategy applies for deeper layers by considering the subnetwork \(G_{\ell}(x)\).

## 3 CNFA as a general mechanism for convolutional feature learning

We now show that the CNFA allows us to introduce a feature learning mechanism in any machine learning model on patches to capture features akin to those of convolutional networks. Given recent work connecting neural networks to kernel machines [22], we focus on convolutional kernels given by the Convolutional Neural Tangent Kernel (CNTK) [4] as our candidate model class. Intuitively, these models can be thought of as combining kernels evaluated across pairs of patches in images. While such models have achieved impressive performance [1, 6, 7, 29, 38, 42], these models do not automatically learn features from data unlike CNNs. Thus, as demonstrated in prior work [24, 52], there are tasks where CNTKs are significantly outperformed by corresponding CNNs.

A major consequence of the CNFA is that we can now enable feature learning in CNTKs by leveraging the AGOP over patches. In particular, we can first solve kernel regression with the CNTK and then use
the AGOP of the trained predictor over patches of images to learn features. We call our method the _Convolutional Recursive Feature Machine (ConvRFM)_, as it is the convolutional variant of the original RFM [37]. We will demonstrate that ConvRFM accurately captures first layer feature learning in CNNs and can recover edge detectors as features when trained on standard image classification datasets. To account for deep convolutional feature learning, we extend ConvRFM to Deep ConvRFMs by sequentially learning features in a manner similar to layerwise training in CNNs. We show that Deep ConvRFM: (1) improves performance of CNTKs on local signal adaptivity tasks considered in [24] ; and (2) improves performance of CNTKs on several image classification tasks.

### Convolutional Recursive Feature Machine (ConvRFM)

We present the algorithm for ConvRFM in Algorithm 1. The ConvRFM algorithm recursively learns a feature extractor on patches of a given image by implementing the AGOP across patches of training data. Namely, the ConvRFM first builds a predictor with a fixed convolutional kernel. Then, we compute the AGOP of the trained predictor with respect to image patches, which we denote as the _feature matrix_, \(M\). Lastly, we transform image patches with \(M\) and then repeat the previous steps. We provide a concrete example of this algorithm for the convolutional neural network Gausssian process (CNNGP) [9, 28] of a one hidden layer convolutional network with fully connected last layer operating on black and white images below.

The CNNGP of a one hidden layer convolutional network with fully connected last layer, activation \(\phi\), and filter size \(q\) is given by

\[K(x,z)=\frac{1}{PQ}\sum_{i=1}^{P}\sum_{j=1}^{Q}\check{\phi}(x[i,j]^{T}z[i,j], \|x[i,j]\|,\|z[i,j]\|)\ ;\]

where \(x,z\in\mathbb{R}^{P\times Q}\), \(x[i,j]\in\mathbb{R}^{q^{2}}\) denotes the vectorized \(q\times q\) patch of \(x\) centered at coordinate \((i,j)\), and \(\check{\phi}(a^{T}b,\|a\|,\|b\|)\) denotes the dual activation [15] of \(\phi\). For the case of ReLU activation, this dual activation has a well known form [9] and is given by

\[\check{\phi}(a^{T}b,\|a\|,\|b\|)=\frac{1}{\pi}\left(a^{T}b\left(\pi-\arccos \left(\frac{a^{T}b}{\|a\|\|b\|}\right)\right)+\sqrt{\|a\|^{2}\|b\|^{2}-a^{T}b} \right)\.\]

In ConvRFM, we modify the inner product in the kernel above to be a Mahalanobis inner product, constructing kernels of the form

\[K_{M}(x,z):=\frac{1}{PQ}\sum_{i=1}^{P}\sum_{j=1}^{Q}\check{\phi}(x[i,j]^{T}Mz [i,j],x[i,j]^{T}Mx[i,j],z[i,j]^{T}Mz[i,j])\ ;\]

where \(M\) is a learned positive semi-definite matrix. In particular, \(M\) is updated as the AGOP of the estimator constructed by solving kernel regression with \(K_{M}\). In our experiments, we analyze performance when replacing \(\check{\phi}\) with the Mahanolobis Laplace kernel used in [37] and with the CNTK of a deep convolutional ReLU network with fully connected last layer. We will make clear our choice of \(\check{\phi}\) by denoting our method as CNTK-ConvRFM or Laplace-ConvRFM.
ConvRFM captures first layer features of convolutional neural networks.We now demonstrate that ConvRFM recovers features similar to those learned by first layers of CNNs. In Fig. 3A, we visualize the top eigenvectors of the feature matrix of CNTK-ConvRFM (filter size \(3\times 3\)) and Laplace-ConvRFM (filter size \(7\times 7\)) trained on SVHN. Training details for all methods are presented in Appendix B. We observe that these top eigenvectors resemble edge detectors [16]. In Fig. 3B, we visualize how the feature matrix of the CNTK-ConvRFM and the CNFM of the corresponding finite width CNN trained on SVHN transform SVHN images. Even though both operators arise from vastly different training procedures (solving kernel regression vs. training a CNN), we observe that both operators appear to extract similar features (corresponding to edges of digits) from SVHN images. We provide additional evidence for similarity between ConvRFM and CNN features in Appendix Fig. 10. To demonstrate further evidence of the universality of edge detector features arising from AGOP of CNTK-ConvRFM and Laplace-ConvRFM, we analyze how these AGOPs transform arbitrary images. In particular, in Fig. 3C, we apply these operators extracted from models trained on SVHN to images on ImageNet. We again observe that these operators remarkably extract edges from corresponding ImageNet images, which are of vastly different resolution (\(224\times 224\) instead of \(32\times 32\)) and contain vastly different objects. Such experiments provide conclusive evidence that AGOP with respect to patches of convolutional kernels recovers features akin to edge detectors. We present further experiments demonstrating emergence of edge detectors from convolutional kernels trained on CIFAR10 and GTSRB in Appendix Figs. 11 and 12. In particular, the eigenvectors of the AGOP often resemble Gabor filters with different orientations. In Figure 11, we see that horizontally, vertically, and diagonally aligned eigenvectors identify edges of the same alignment.

### Deep feature learning with Deep ConvRFM

ConvRFM is capable of only extracting features by linearly transforming patches of input images, which is analogous to extracting such features using the first layer of a CNN. In contrast, the CNFA implies that deep convolutional networks are capable of learning features in intermediate layers. To enable deep feature learning, we introduce Deep ConvRFM (see Algorithm 2) by sequentially learning features with AGOP in a manner similar to layerwise training in CNNs. In particular, Deep ConvRFM iterates the following steps:

1. Construct a predictor, \(\widehat{f}\), by training a convolutional kernel machine with kernel \(K_{M}\).

Figure 3: Features extractors learned by ConvRFM using CNTK (CNTK-ConvRFM) and Laplace kernel (Laplace-ConvRFM), which appear to operate as universal edge detectors. **A.** Top 8 eigenvectors of CNTK-ConvRFM and Laplace-ConvRFM trained on SVHN. We use \(3\times 3\) patches for CNTK-ConvRFM and \(7\times 7\) patches for Laplace-ConvRFM. **B.** Comparison of patch operators learned by CNTK-ConvRFM (given by the AGOP taken with respect to patches) and CNNs (given by the CNFM). **C.** Applying patch-based AGOP operators from ConvRFMs trained on SVHN to images from ImageNet.
2. Update \(M\) to be the AGOP with respect to patches of the trained predictor.
3. Transform the data, \(x\), with random features given by \(\phi(Wx)\) where \(W\) denotes a set of convolutional filters with weights sampled according to \(\mathcal{N}(0,M)\) and \(\phi\) is a nonlinearity.

Note that while we utilize random features and sample convolutional filters in Deep ConvRFM, we never utilize backpropgation to learn features or train models. Features are learned via the AGOP and models are trained by solving kernel regression, which is a convex optimization problem. For the base kernel for Deep ConvRFM, we utilize the deep CNTK [4] as implemented in the Neural Tangents library [34].5

Footnote 5: In order to take gradient with respect to patches using Neural Tangents, we used a workaround that involved expanding images into their patch representations. This workaround unfortunately leads to heavy memory utilization, which limited our analysis of Deep ConvRFMs.

Deep ConvRFM learns similar features to deep CNNs.We now present evidence that Deep ConvRFMs learn similar features to those learned by deep CNNs. We analyze features learned by deep ConvRFM and the corresponding CNN on the local signal adaptivity synthetic tasks from [24] and SVHN. For the synthetic task from [24], we consider classification of MNIST digits embedded in a larger image of i.i.d. Gaussian noise. Dataset and training details are presented in Appendix B. In Fig. 4, we observe that AGOPs at each layer of Deep ConvRFM and and CNFMs at each layer of the corresponding CNN transform examples from both datasets similarly.

Figure 4: Visualizations of features for each layer of Deep ConvRFM and the corresponding CNN on SVHN and the noisy digits task from [24].
Deep ConvRFM overcomes limitations of convolutional kernels.In the work [24] the authors posited local signal adaptivity, the ability to suppress noise and amplify signal in images, as a potential explanation for the superiority of convolutional neural networks over convolutional kernels. As supporting evidence, [24] demonstrated that convolutional networks generalized far better than convolutional kernels on image classification tasks in which images were embedded in a noisy background. We now demonstrate that by incorporating feature learning through patch-AGOPs, Deep ConvRFM exhibits local signal adaptivity on the tasks considered in [24] and thus, similar to CNNs, yield significantly improved performance over convolutional kernels. In particular, we begin by comparing performance of CNTK, Conv RFM, Deep ConvRFM, and corresponding CNNs on the following two image classification tasks from [24]: (1) images of black and white horizontal bars placed in a random position on larger images of Gaussian noise ; (2) MNIST images placed in a random position on larger images of Gausssian noise. The work [24] demonstrated that CNNs, unlike CNTK, could learn to threshold the background noise and amplify the signal in these tasks thus far outperforming CNTKs when the amount of background noise was large. In Fig. 5, we demonstrate that for these tasks CNNs, ConvRFMs, and Deep ConvRFMs all extract local signals and dim background noise through the AGOP, and thus far outperform CNTKs. Moreover, we observe that Deep ConvRFMs can provide up to a 5% improvement in performance over ConvRFM on the synthetic MNIST task, indicating a benefit to deep feature learning.

Benefit of deep feature learning on real-world image classification tasks.Lastly, we analyze performance of CNTK, ConvRFM, Deep ConvRFM, and the corresponding three convolutional layer CNN on standard image classification datasets available for download from PyTorch. Consistent with our observations for synthetic tasks from [24], we observe in Fig. 6A that ConvRFM and Deep ConvRFM provide an improvement over CNTK across almost all tasks. Moreover, we observe that ConvRFM and Deep ConvRFM outperform CNTKs consistently when the corresponding CNN outperforms the CNTK. In Fig. 6B, we analyze the impact of deep feature learning by increasing the number of feature learning layers in Deep ConvRFM, i.e., the number of layers for which we utilize the AGOP to learn features. We observe that adding more layers of feature learning leads to consistent performance boost in the local signal adaptivity tasks from [24] and on select datasets such as SVHN and EMNIST [13].

## 4 Discussion

In this work, we identified a mathematical mechanism of feature learning in deep convolutional networks, which we posited as the Convolutional Neural Feature Ansatz (CNFA). Namely, the ansatz stated that features selected by convolutional networks, given by empirical covariance matrices of filters at any given layer, can be recovered by computing the average gradient outer product (AGOP) of the trained network

Figure 5: Test accuracy of CNTK, ConvRFM, Deep ConvRFM, and the corresponding CNN on local signal adaptivity tasks from [24] as a function of noise level. **A.** Identifying black and white bars in noisy images. **B.** MNIST digits placed randomly in noisy background image.
with respect to image patches. We presented empirical and theoretical evidence for the ansatz. Notably, we showed that convolutional filter covariances of neural networks pre-trained on ImageNet (AlexNet, VGG, ResNet) are highly correlated with AGOP with respect to patches (in many cases, Pearson correlation \(>.9\)). Since the AGOP with respect to patches can be computed on any function operating on image patches, we could use the AGOP to enable feature learning in any machine learning model operating on image patches. Thus, building on the RFM algorithm for fully connected networks from [37], we integrated the AGOP to enable deep feature learning in convolutional kernel machines, which could not apriori learn features, and referred to the resulting algorithms as ConvRFM and Deep ConvRFM. We demonstrated that ConvRFM and Deep ConvRFM recover features similar to those of deep convolutional neural networks, including evidence that features learned by these models can serve as universal edge detectors, akin to features learned in convolutional networks. Moreover, we demonstrated that ConvRFM and Deep ConvRFM overcome prior limitations of convolutional kernels, including the Convolutional Neural Tangent Kernel (CNTK), such the inability to adapt to localized signals in images [24]. Lastly, we showed a benefit to deep feature learning by demonstrating improvement in performance of Deep ConvRFM over ConvRFM and the CNTK on standard image classification benchmarks. We now conclude with a discussion of implications of our results and future directions.

Identifying mechanisms driving success of deep learning.Understanding the mechanisms driving success of neural networks is an important problem for developing effective, interpretable and safe machine learning models. The complexities of training deep neural networks such as custom training procedures and layer structures (batch normalization, dropout, residual connections, etc.) can make it difficult to pinpoint overarching principles leading to effectiveness of these models. The fact that correlation between convolutional neural feature matrices (CNFMs) and AGOPs is high for convolutional networks pre-trained on ImageNet with all of these inherent complexities baked in, provides strong evidence that the connection between AGOP and CNFMs is key to identifying the core principles making these networks successful.

Emergence of universal edge detectors with average gradient outer product.Detecting edges in images is a well-studied task in computer vision and classical approaches involved applying fixed convolutional filters to detect edges in images [2, 16, 54]. For example, AlexNet automatically learned filters in its first convolutional layer that were remarkably similar to Gabor filters [30]. Similarly, there was evidence that other convolutional networks pre-trained on ImageNet learned features akin to edge detection in the first layer [58]. Yet, it had been unclear how such filters automatically emerge through training. We demonstrated that the AGOP with respect to patches of a large class of convolutional models (convolutional neural networks and convolutional kernels) trained on various standard image classification tasks consistently recovered edge detectors (see Fig. 2, Fig. 3A, B). We further showed the universality of these edge detector features by demonstrating that features learned by ConvRFM on SVHN automatically identified edges in ImageNet

Figure 6: **A. Performance comparison of Deep ConvRFM with the corresponding CNTK and CNN on benchmark image classification datasets from PyTorch. B. Effect of number of feature learning layers on Deep ConvRFM performance.**
images. This strongly suggests that edge detectors emerge from the underlying nature of the task rather than specific properties of architectures. Our findings indicate that understanding connections between AGOP and classical edge detection approaches is a promising direction for understanding emergence of features in the first layer of convolutional neural networks and for identifying simple algorithms to capture deeper convolutional features.

Reducing computational complexity of convolutional kernels.In this work, we provided an approach for enabling feature learning in convolutional kernels by iteratively training convolutional kernel machines and computing AGOP of the trained predictor. Given that convolutional kernels are able to achieve impressive accuracy on standard datasets without any feature learning [1, 6, 7, 29, 42], these methods have the potential to provide state-of-the-art results upon incorporating feature learning. Yet, in contrast to the case of classical kernel machines such as those used in [37], evaluating the kernel for an effective CNTK (such as those with Global Average Pooling [4]) can be a far more computationally intensive process than simply training a convolutional neural network. For example, according to Neural Tangents [34], the CNTK of a Myrtle kernel [42] can take anywhere from 300 to 500 GPU hours for CIFAR10. Given that Deep ConvRFM involves constructing a kernel matrix and computing AGOP to capture features at each layer, reducing the evaluation time of convolutional kernels through strategies such as random feature approximations is key to making these approaches scalable.

## Acknowledgements

A.R. is supported by the Eric and Wendy Schmidt Center at the Broad Institute. We acknowledge support from the National Science Foundation (NSF) and the Simons Foundation for the Collaboration on the Theoretical Foundations of Deep Learning6 through awards DMS-2031883 and #814639 as well as the TILOS institute (NSF CCF-2112665). This work used the programs (1) XSEDE (Extreme science and engineering discovery environment) which is supported by NSF grant numbers ACI-1548562, and (2) ACCESS (Advanced cyberinfrastructure coordination ecosystem: services & support) which is supported by NSF grants numbers #2138259, #2138286, #2138307, #2137603, and #2138296. Specifically, we used the resources from SDSC Expanse GPU compute nodes, and NCSA Delta system, via allocations TG-CIS220009.

Footnote 6: [https://deepfoundations.ai/](https://deepfoundations.ai/)

## Code Availability

All code is available at [https://github.com/aradha/convrfm](https://github.com/aradha/convrfm).
