Enhanced Convolutional Neural Tangent Kernels
Zhiyuan Li, Ruosong Wang, Dingli Yu, Simon S. Du, Wei Hu, Ruslan Salakhutdinov, Sanjeev Arora
Introduction
While this performance is encouraging for a fixed kernel, the best accuracy is still under , which is disappointing even compared to AlexNet. One hope for improving the accuracy further is to somehow capture modern innovations such as batch normalization, data augmentation, residual layers, etc. in CNTK. The current paper shows how to incorporate simple data augmentation. Specifically, the idea of creating new training images from existing images using pixel translation and flips, while assuming that these operations should not change the label. Since deep learning uses stochastic gradient descent (SGD), it is trivial to do such data augmentation on the fly. However, it’s unclear how to efficiently incorporate data augmentation in kernel regression, since training time is quadratic in the number of training images.
Thus somehow data augmentation has to be incorporated into the computation of the kernel itself. The main observation here is that the above-mentioned algorithm for computing CNTK involves a dynamic programming whose recursion depth is equal to the depth of the corresponding finite CNN. It is possible to impose symmetry constraints at any desired layer during this computation. In this viewpoint, it can be shown that prediction using CNTK/CNN-GP with GAP is equivalent to prediction using CNTK/CNN-GP without GAP but with full translation data augmentation with wrap-around at the boundary. The translation invariance property implicitly assumed in data augmentation is exactly equivalent to an imposed symmetry constraint in the computation of the CNTK which in turn is derived from the pooling layer in the CNN. See Section 4 for more details.
Thus GAP corresponds to full translation data augmentation scheme, but in practice such data augmentation creates unrealistic images (cf. Figure 1) and training on them can harm performance. However, the idea of incorporating symmetry in the dynamic programming leads to a variant we call Local Average Pooling (LAP). This implicitly is like data augmentation where image labels are assumed to be invariant to small translation, say by a few pixels. This operation also suggests a new pooling layer for CNNs which we call BBlur and also find it beneficial for CNNs in experiments.
Experimentally, we find LAP significantly enhances the performance as discussed below.
In extensive experiments on CIFAR-10 and Fashion-MNIST, we find that LAP consistently improves performance of CNN-GP and CNTK. In particular, we find CNN-GP with LAP achieves on CIFAR-10 dataset, outperforming the best previous kernel predictor by .
When using the technique proposed by Coates et al. (2011), which uses randomly sampled patches from training data as filters to do pre-processing,See Section 6.2 for the precise procedure. CNN-GP with LAP and horizontal flip data augmentation achieves accuracy on CIFAR-10, matching the performance of AlexNet (Krizhevsky et al., 2012) and is the strongest classifier that is not a trained neural network. https://benchmarks.ai/cifar-10
We also derive a layer for CNN that corresponds to LAP and observe that it improves the performance on certain architectures.
Related Work
Data augmentation has long been known to improve the performance of neural networks and kernel methods (Sietsma and Dow, 1991; Schölkopf et al., 1996). Theoretical study of data augmentation dates back to Chapelle et al. (2001). Recently, Dao et al. (2018) proposed a theoretical framework for understanding data augmentation and showed data augmentation with a kernel classifier can have feature averaging and variance regularization effects. More recently, Chen et al. (2019) quantitatively shows in certain settings, data augmentation provably improves the classifier performance. For more comprehensive discussion on data augmentation and its properties, we refer readers to Dao et al. (2018); Chen et al. (2019) and references therein.
CNN-GP and CNTK correspond to infinitely wide CNN with different training strategies (only training the top layer or training all layers jointly). The correspondence between infinite neural networks and kernel machines was first noted by Neal (1996). More recently, this was extended to deep and convolutional neural networks (Lee et al., 2018; Matthews et al., 2018; Novak et al., 2019; Garriga-Alonso et al., 2019). These kernels correspond to neural networks where only the last layer is trained. A recent line of work studied overparameterized neural networks where all layers are trained (Allen-Zhu et al., 2018; Du et al., 2019b, 2018; Li and Liang, 2018; Zou et al., 2018). Their proofs imply the gradient kernel is close to a fixed kernel which only depends the training data and the neural network architecture. These kernels thus correspond to neural networks where are all layers are trained. Jacot et al. (2018) named this kernel neural tangent kernel (NTK). Arora et al. (2019) formally proved polynomially wide neural net predictor trained by gradient descent is equivalent to NTK predictor. Recently, NTKs induced by various neural network architectures are derived and shown to achieve strong empirical performance (Arora et al., 2019; Yang, 2019; Du et al., 2019a).
Global Average Pooling (GAP) is first proposed in Lin et al. (2013) and is common in modern CNN design (Springenberg et al., 2014; He et al., 2016; Huang et al., 2017). However, current theoretical understanding on GAP is still rather limited. It has been conjectured in Lin et al. (2013) that GAP reduces the number of parameters in the last fully-connected layer and thus avoids overfitting, and GAP is more robust to spatial translations of the input since it sums out the spatial information. In this work, we study GAP from the CNN-GP and CNTK perspective, and draw an interesting connection between GAP and data augmentation.
The approach proposed in Coates et al. (2011) is one of the best-performing approaches on CIFAR-10 preceding modern CNNs. In this work we combine CNTK with LAP and the approach in Coates et al. (2011) to achieve the best performance for classifiers that are not trained neural networks.
Preliminaries
2 CNN, CNN-GP and CNTK
CNN.
Without GAP: the final output is defined as
CNN-GP and CNTK.
Kernel Prediction.
3 Data Augmentation Schemes
In this paper we consider two types of data augmentation schemes: translation and horizontal flip.
for . Here the precise definition of depends on the padding scheme. Given a dataset , the full translation data augmentation scheme creates a new dataset and training is performed on .
Horizontal Flip.
for . Given a dataset , the horizontal flip data augmentation scheme creates a new dataset of the form and training is performed on .
Equivalence Between Augmented Kernel and Data Augmentation
In this section, we demonstrate the equivalence between data augmentation and augmented kernels. To formally discuss the equivalence, we use group theory to describe translation and horizontal flip operators. We provide the definition of group in Section B for completeness.
It is easy to verify that , , are groups, where is the identity map. From now on, given a dataset with data and a group , the augmented dataset is defined to be . The prediction for an unseen data on the augmented dataset is where
To proceed, we define the concept of augmented kernel. Let be a finite group. Define the augmented kernel as
where are two inputs images and is drawn from uniformly at random. A key observation is that for CNTK and CNN-GP, when circular padding and GAP is adopted, the corresponding kernel is the augmented kernel of the group . Formally, we have
which can be seen by checking the formula of these kernels and using definition of circular padding. Similarly, the following equivariance property holds for and , under all groups mentioned above, including and .
A kernel is equivariant under a group if and only if for any , .
The following theorem formally states the equivalence between using an augmented kernel on the dataset and using the kernel on the augmented dataset.
The proof is deferred to Appendix B. Theorem 4.1 implies the following two corollaries.
For , for any given dataset , the prediction of (or ) with dataset is equal to the prediction of (or ) with augmented dataset .
For , for any given dataset , the prediction of (or ) with dataset is equal to the prediction of (or ) with augmented dataset .
Now we discuss implications of Theorem 4.1 and its corollaries. Naively applying data augmentation, with full translation on CNTK or CNN-GP for example, one needs to create a much larger kernel matrix since there are translation operators, which is often computationally infeasible. Instead, one can directly use the augmented kernel ( or for the case of full translation on CNTK or CNN-GP) for prediction, for which one only needs to create a kernel matrix that is as large as the original one. For horizontal flip, although the augmentation kernel can not be conveniently computed as full translation, Corollary 4.2 still provides a more efficient method for computing kernel values and solving kernel regression, since the augmented dataset is twice as large as the original dataset, while the kernel matrix of the augmented kernel is as large as the original one.
Local Average Pooling
In this section, we introduce a new operation called Local Average Pooling (LAP). As discussed in the introduction, full translation data augmentation may create unrealistic images. A natural idea is to do local translation data augmentation, i.e., restricting the distance of translation. More specifically, we only allow translation operations (cf. Section 3.3) for where is a parameter to control the amount of allowed translation. With a proper choice of the parameter , translation data augmentation will not create unrealistic images (cf. Figure 1). However, naive local translation data augmentation is computationally infeasible for kernel methods, even for moderate choice of . To remedy this issue, in this section we introduce LAP, which is inspired by the connection between full translation data augmentation and GAP on CNN-GP and CNTK. Here, for simplicity, we assume and derive the formula only for CNTK. Our formula can be generalized to CNN-GP in a straightforward manner.
With circular padding, the formula can be rewritten as
We ignore the scaling factor since it plays no role in kernel regression.
Now we consider restricted translation operations with and derive the formula for LAP. Assuming circular padding, we have
Now we have derived the formula for LAP, which is the RHS of Equation 1. Notice that the formula in the RHS of Equation 1 is a well-defined quantity for all padding schemes. In particular, assuming zero padding, when , LAP is equivalent to GAP. When , LAP is equivalent to no pooling layer. Another advantage of LAP is that it does not incur any extra computational cost, since the formula in Equation 1 can be rewritten as
where each entry in the weight tensor can be calculated in constant time.
This is in fact the standard average pooling layer with pooling size and stride . We prove the equivalence between LAP and box blur layer in Appendix C. In Section 6.3, we verify the effectiveness of BBlur on CNNs via experiments.
Experiments
In this section we present our empirical findings on CIFAR-10 (Krizhevsky, 2009) and Fashion-MNIST (Xiao et al., 2017).
For both CIFAR-10 and Fashion-MNIST we use the full training set and report the test accuracy on the full test set. Throughout this section we only consider convolutional filters with stride and no dilation. In the convolutional layers in CNTK and CNN-GP, we use zero padding with pad size to ensure the input of each layer has the same size. We use zero padding for LAP throughout the experiment. We perform standard preprocessing (mean subtraction and standard deviation division) for all images.
In all experiments, we perform kernel ridge regression to utilize the calculated kernel valuesWe also tried kernel SVM but found it significantly degrading the performance, and thus do not include the results.. We normalize the kernel matrices so that all diagonal entries are ones. Equivalently, we ensure all features have unit norm in RKHS. Since the resulting kernel matrices are usually ill-conditioned, we set the regularization term , to make inverting kernel matrices numerically stable. We use one-hot encodings of the labels as regression targets. We use scipy.linalg.solve to solve the corresponding kernel ridge regression problem.
The kernel value of CNTK and CNN-GP are calculated using the CuPy package. We write native CUDA codes to speed up the calculation of the kernel values. All experiments are performed on Amazon Web Services (AWS), using (possibly multiple) NVIDIA Tesla V100 GPUs. For efficiency considerations, all kernel values are computed with 32-bit precision.
One unique advantage of the dynamic programming algorithm for calculating CNTK and CNN-GP is that we do not need repeat experiments for, say, different values of in LAP and different depths. With our highly-optimized native CUDA codes, we spend roughly 1,000 GPU hours on calculating all kernel values for each dataset.
1 Ablation Study on CIFAR-10 and Fashion-MNIST
We perform experiments to study the effect of different values of the parameter in LAP and horizontal flip data argumentation on CNTK and CNN-GP. For experiments in this section we set the bias term in CNTK and CNN-GP to be (cf. Section A). We use the same architecture for CNTK and CNN-GP as in Arora et al. (2019). I.e., we stack multiple convolutional layers before the final pooling layer. We use to denote the number of convolutions layers, and in our experiments we set to be , , or , to study the effect of depth on CNTK and CNN-GP. For CIFAR-10, we set the parameter in LAP to be , while for Fashion-MNIST we set the parameter in LAP to be . Notice that when for CIFAR-10 or for Fashion-MNIST, LAP is equivalent to GAP, and when , LAP is equivalent to no pooling layer. Results on CIFAR-10 are reported in Tables 1 and 2, and results on Fashion-MNIST are reported in Tables 3 and 4. In each table, for each combination of and , the first number is the test accuracy without horizontal flip data augmentation (in percentage), and the second number (in parentheses) is the test accuracy with horizontal flip data augmentation.
We made the following observations regarding our experimental results.
LAP with a proper choice of the parameter significantly improves the performance of CNTK and CNN-GP. On CIFAR-10, the best-performing value of is or , while on Fashion-MNIST the best-performing value of is . We suspect this difference is due to the nature of the two datasets: CIFAR-10 contains real-life images and thus allow more translation, while Fashion-MNIST contains images with centered clothes and thus allow less translation. For both datasets, the best-performing value of is consistent across all settings (depth, CNTK or CNN-GP) that we have considered.
Horizontal flip data augmentation is less effective on Fashion-MNIST than on CIFAR-10. There are two possible explanations for this phenomenon. First, most images in Fashion-MNIST are nearly horizontally symmetric (e.g., T-shirts and bags). Second, CNTK and CNN-GP have already achieved a relatively high accuracy on Fashion-MNIST, and thus it is reasonable for horizontal flip data augmentation to be less effective on this dataset.
Finally, for CNTK, when (no pooling layer) and (GAP) our reported test accuracies are close to those in Arora et al. (2019) on CIFAR-10. For CNN-GP, when (no pooling layer) our reported test accuracies are close to those in Novak et al. (2019) on CIFAR-10 and Fashion-MNIST. This suggests that we have reproduced previous reported results.
2 Improving Performance on CIFAR-10 via Additional Pre-processing
From our experimental results, it is evident that combining CNTK or CNN-GP with additional pre-processing can significantly improve upon the performance of using solely CNTK or CNN-GP, and that of using solely the approach in Coates et al. (2011). Previously, it has been reported in Recht et al. (2019) that using solely the approach in Coates et al. (2011) (together with appropriate pooling layer) can only achieve a test accuracy of 84.2% using 256, 000 image patches, or 83.3% using 32, 000 image patches. Even with the help of horizontal flip data augmentation, the approach in Coates et al. (2011) can only achieve a test accuracy of 85.6% using 256, 000 image patches, or 85.0% using 32, 000 image patches. Here we use significantly less image patches (only 2048) but achieve a much better performance, with the help of CNTK and CNN-GP. In particular, we achieve a performance of 88.92% on CIFAR-10, matching the performance of AlexNet on the same dataset. In the setting reported in Coates et al. (2011), increasing the number of sampled image patches will further improve the performance. Here we also conjecture that in our setting, further increasing the number of sampled image patches can improve the performance and get close to modern CNNs. However, due the limitation on computational resources, we leave exploring the effect of number of sampled image patches as a future research direction.
3 Experiments on CNN with BBlur
In Figure 2, we verify the effectiveness of BBlur on a 10-layer CNN (with Batch Normalization) on CIFAR-10. The setting of this experiment is reported in Appendix D. Our network structure has no pooling layer except for the BBlur layer before the final fully-connected layer. The fully-connected layer is fixed during the training. Our experiment illustrates that even with a fixed final FC layer, using GAP could improve the performance of CNN, and challenges the conjecture that GAP reduces the number of parameters in the last fully-connected layer and thus avoids overfitting. Our experiments also show that BBlur with appropriate choice of achieves better performance than GAP.
Conclusion
In this paper, inspired by the connection between full translation data augmentation and GAP, we derive a new operation, LAP, on CNTK and CNN-GP, which consistently improves the performance on image classification tasks. Combining CNN-GP with LAP and the pre-processing technique proposed by Coates et al. (2011), the resulting kernel achieves 89% accuracy on CIFAR-10, matching the performance of AlexNet and is the strongest classifier that is not a trained neural network.
Here we list a few future research directions. Is that possible to combine more modern techniques on CNN, such as batch normalization and residual layers, with CNTK or CNN-GP, to further improve the performance? Moreover, it is an interesting direction to study other components in modern CNNs through the lens of CNTK and CNN-GP.
Acknowledgements
S. Arora, W. Hu, Z. Li and D. Yu are supported by NSF, ONR, Simons Foundation, Schmidt Foundation, Amazon Research, DARPA and SRC. S. S. Du is supported by National Science Foundation (Grant No. DMS-1638352) and the Infosys Membership. R. Salakhutdinov and R. Wang are supported in part by NSF IIS-1763562, Office of Naval Research grant N000141812861, and Nvidia NVAIL award. Part of this work was done while R. Wang was visiting Princeton University. The authors would like to thank Amazon Web Services for providing compute time for the experiments in this paper.
References
Appendix A Formal Definitions of CNN, CNN-GP and CNTK
Here the precise definition of and depends on the padding scheme (cf. Section 3.2). Notice that in Equation 2, the value of depends on . Thus, for , we define
Now we formally define CNN, CNN-GP and CNTK.
For , , the intermediate outputs are defined as
CNN-GP and CNTK.
For , , define
For , define
For , define
For , define
Note that the definition of and share similar patterns as their NTK counterparts [Jacot et al., 2018]. The only difference is that we have one more step, taking the trace over patches. This step represents the convolution operation in the corresponding CNN. Now we can define the kernel value recursively.
First, we define .
For and , we define
Appendix B Additional Definitions and Proof of Theorem 4.1
is a group of operators, if and only if
, where is defined as .
, such that , .
, , such that . We say is the inverse of , namely, .
By the equivariance of under , for all and ,
Note that is defined as the unique solution of .
Appendix C Equivalence Between LAP and Box Blur Layer.
By the formula of the output kernel value for CNTK without GAP, we obtain
Appendix D Setting of the Experiment in Section 6.3
The total number of training epochs is 80, and the learning rate is 0.1 initially, decayed by 10 at epoch 40 and 60 respectively. The momentum is 0.9 and the weight decay factor is 0.0005. In Figure 2, the blue line reports the average test accuracy of the last 10 epochs, while the red line reports the best test accuracy of the total 80 epochs. Each experiment is repeated for 3 times. We use circular padding for both convolutional layers and the BBlur layer. The last data point with largest -coordinate reported in Figure 2 corresponds to GAP.