The Recurrent Neural Tangent Kernel

Sina Alemohammad, Zichao Wang, Randall Balestriero, Richard Baraniuk

Introduction

The overparameterization of modern deep neural networks (DNNs) has resulted in not only remarkably good generalization performance on unseen data but also guarantees that gradient descent learning can find the global minimum of their highly nonconvex loss functions . From these successes, a natural question arises: What happens when we take overparameterization to the limit by allowing the width of a DNN’s hidden layers to go to infinity? Surprisingly, the analysis of such an (impractical) DNN becomes analytically tractable. Indeed, recent work has shown that the training dynamics of (infinite-width) DNNs under gradient flow is captured by a constant kernel called the Neural Tangent Kernel (NTK) that evolves according to a linear ordinary differential equation (ODE) .

Every DNN architecture and parameter initialization produces a distinct NTK. The original NTK was derived from the Multilayer Perceptron (MLP) and was soon followed by kernels derived from Convolutional Neural Networks (CNTK) , Residual DNNs , and Graph Convolutional Neural Networks (GNTK) . In , a general strategy to obtain the NTK of any architecture is provided.

In this paper, we extend the NTK concept to the important class of overparametrized Recurrent Neural Networks (RNNs), a fundamental DNN architecture for processing sequential data. We show that RNN in its infinite-width limit converges to a kernel that we dub the Recurrent Neural Tangent Kernel (RNTK). The RNTK provides high performance for various machine learning tasks, and an analysis of the properties of the kernel provides useful insights into the behavior of RNNs in the following overparametrized regime. In particular, we derive and study the RNTK to answer the following theoretical questions:

Q: Can the RNTK extract long-term dependencies between two data sequences? RNNs are known to underperform at learning long-term dependencies due to the gradient vanishing or exploding . Attempted ameliorations have included orthogonal weights and gating such as in Long Short-Term Memory (LSTM) and Gated Recurrent Unit (GRU) RNNs. We demonstrate that the RNTK can detect long-term dependencies with proper initialization of the hyperparameters, and moreover, we show how the dependencies are extracted through time via different hyperparameter choices.

Q: Do the recurrent weights of the RNTK reduce its representation power compared to other NTKs? An attractive property of an RNN that is shared by the RNTK is that it can deal with sequences of different lengths via weight sharing through time. This enables the reduction of the number of learnable parameters and thus more stable training at the cost of reduced representation power. We prove the surprising fact that employing tied vs. untied weights in an RNN does not impact the analytical form of the RNTK.

Q: Does the RNTK generalize well? A recent study has revealed that the use of an SVM classifier with the NTK, CNTK, and GNTK kernels outperforms other classical kernel-based classifiers and trained finite DNNs on small data sets (typically fewer than 5000 training samples) . We extend these results to RNTKs to demonstrate that the RNTK outperforms a variety of classic kernels, NTKs and finite RNNs for time series data sets in both classification and regression tasks. Carefully designed experiments with data of varying lengths demonstrate that the RNTK’s performance accelerates beyond other techniques as the difference in lengths increases. Those results extend the empirical observations from into finite DNNs, NTK, CNTK, and GNTK comparisons by observing that their performance-wise ranking depends on the employed DNN architecture.

We summarize our contributions as follows:

[C1] We derive the analytical form for the RNTK of an overparametrized RNN at initialization using rectified linear unit (ReLU) and error function (erf) nonlinearities for arbitrary data lengths and number of layers (Section 3.1).

[C2] We prove that the RNTK remains constant during (overparametrized) RNN training and that the dynamics of training are simplified to a set of ordinary differential equations (ODEs) (Section 3.2).

[C3] When the input data sequences are of equal length, we show that the RNTKs of weight-tied and weight-untied RNNs converge to the same RNTK (Section 3.3).

[C4] Leveraging our analytical formulation of the RNTK, we empirically demonstrate how correlations between data at different times are weighted by the function learned by an RNN for different sets of hyperparameters. We also offer practical suggestions for choosing the RNN hyperparameters for deep information propagation through time (Section 3.4).

[C5] We demonstrate that the RNTK is eminently practical by showing its superiority over classical kernels, NTKs, and finite RNNs in exhaustive experiments on time-series classification and regression with both synthetic and 56 real-world data sets (Section 4).

Background and Related Work

The output of an LL-hidden layer RNN with linear read out layer is achieved via

Generally, Θ^s(x,x′)\widehat{\Theta}_{s}({\bm{x}},{\bm{x}}^{\prime}), hereafter referred to as the empirical NTK, changes over time during training, making the analysis of the training dynamics difficult. When fθsf_{\theta_{s}} corresponds to an infinite-width MLP, showed that Θ^s(x,x′)\widehat{\Theta}_{s}({\bm{x}},{\bm{x}}^{\prime}) converges to a limiting kernel at initialization and stays constant during training, i.e.,

which is equivalent to replacing the outputs of the DNN by their first-order Taylor expansion in the parameter space . With a mean-square error (MSE) loss function, the training dynamics in (1) and (2) simplify to a set of linear ODEs, which coincides with the training dynamics of kernel ridge regression with respect to the NTK when the ridge term goes to zero. A nonzero ridge regularization can be conjured up by adding a regularization term λ22∥θs−θ0∥22\frac{\lambda^{2}}{2}\|\theta_{s}-\theta_{0}\|_{2}^{2} to the empirical loss .

The Recurrent Neural Tangent Kernel

We are now ready to derive the RNTK. We first prove the convergence of an RNN at initialization to the RNTK in the infinite-width limit and discuss various insights it provides. We then derive the convergence of an RNN after training to the RNTK. Finally, we analyze the effects of various hyperparameter choices on the RNTK. Proofs of all of our results are provided in the Appendices.

First we specify the following parameter initialization scheme that follows previous work on NTKs , which is crucial to our convergence results:

The derivation of the RNTK at initialization is based on the correspondence between Gaussian initialized, infinite-width DNNs and Gaussian Processes (GPs), known as the DNN-GP. In this setting every coordinate of the DNN output tends to a GP as the number of units/neurons in the hidden layer (its width) goes to infinity. The corresponding DNN-GP kernel is computed as

Both convergences occur independently of the coordinate index ii and for inputs of possibly different lengths, i.e., T≠T′T\neq T^{\prime}. With (6) and (7), we now prove that an infinite-width RNN at initialization converges to the limiting RNTK.

Let x{\bm{x}} and x′{\bm{x}}^{\prime} be two data sequences of potentially different lengths TT and T′T^{\prime}, respectively. Without loss of generality, assume that T≤T′T\leq T^{\prime}, and let τ:=T′−T\tau:=T^{\prime}-T. Let nn be the number of units in the hidden layers, the empirical RNTK for an LL-layer RNN with NTK initialization converges to the following limiting kernel as n→∞n\rightarrow\infty

Remarks. Theorem 1 holds generally for any two data sequences, including different lengths ones. This highlights the RNTK’s ability to produce a similarity measure Θ(x,x′)\Theta({\bm{x}},{\bm{x}}^{\prime}) even if the inputs are of different lengths, without resorting to heuristics such as zero padding the inputs to the to the max length of both sequences. Dealing with data of different length is in sharp contrast to common kernels such as the classical radial basis functions, polynomial kernels, and current NTKs. We showcase this capability below in Section 4.

To visualize Theorem 1, we plot in the left plot in Figure 2 the convergence of a single layer, sufficiently wide RNN to its RNTK with the two simple inputs x={1,−1,1}{\bm{x}}=\{1,-1,1\} of length 3 and x′={cos(α),sin(α)}{\bm{x}}^{\prime}=\{{\rm cos}(\alpha),{\rm sin}(\alpha)\} of length 2, where α=[0,2π]\alpha=[0,2\pi]. For an RNN with a sufficiently large hidden state (n=1000n=1000), we see clearly that it converges to the RNTK (n=∞n=\infty).

Following , we obtain the analytical recursive formula for the GP kernel Σ(t,t+τ)(x,x′)\Sigma^{(t,t+\tau)}({\bm{x}},{\bm{x}}^{\prime}) for a single layer RNN as

Similarly, we obtain the analytical recursive formula for the GP kernel Π(t,t+τ)(x,x′)\Pi^{(t,t+\tau)}({\bm{x}},{\bm{x}}^{\prime}) as

2 RNTK for an Infinite-Width RNN during Training

We prove that an infinitely-wide RNN, not only at initialization but also during gradient descent training, converges to the limiting RNTK at initialization.

Remarks. Theorem 2 states that the training dynamics of an RNN in the infinite-width limit as in (1), (2) are governed by the RNTK derived from the RNN at its initialization. Intuitively, this is due to the NTK initialization (3), (4) which positions the parameters near a local minima, thus minimizing the amount of update that needs to be applied to the weights to obtain the final parameters.

3 RNTK for an Infinite-Width RNN Without Weight Sharing

For inputs of the same length, an RNN with untied weights converges to the same RNTK as an RNN with tied weights in the infinite-width (n→∞n\rightarrow\infty) regime.

Remarks. Theorem 3 implies that weight-tied and weight-untied RNNs have similar behaviors in the infinite-width limit. It also suggests that existing results on the simpler, weight-untied RNN setting may be applicable for the more general, weight-tied RNN. The plot on the right side of Figure 2 empirically demonstrates the convergence of both the weight-tied and weight-untied RNNs to the RNTK with increasing hidden layer size nn; moreover, the convergence rates are similar.

4 Insights into the Roles of the RNTK’s Hyperparameters

Our analytical form for the RNTK is fully determined by a small number of hyperparameters, which contains the various weight variances collected into S={σw,σu,σb,σh}\mathcal{S}=\{\sigma_{w},\sigma_{u},\sigma_{b},\sigma_{h}\} and the activation function.From (11) to (20) we emphasize that σv\sigma_{v} merely scales the RNTK and does not change its overall behavior. In standard supervised-learning settings, one often performs cross-validation to select the hyperparameters. However, since kernel methods become computationally intractable for large datasets, we seek a more computationally friendly alternative to cross-validation. Here we conduct a novel exploratory analysis that provides new insights into the impact of the RNTK hyperparameters on the RNTK output and suggests a simple method to select them a priori in a deliberate manner.

To visualize the role of the RNTK hyperparameters, we introduce the sensitivity s(t)s(t) of the RNTK of two input sequences x{\bm{x}} and x′{\bm{x}}^{\prime} with respect to the input xt{\bm{x}}_{t} at time tt

Here, s(t)s(t) indicates how sensitive the RNTK is to the data at time tt, i.e., xt{\bm{x}}_{t}, in presence of another data sequence x′{\bm{x}}^{\prime}. Intuitively, large/small s(t)s(t) indicates that the RNTK is relatively sensitive/insensitive to the input xt{\bm{x}}_{t} at time tt.

The sensitivity is crucial to understanding to which extent the RNTK prediction is impacted by the input at each time step. In the case where some time indices have a small sensitivity, then any input variation in those corresponding times will not alter the RNTK output and thus will produce a metric that is invariant to those changes. This situation can be beneficial or detrimental based on the task at hand. Ideally, and in the absence of prior knowledge on the data, one should aim to have a roughly constant sensitivity across time in order to treat all time steps equally in the RNTK input comparison.

Figure 3 plots the normalized sensitivity s(t)/maxt(s(t))s(t)/{\rm max}_{t}(s(t)) for two data sequences of the same length T=100T=100, with s(t)s(t) computed numerically for xt,xt′∼N(0,1){\bm{x}}_{t},{\bm{x}}^{\prime}_{t}\sim\mathcal{N}(0,1). We repeated the experiments 10000 times; the mean of the sensitivity is shown in Figure 3. Each of the plots shows the changes of parameters SReLU={2,1,0,0}\mathcal{S}_{\rm ReLU}=\{\sqrt{2},1,0,0\} for ϕ=ReLU\phi=\rm ReLU and Serf={1,0.01,0.05,0}\mathcal{S}_{\rm erf}=\{1,0.01,0.05,0\} for ϕ=erf\phi=\rm erf.

Another notable observation is the importance of σh\sigma_{h}, which is usually set to zero for RNNs. showed that a non-zero σh\sigma_{h} acts as a regularization that improves the performance of RNNs with the ReLU\rm ReLU nonlinearity. From the sensitivity perspective, a non-zero σh\sigma_{h} results in reducing the importance of the first time steps of the input. We also see the same behavior in erf\rm erf, but with stronger changes as σh\sigma_{h} increases. Hence whenever one aims at reinforcing the input pairwise comparisons, such parameters should be favored.

This sensitivity analysis provides a practical tool for RNTK hyperparameter tuning. In the absence of knowledge about the data, hyperparameters should be chosen to produce the least time varying sensitivity. If given a priori knowledge, hyperparameters can be selected that direct the RNTK to the desired time-steps.

Experiments

We now empirically validate the performance of the RNTK compared to classic kernels, NTKs, and trained RNNs on both classification and regression tasks using a large number of time series data sets. Of particular interest is the capability of the RNTK to offer high performance even on inputs of different lengths.

Time Series Classification. The first set of experiments considers time series inputs of the same lengths from 56 datasets in the UCR time-series classification data repository . We restrict ourselves to selected data sets with fewer than 10001000 training samples and fewer than 10001000 time steps (TT) as kernel methods become rapidly intractable for larger datasets. We compare the RNTK with a variety of other kernels, including the Radial Basis Kernel (RBF), polynomial kernel, and NTK , as well as finite RNNs with Gaussian, identity initialization, and GRU . We use ϕ=ReLU\phi=\rm ReLU for both the RNTKs and NTKs. For each kernel, we train a C-SVM classifier, and for each finite RNN we use gradient descent training. For model hyperparameter tuning, we use 10-fold cross-validation. Details on the data sets and experimental setup are available in Appendix 2.

We summarize the classification results over all 56 datasets in Table 1; detailed results on each data set is available in Appendix A.2. We see that the RNTK outperforms not only the classical kernels but also the NTK and trained RNNs in all metrics. The results demonstrate the ability of RNTK to provide increased performances compare to various other methods (kernels and RNNs). The superior performance of RNTK compared to other kernels, including NTK, can be explained by the internal recurrent mechanism present in RNTK, allowing time-series adapted sample comparison. In addition, RNTK also outperforms RNN and GRU. As the datasets we consider are relative small in size, finite RNNs and GRUs that typically require large amount of data to succeed do not perform well in our setting. An interesting future direction would be to compare RNTK to RNN/GRU on larger datasets.

Time Series Regression. We now validate the performance of the RNTK on time series inputs of different lengths on both synthetic data and real data. For both scenarios, the target is to predict the next time-step observation of the randomly extracted windows of different length using kernel ridge regression.

We compare the RNTK to other kernels, the RBF and polynomial kernels and the NTK. We also compare our results with a data independent predictor that requires no training, that is simply to predict the next time step with previous time step (PTS).

For the synthetic data experiment, we simulate 1000 samples of one period of a sinusoid and add white Gaussian noise with default σn=0.05\sigma_{n}=0.05. From this fixed data, we extract training set size Ntrain=20N_{\rm train}=20 segments of uniform random lengths in the range of [Tfixed,Tfixed+Tvar][T_{\rm fixed},T_{\rm fixed}+T_{\rm var}] with Tfixed=10T_{\rm fixed}=10. We use standard kernel ridge regression for this task. The test set is comprised of Ntest=5000N_{\rm test}=5000 obtained from other randomly extracted segments, again of varying lengths. For the real data, we use 975975 days of the Google stock value in the years 2014–2018. As in the simulated signal setup above, we extract NtrainN_{\rm train} segments of different lengths from the first 700 days and test on the NtestN_{\rm test} segments from days 701 to 975. Details of the experiment are available in Appendix A.2.

We report the predicted signal-to-noise ratio (SNR) for both datasets in Figures 4a and 4c for various values of TvarT_{\rm var}. We vary the noise level and training set size for fixed Tvar=10T_{\rm var}=10 in Figures 4b and 4d. As we see from Figures 4a and 4c, the RNTK offers substantial performance gains compared to the other kernels, due to its ability to naturally deal with variable length inputs. Moreover, the performance gap increases with the amount of length variation of the inputs TvarT_{\rm var}. Figure 4d demonstrates that, unlike the other methods, the RNTK maintains its performance even when the training set is small. Finally, Figure 4c demonstrates that the impact of noise in the data on the regression performance is roughly the same for all models but becomes more important for RNTK with a large σn\sigma_{n}; this might be attributed to the recurrent structure of the model allowing for a time propagation and amplification of the noise for very low SNR. These experiments demonstrate the distinctive advantages of the RNTK over classical kernels, and NTKs for input data sequences of varying lengths.

In the case of PTS, we expect the predictor to outperform kernel methods when learning from the training samples is hard, due to noise in the data or small training size which can lead to over fitting. In Figure 4a RNTK and Polynomial kernels outperforms PTS for all values of TvarT_{\rm var}, but for larger TvarT_{\rm var}, NTK and RBF under perform PTS due to the increasing detrimental effect of zero padding. For the Google stock value, we see a superior performance of PTS with respect to all other kernel methods due to the nature of those data heavily relying on close past data. However, RNTK is able to reduce the effect of over-fitting, and provide the closest results to PTS among all kernel methods we employed, with increasing performance as the number of training samples increase.

Conclusions

In this paper, we have derived the RNTK based on the architecture of a simple RNN. We have proved that, at initialization, after training, and without weight sharing, any simple RNN converges to the same RNTK. This convergence provides new insights into the behavior of infinite-width RNNs, including how they process different-length inputs, their training dynamics, and the sensitivity of their output at every time step to different nonlinearities and initializations. We have highlighted the RNTK’s practical utility by demonstrating its superior performance on time series classification and regression compared to a range of classical kernels, the NTK, and trained RNNs. There are many avenues for future research, including developing RNTKs for gated RNNs such as the LSTM and investigating which of our theoretical insights extend to finite RNNs.

Acknowledgments

This work was supported by NSF grants CCF-1911094, IIS-1838177, and IIS-1730574; ONR grants N00014-18-12571, N00014-20-1-2787, and N00014-20-1-2534; AFOSR grant FA9550-18-1-0478; and a Vannevar Bush Faculty Fellowship, ONR grant N00014-18-1-2047.

References

Appendix A Experiment Details

We used RNTK, RBF, polynomial and NTK . For data pre-processing, we normalized the norm of each x{\bm{x}} to 1. For training we used C-SVM in LIBSVM library and for hyperparameter selection we performed 10-fold validation for splitting the training data into 90% training set and 10% validation test. We then choose the best performing set of hyperparameters on all the validation sets, retrain the models with the best set of hyperparameters on the entire training data and finally report the performance on the unseen test data. The performance of all kernels on each data set is shown in table 2.

For C-SVM we chose the cost function value

and for each kernel we used the following hyperparameter sets

RNTK: We only used single layer RNTK, we ϕ=ReLU\phi={\rm ReLU} and the following hyperparameter sets for the variances:

Finite-width RNN settings.

We used 3 different RNNs. The first is a ReLU RNN with Gaussian initialization with the same NTK initialization scheme, where parameter variances are σw=σv=2\sigma_{w}=\sigma_{v}=\sqrt{2}, σu=1\sigma_{u}=1 and σb=0\sigma_{b}=0. The second is a ReLU RNN with identity initialization following . The third is a GRU with uniform initialization. All models are trained with RMSProp algorithm for 200 epochs. Early stopping is implemented when the validation set accuracy does not improve for 5 consecutive epochs.

We perform standard 5-fold cross validation. For each RNN architecture we used hyperparamters of number of layer, number of hidden units and learning rate as

Metrics descriptions

First, only in this paragraph, let i∈{1,2,...,N}i\in\{1,2,...,N\} index a total of NN datasets and j∈{1,2,...,M}j\in\{1,2,...,M\} index a total of MM classifiers. Let yijy_{ij} be the accuracy of the jj-th classifer on the ii-th dataset. We reported results on 4 metrics: average accuracy (Acc. mean), P90, P95, PMA and Friedman Rank. P90 and P95 is the fraction of datasets that the classifier achieves at least 90% and 95% of the maximum achievable accuracy for each dataset, i.e.,

PMA is the accuracy of the classifier on a dataset divided by the maximum achievable accuracy on that dataset, averaged over all datasets:

Friedman Rank first ranks the accuracy of each classifier on each dataset and then takes the average of the ranks for each classifier over all datasets, i.e.,

where rijr_{ij} is the ranking of the jj-th classifier on the ii-th dataset.

Note that a better classifier achieves a lower Friedman Rank, Higher P/90 and PMA.

Remark. In order to provide insight into the performance of RNTK in long time steps setting, we picked two datasets with more that 1000 times steps: SemgHandSubjectCh2 (T=1024T=1024) and StarLightCurves (T=1024T=1024).

A.2 Time Series Regression

For time series regression, we used the 5-fold validation of training set and same hyperparamter sets for all kernels. For training we kernel ridge regression with ridge term chosen form

Appendix B Proofs for Theorems 1 and 3: RNTK Convergence at Initialization

Calculation of NTK in any architecture relies on finding the GP kernels that correspond to each pre-activation and gradient layers at initialization. For feedforward neural networks with n1,…,nLn_{1},\dots,n_{L} number of neurons (channels in CNNs) at each layer the form of this GP kernels can be calculated via taking the limit of n1,…,nLn_{1},\dots,n_{L} sequentially one by one. The proof is given by induction, where by conditioning on the previous layers, each entry of the current layer is sum of infinite i.i.d Gaussian random variables, and based on Central Limit Theorem (CLT), it becomes a Gaussian process with kernel calculated based on the previous layers. Since the first layer is an affine transformation of input with Gaussian weights, it is a Gaussian process and the proof is completed. See for a formal treatment. However, due to weight-sharing, sequential limit is not possible and condoning on previous layers does not result in i.i.d. weights. Hence the aforementioned arguments break. To deal with it, in a proof using Gaussian conditioning trick is presented which allows use of recurrent weights in a network. More precisely, it has been demonstrated than neural networks (without batch normalization) can be expressed and a series of matrix multiplication and (piece wise) nonlinearity application, generally referred as Netsor programs. It has been shown that any architecture that can be expressed as Netsor programs that converge to GPs as width goes to infinity in the same rate, which a general rule to obtain the GP kernels. For completeness of this paper, we briefly restate the results from which we will use later for calculation derivation of RNTK.

There are 3 types of variables in Netsor programs; AA-vars, GG-vars and HH-vars. AA-vars are matrices and vectors with i.i.d Gaussian entries, GG-vars are vectors introduced by multiplication of a vector by an AA-var and HH-vars are vectors after coordinate wise nonlinearities is applied to GG-vars. Generally, GG-vars can be thought of as pre-activation layers which are asymptotically treated as a Gaussian distributed vectors, HH-vars as after-activation layers and AA-vars are the weights. Since in neural networks inputs are immediately multiplied by a weight matrix, it can be thought of as an GG-var, namely gin{\bm{g}}_{in}. Generally Netsor programs supports GG-vars with different dimension, however the asymptotic behavior of a neural networks described by Netsor programs does not change under this degree of freedom, as long as they go to infinity at the same rate. For simplicity, let the GG-vars and HH-vars have the same dimension nn since the network of interest is RNN and all pre-activation layers have the same dimension. We introduce the Netsor programs under this simplification. To produce the output of a neural network, Netsor programs receive a set of GG-vars and AA-vars as input, and new variables are produced sequentially using the three following operators:

Matmul : multiplication of an AA-var: A{\bm{A}} with an HH-var: h{\bm{h}}, which produce a new GG-var, g{\bm{g}}.

Any other output can be produced by another v′{\bm{v}}^{\prime} and h′{\bm{h}}^{\prime} (possibility the same h{\bm{h}} or v{\bm{v}}).

Where h=φ(g1,…,gr){\bm{h}}=\varphi({\bm{g}}^{1},\dots,{\bm{g}}^{r}) and h′=φˉ(g1,…,gr){\bm{h}}^{\prime}=\bar{\varphi}({\bm{g}}^{1},\dots,{\bm{g}}^{r}) are functions of GG-vars in G\mathcal{G} from possibly different nonlinearities. This set of rules presents a recursive method for calculating the GP kernels in a network where the recursive formula starts from data dependent quantities Σin\Sigma^{\rm in} and μin\mu^{in} which are given.

All the above results holds when the nonlinearities are bounded uniformly by e(cx2−α)e^{(cx^{2-\alpha})} for some α>0\alpha>0 and when their derivatives exist.

Standard vs. NTK initialization. The common practice (which netsor programs uses) is to initialize DNNs weights [A]i,j[{\bm{A}}]_{i,j} with N(0,σan)\mathcal{N}(0,\frac{\sigma_{a}}{\sqrt{n}}) (known as standard initialization) where generally nn is the number of units in the previous layer. In this paper we have used a different parameterization scheme as used in and we factor the standard deviation as shown in 3 and initialize weights with standard standard Gaussian. This approach does not change the the forward computation of DNN, but normalizes the backward computation (when computing the gradients) by factor 1n\frac{1}{n}, otherwise RNTK will be scales by nn. However this problem can be solved by scaling the step size by 1n\frac{1}{n} and there is no difference between NTK and standard initialization .

B.2 Proof for Theorem 1: Single layer Case

Note that (34), (35) and (36) use all the introduced operators introduced in 29, 30 and 31 given input variables W,{Uxt}t=1T,b,v{\mathbf{W}},\{{\mathbf{U}}{\bm{x}}_{t}\}_{t=1}^{T},{\mathbf{b}},{\bm{v}} and h(0)(x){\bm{h}}^{(0)}({\bm{x}}).

First, we compute the kernels of forward pass Σ(t,t′)(x,x′)\Sigma^{(t,t^{\prime})}({\bm{x}},{\bm{x}}^{\prime}) and backward pass Π(t,t′)(x,x′)\Pi^{(t,t^{\prime})}({\bm{x}},{\bm{x}}^{\prime}) introduced in (6) and (7) for two input x{\bm{x}} and x′{\bm{x}}^{\prime}. Note that based on (32) the mean of all variables is zero since the inputs are all zero mean. In the forward pass for the intermediate layers we have:

We have used the second and third rule in (33) to expand the formula, We have also used the first and fifth rule to set the cross term to zero, i.e.,

which can be achieved by straight forward computation. If t≠1t\neq 1 and t′≠1t^{\prime}\neq 1, by using the forth rule in (33) we have

With K(t,t′)(x,x′){\bm{K}}^{(t,t^{\prime})}({\bm{x}},{\bm{x}}^{\prime}) defined in (18). Otherwise, it will be zero by the fifth rule (if tt or tt = 1) .

Here the set of previously introduced GG-vars is \mathcal{G}=\big{\{}\{{\bm{g}}^{(\alpha)}({\bm{x}})\},{\mathbf{U}}{\bm{x}}_{\alpha}\}_{\alpha=1}^{t-1},\{{\bm{g}}^{(\alpha^{\prime})}({\bm{x}}^{\prime}),{\mathbf{U}}{\bm{x}}^{\prime}_{\alpha^{\prime}}\}_{\alpha^{\prime}=1}^{t^{\prime}-1},{\bm{h}}^{(0)}({\bm{x}}),{\bm{h}}^{(0)}({\bm{x}}^{\prime})\big{\}}, but the dependency is only on the last layer GG-vars, φ({g:g∈G})=ϕ(g(t−1)(x))\varphi(\{{\bm{g}}:{\bm{g}}\in\mathcal{G}\})=\phi({\bm{g}}^{(t-1)}({\bm{x}})), φˉ(({g:g∈G}))=ϕ(g(t′−1)(x′))\bar{\varphi}((\{{\bm{g}}:{\bm{g}}\in\mathcal{G}\}))=\phi({\bm{g}}^{(t^{\prime}-1)}({\bm{x}}^{\prime})), leading the calculation to the operator defined in (10). As a result

To complete the recursive formula, using the same procedure for the first layers we have

The calculation of the gradient vectors {\bm{\delta}}^{(t)}({\bm{x}})=\sqrt{n}\big{(}\nabla_{{\bm{g}}^{(t)}({\bm{x}})}f_{\theta}({\bm{x}})\big{)} in the backward pass is given by

To calculate the backward pass kernels, we rely on the following Corollary from

In infinitely wide neural networks weights used in calculation of back propagation gradients (W⊤{\mathbf{W}}^{\top}) is an i.i.d copy of weights used in forward propagation (W{\mathbf{W}}) as long as the last layer weight (v{\bm{v}}) is sampled independently from other parameters and has mean 0.

The immediate result of Corollary 1 is that g(t)(x){\bm{g}}^{(t)}({\bm{x}}) and δ(t)(x){\bm{\delta}}^{(t)}({\bm{x}}) are two independent Gaussian vector as their covariance is zero based on the fifth rule in (33). Using this result, we have:

If T′−t′=T−tT^{\prime}-t^{\prime}=T-t, then the the formula will lead to

Otherwise it will end to either of two cases for some t′′<Tt^{\prime\prime}<T or T′T^{\prime} and by the fifth rule in (33) we have:

Without loss of generality, from now on assume T′<TT^{\prime}<T and T′−T=τT^{\prime}-T=\tau, the final formula for computing the backward gradients becomes:

Where the gradients of output with respect to weights can be formulated as the following compact form:

Hence, by summing the above terms in the infinite-width limit we get

Since Π(t,t′)(x,x′)=0\Pi^{(t,t^{\prime})}({\bm{x}},{\bm{x}}^{\prime})=0 for t′−t≠τt^{\prime}-t\neq\tau it is simplified to

For i=ji=j, the kernel is the same as computed in (37) and we denote it as

For i≠ji\neq j, since vi{\bm{v}}_{i} is independent of vj{\bm{v}}_{j}, Π(T,T′)(x,x′)\Pi^{(T,T^{\prime})}({\bm{x}},{\bm{x}}^{\prime}) and all the backward pass gradients become zero, so

This concludes the proof for Theorem 1 for single-layer case.

B.3 Proof for Theorem 1: Multi-Layer Case

Now we drive the RNTK for multi-layer RNTK. We will only study single output case and the generalization to multi-dimensional case is identical as the single layer case. The set of equations for calculation of the output of a LL-layer RNN for x={xt}t=1T{\bm{x}}=\{{\bm{x}}_{t}\}_{t=1}^{T} are

and Σin\Sigma^{\rm in} is defined in (B.2). For the first first time step we have:

Note that because of using new weights at each layer we get

Now we calculate the backward pass kernels in multi-layer RNTK. The gradients at the last layer is calculated via

In the last hidden layer for different time steps we have

In the last time step for different hidden layers we have

The recursive formula for the Π(L,t,t′)(x,x′)\Pi^{(L,t,t^{\prime})}({\bm{x}},{\bm{x}}^{\prime}) is the same as the single layer, and it is non-zero for t′−t=T′−T=τt^{\prime}-t=T^{\prime}-T=\tau. As a result we have

Similarly by using the same course of arguments used in the single layer setting, for the last time step we have

For t′−t≠τt^{\prime}-t\neq\tau the recursion continues until it reaches Π(L,T,t′′)(x,x′),t′′<T′\Pi^{(L,T,t^{\prime\prime})}({\bm{x}},{\bm{x}}^{\prime}),t^{\prime\prime}<T^{\prime} or Π(L,t′′,T′)(x,x′),t′′<T\Pi^{(L,t^{\prime\prime},T^{\prime})}({\bm{x}},{\bm{x}}^{\prime}),t^{\prime\prime}<T and as a result based on (38) we get

For t′−t=τt^{\prime}-t=\tau it leads to Π(L,T,T′)(x,x′)\Pi^{(L,T,T^{\prime})}({\bm{x}},{\bm{x}}^{\prime}) and has a non-zero value. Now we derive RNTK for multi-layer:

Summing up all the terms and replacing the inner product of vectors with their expectations we get

This concludes the proof for Theorem 1 for the multi-layer case.

B.4 Proof for Theorem 3: Weight-Untied RNTK

The architecture of a weight-untied single layer RNN is

Where we use new weights at each time step and we index it by time. Like previous sections, we first derive the forward pass kernels for two same length data x={xt}t=1T{\bm{x}}=\{{\bm{x}}_{t}\}_{t=1}^{T},x={xt′′}t′=1T{\bm{x}}=\{{\bm{x}}^{\prime}_{t^{\prime}}\}_{t^{\prime}=1}^{T}

Since we are using same weight at the same time step, Σ(t,t)(x,x′)\Sigma^{(t,t)}({\bm{x}},{\bm{x}}^{\prime}) can be written as a function of the previous kernel, which is exactly as the weight-tied RNN. However for different length, it becomes zero as a consequence of using different weights, unlike weight-tied which has non-zero value. The kernel of the first time step and output is also the same as weight-tied RNN. For the gradients we have:

same as the weight-tied RNN when τ=0\tau=0. This concludes the proof for Theorem 3.

For any positive definite matrix {\bm{K}}=\left[{\begin{array}[]{cc}K_{1}&K_{3}\\ K_{3}&K_{2}\\ \end{array}}\right] we have:

Appendix C Proof for Theorem 2: RNTK Convergence after Training

The Jacobian of a neural network is local lipschitz at NTK initialization (θ0∼N(0,1))\left(\theta_{0}\sim\mathcal{N}(0,1)\right) if there is constant K>0K>0 for every CC such that

Theorem 4 holds for any network architecture and any cost function and it was used in to show the stability of NTK for MLP during training.

Here we extend the results for RNTK by proving that the Jacobian of a multi-layer RNN under NTK initialization is local lipschitz with high probability.

To prove (40) and (41) we use the following lemmas.See math.uci.edu/~rvershyn/papers/HDP-book/HDP-book.pdf for proofs

Setting t=nt=\sqrt{n} for any θ∈R(θ0,R)\theta\in R(\theta_{0},R). With high probability, we get:

We also assume that there exists some finite constant CC such that

The proof is obtained by induction. From now on assume that all inequalities in (40) and (41) holds with some kk for the previous layers. We have

And the proof for (40) and (41) is completed by showing that the first layer is bounded

And similarly using same techniques we have

As a result, there exists K1K_{1} that is a function of σw,σu,σb,L,T\sigma_{w},\sigma_{u},\sigma_{b},L,T and the norm of the inputs.

Now we prove the local Lipchitzness of the Jacobian

The above proof can be generalized to the entire dataset by a straightforward application of the union bound. This concludes the proof for Theorem 2.