[notes] NTK analysis for an MLP with one hidden layer and infinite data
Motivation
I am interested in understanding the learning dynamics of neural networks. In particular, I’d like to understand the difference between the neural network “NTK parametrization” and the “mu Parametrization” (the latter from the Tensor Programs series of papers).
I understand that both parametrizations are justified by various analyses of the behavior of training as the width goes to infinity. It is known that the NTK parametriation can essentially already fit any finite amount of data perfectly. So my suspicion is that the difference in power between any two parametrizations must be found in the regime where the amount of data goes to infinity alongside the width. (However this could be totally wrong because I haven’t actually studied Tensor programs yet. Either way, I’m interested in studying this.)
In this note I’ll analyze the simplest possible neural network, an MLP with a single hidden layer using NTK parametrization, as both its width and amount of data go to infinity. I will prove that we remain in the kernel/lazy/linearized regime when the amount of data is below the fourth-root of the width.
My proof is not very sophisticated: it doesn’t use any tools more powerful than Chernoff bounds. I do not know whether this result, or perhaps something better, can already be found in the literature, because I did not do a thorough literature review.
Setup: single layer MLP
Given an input , the output of an MLP with a single hidden layer, which is using the “NTK parametrization,” is:
where and are its weight matrices, which are both initialized IID with zero mean and unit variance.
We assume that the initialization distribution of is standard Gaussian, and is either Gaussian or bounded. We also assume that the activation function has bounded second moment and is Lipschitz. Without loss of generality, let be a constant such that and and . E.g., this covers sigmoid, arbitrarily-smoothed-ReLU, and GELU activations.
Let be our dataset of inputs to the MLP. When the MLP has weights , we write to denote the matrix of gradients of the output with respect to each of the inputs in the dataset. That is, , where is the th column of . We additionally write to denote the matrix of dot products between the gradients. We assume that the norm of each datapoint is bounded by .
We will hold the input dimension fixed, and analyze the training dynamics as the hidden dimension (also known as the width of the MLP) and the number of datapoints both go to infinity.
We assume at the outset that the data rate is at most linear in the width, that is, . In fact, it will have to grow much more slowly than this.
We write to denote a function which asymptotically grows at most at the rate for some . And we write to denote a function which asymptotically grows more slowly than for every . Hence, e.g., .
Throughout the proofs, if we write where is a matrix, we mean , i.e., , rather than any other notion of norm.
Main result and proof outline
In this note I will prove the following.
Given a randomly initialized wide MLP with a single hidden layer, and a dataset of inputs alongside arbitrary bounded regression targets, we can take full-batch gradient descent steps with learning rate per step, without leaving the linearized regime. That is, in this regime, the trajectory of the model’s outputs can be asymptotically-perfectly predicted using only the angles between the inputs plus the model’s outputs at initialization. In addition, if the inputs are orthogonal, then performing descent steps will perfectly solve the problem.
The key points in the proof are as follows:
- NTK convergence theorem: As long as is polynomial in , all the dot products between gradients at initialization are almost-surely equal to the NTK plus a error term.
- Hessian analysis: The MLP’s Hessian has spectral norm , both at initialization, and anywhere along any optimization trajectory given by taking at most update steps with learning rate per example across a dataset of examples.
- Discrepancy analysis: A full-batch gradient update with learning rate on points has norm (this can be sharp even if the inputs are orthogonal). At curvature , this induces a discrepancy of order in the angle of gradients (relative to what they are at initialization, which is roughly the NTK). This discrepancy in angle gets magnified by the size of the step to produce a final discrepancy in values of .
- Trajectory linearization theorem: Therefore, if we limit the dataset size to , then the discrepancy stays and we can perfectly predict the dynamics of gradient descent with total learning rate per example spread out over steps.
- Application to regression: This yields a formula for the dynamics of gradient descent against squared-error loss, which involves only the NTK and the model’s initial outputs.
Gradient kernel
Basic calculation
Given an input , the Jacobian of the first layer’s output (i.e., ) with respect to the MLP’s output is
Thus, the partial derivatives are:
\begin{align*} \tfrac{\partial f_x(W)}{\partial W_{ij}^{(1)}} &= \left(\tfrac{1}{\sqrt d_1}W_{1i}^{(2)} \cdot \sigma'(\tfrac{1}{\sqrt d_0} W_i^{(1)}x)\right) \cdot \left(\tfrac{1}{\sqrt d_0} x_j\right) \ \tfrac{\partial f_x(W)}{\partial W_{1i}^{(2)}} &= \tfrac{1}{\sqrt d_1} \sigma(\tfrac{1}{\sqrt d_0} W_i^{(1)}x) \end{align*}
And the gradients are:
\begin{align*} \nabla_{W^{(1)}}f_x(W) &= \left(\tfrac{1}{\sqrt d_1}W^{(2)}\mathrm{diag}(\sigma'(\tfrac{1}{\sqrt d_0} W^{(1)}x))\right)^\top (\tfrac{1}{\sqrt d_0}x)^\top \ \nabla_{W^{(2)}}f_x(W) &= \tfrac{1}{\sqrt d_1}\sigma(\tfrac{1}{\sqrt d_0} W^{(1)}x) \end{align*}
Therefore, the dot products between the gradients for two inputs are:
\begin{align*} \langle \nabla_{W^{(1)}}f_x(W), \nabla_{W^{(1)}}f_{\tilde x}(W) \rangle &= \tfrac{1}{d_0}\langle x, \tilde x\rangle \cdot \tfrac{1}{d_1}\sum_{i=1}^{d_1}(W_{1i}^{(2)})^2 \sigma'(\tfrac{1}{\sqrt d_0} W^{(1)}x)\sigma'(\tfrac{1}{\sqrt d_0} W^{(1)}\tilde x) \ \langle \nabla_{W^{(2)}}f_x(W), \nabla_{W^{(2)}}f_{\tilde x}(W) \rangle &= \tfrac{1}{d_1}\langle \sigma(\tfrac{1}{\sqrt d_0} W^{(1)}x), \sigma(\tfrac{1}{\sqrt d_0} W^{(1)}\tilde x)\rangle \end{align*}
We denote the activations across the dataset by and their derivatives by , the full matrix of dot products between their gradients is
where denotes element-wise multiplication of matrices.
Moments of the relevant distributions
The entries of are fixed as we increase . The entries of and are both averages of IID variables. To get large deviation bounds for them we now calculate the moments of those variables.
The weights are initialized using IID Gaussian variables, so given two inputs from the columns of , if we define and likewise , then are jointly Gaussian with distribution .
Therefore, the moments that we are interested in calculating are of variables with distribution and .
The conditions we placed on imply that . Therefore where is the variable among with the larger variance. If then . Else if then . Therefore either way, . Hence
\begin{align*} {\mathbb E}[|Y|^k] &\leq (2C)^{2k}(1+{\mathbb E}[z^{2k}]) \ &= (2C\max(\tfrac{1}{\sqrt d_0}|x|, \tfrac{1}{\sqrt d_0}|\tilde x|))^{2k}(1 + {\mathbb E}[w^{2k}]) \ &\leq (2C)^{2k}(1 + (2k-1)!!) \ &\leq (2C)^{2k}(1 + (2k)!!) \ &= (2C)^{2k}(1 + 2^kk!) \ &\leq (3C)^{2k}k! \ \end{align*}
where we use our assumption that , and the formula for the th moment of a Gaussian.
We have therefore shown that the IID distributions whose averages make up the entries of the term each have moments bounded by .
For the matrix , its entries are averages of variables of distribution , where stands in for one of the IID . This satisfies
Therefore, the distributions in the IID averages forming the entries of both matrices always have their th moment bounded by .
Deviation bound
We previously proved that the matrices and have entries which are each an average of IID variables whose distribution has th moment bounded by . Therefore, via generic sub-exponential large deviation bounds, we have
In particular, letting , and using the assumption that , we have
and therefore
hence almost-surely , where ignores logarithmic factors, and ranges over both of the two matrices.
Calculation of the expectations
It remains to calculate the expectations for matrices and .
Let and . Then for any , the variables and likewise are jointly Gaussian with covariance given by
\begin{align*} {\mathbb E}[z \tilde{z}] &= {\mathbb E}\left[\frac{1}{d_0} (W_j^{(1)} x)(W_j^{(1)} \tilde{x})\right] \ &= {\mathbb E}\left[\frac{1}{d_0} \sum_{i_1=1}^{d_0} \sum_{i_2=1}^{d_0} (W_{ji_1}^{(1)} x_{i_1})(W_{ji_2}^{(1)} \tilde x_{i_2})\right] \ &= \frac{1}{d_0} \sum_{i_1=1}^{d_0} \sum_{i_2=1}^{d_0}{\mathbb E}\left[(W_{ji_1}^{(1)} x_{i_1})(W_{ji_2}^{(1)} \tilde x_{i_2})\right] \ &= \frac{1}{d_0} \sum_{i_1=1}^{d_0} \sum_{i_2=1}^{d_0} (x_{i_1}\tilde x_{i_2}){\mathbb E}\left[W_{ji_1}^{(1)}W_{ji_2}^{(1)}\right] \ &= \frac{1}{d_0} \sum_{i_1=1}^{d_0} \sum_{i_2=1}^{d_0} (x_{i_1}\tilde x_{i_2})1{i_1=i_2} \ &= \frac{1}{d_0} \sum_{i=1}^{d_0} x_i\tilde x_i \ &= \tfrac{1}{d_0} \langle x, \tilde x \rangle. \end{align*}
Therefore, according to the definition of the dual of the activation , we have
We next calculate . We have:
\begin{align*} {\mathbb E}\left[(\tfrac{F'^\top \mathrm{diag}(W^{(2)})^2 F'}{d_1}){n_1n_2}\right] &= {\mathbb E}\left[\frac{1}{d_1}\sum{i=1}^{d_1} (W_{1i}^{(2)})^2 \sigma'(\tfrac{1}{\sqrt d_0} W_i^{(1)} x)\sigma'(\tfrac{1}{\sqrt d_0} W_i^{(1)} \tilde x)\right] \ &= {\mathbb E}_{z, \tilde z \sim {\mathcal N}(0, \tfrac{1}{d_0}(x, \tilde x)^\top (x, \tilde x))}\left[\sigma'(z)\sigma'(\tilde z)\right] \ \end{align*}
and therefore
NTK convergence theorem
Define the neural tangent kernel given a matrix of dot products via
The following theorem states that the dot products between gradients are asymptotically given by the neural tangent kernel, at a uniform rate of convergence across all pairs in the dataset.
Theorem. Let be the initialization weights of the MLP. Then satisfies:
Proof. This is immediate from the previous section.
In the case that for every column of , hence has unit diagonal, we can overload the definition of via
for every angle .
According to our second proposition regarding duals (in the Appendix), if this conditions is satisfied, then this definition of the NTK is consistent with the full-matrix one when applied element-wise.
Intuition for this NTK formula:
- Every single filter (row) of the first layer has a gradient which is some scalar times the input. The question is just what the scalar will be, which depends on the derivative of the activation function.
- Therefore the dot product of gradients in the first layer will just be the dot product between the inputs, times the expected product of the two activation-derivatives wrt the two different inputs. For ReLU, this latter quantity is precisely the fraction of neurons which are co-activated across both inputs.
- The final weight’s gradient is always just the hidden activations. So the dot product in the final layer is proportional to the dot product of hidden activations.
Concrete values and visualization for ReLU
Theorem. If , and and , then:
Proof. Combination of previous theorem with formulas for ReLU and ReLU’.
The kernel looks like:

This is actually correct (confirmed by simulation). In particular, single hidden layer ReLU MLPs have the property that, if you have two inputs which are almost opposites of each other, and you want them to “look more different”, then you should make them a bit closer to each other. One is reminded of the GELU activation.
BTW, if you’re lazy and don’t wanna do the calculus to derive the duals, it’s perfectly correct to just compute them via simulation, i.e., generate a stream of Gaussian samples with the correct covariance, and then just compute the expectation in the formula for the dual. This would look something like the following.
import torch
xx1 = torch.randn(5000000, device='cuda')
xx2 = torch.randn(5000000, device='cuda')
def dual(fn, kappa):
gamma = ((1 - kappa) / 2)**0.5
yy1 = (1 - gamma**2)**0.5 * xx1 + gamma * xx2
yy2 = (1 - gamma**2)**0.5 * xx1 - gamma * xx2
assert (0.998 < (yy1 * yy1).mean() < 1.002)
assert ((yy1 * yy2).mean() - kappa) < 0.002
return (fn(yy1) * fn(yy2)).mean()
def prime(x, act):
p = torch.nn.Parameter(x)
y = act(p)
y.sum().backward()
return p.grad
def ntk(kappa, act):
return kappa * dual(lambda x: prime(x, act), kappa) + dual(act, kappa)
print(ntk(-0.8, torch.relu)) # -0.0684To see that the kernel has value zero at (i.e., when the two inputs are opposite), visualize that their two sets of activated neurons, and therefore also their sets of weights with any gradient, will be disjoint.
Whereas to see that the value is negative at , visualize that some percent of neurons will be activated by both inputs (in fact, exactly many), and their incoming weights will have almost opposite gradients, so the two inputs will overall have gradients which point in somewhat opposite directions.
Hessian and asymptotic linearization
The kernel we have derived applies only to the initialization-time behavior of the network and its gradients. To extend it to the train-time behavior (i.e., after we take one or more gradient steps), our next step is to analyze the Hessian.
Hessian: Basic calculation
The MLP’s gradients are:
Most weights do not affect the gradients of other weights. In particular, none of the rows of affect any of the other rows. And between and , only interacts with . Changes to do not affect its own gradient. So the only nonzero interactions are:
Hessian: spectral norm
Theorem. If , then the spectral norm of the Hessian is bounded by:
Proof. The spectral norm of the Hessian is given by
where is an arbitrary weight update with bounded norm. The matrix , which describes the local impact of the update on the network’s gradient, can be decomposed into a series of sub-blocks based on parts of the gradient.
We first calculate the local impact of on the gradient with respect to :
\begin{align*} (D_WD_{W_{1i}^{(2)}} f_x(W)) U &= \sum_{j=1}^{d_0} D_{W_{ij}^{(1)}}D_{W_{1i}^{(2)}}f_x(W)U_{ij}^{(1)} \ &= \sum_{j=1}^{d_0} \left(\tfrac{1}{\sqrt{d_1}}\sigma'(\tfrac{1}{\sqrt{d_0}}W_i^{(1)}x)\right)(\tfrac{1}{\sqrt{d_0}}x_j) U_{ij}^{(1)} \ &= \tfrac{1}{\sqrt{d_1}}\sigma'(\tfrac{1}{\sqrt{d_0}}W_i^{(1)}x)\tfrac{1}{\sqrt{d_0}} U_ix \end{align*}
Therefore we have:
\begin{align*} |(D_WD_{W^{(2)}} f_x(W)) U|F^2 &= \sum{i=1}^{d_1} (D_WD_{W_{1i}^{(2)}} f_x(W)U)^2 \ &= \sum_{i=1}^{d_1} \left(\tfrac{1}{\sqrt{d_1}}\sigma'(\tfrac{1}{\sqrt{d_0}}W_i^{(1)}x)\tfrac{1}{\sqrt{d_0}} U_ix\right)^2 \ &= \frac{1}{d_1}\sum_{i=1}^{d_1} (\sigma'(\tfrac{1}{\sqrt{d_0}}W_i^{(1)}x))^2(\tfrac{1}{\sqrt{d_0}} U_ix)^2 \ &\leq \frac{1}{d_1}\sum_{i=1}^{d_1} C^2(\tfrac{1}{\sqrt{d_0}} U_ix)^2 \ &= \tfrac{1}{d_1}C^2|\tfrac{1}{\sqrt{d_0}} Ux|_2^2 \ &\leq \tfrac{1}{d_1}C^2 \end{align*}
where we used the assumption that and .
We next calculate the local impact of on the partial derivative of :
\begin{align*} &(D_WD_{W_{ij_1}^{(1)}}f_x(W))U = (D_{W_{1i}^{(2)}}D_{W_{ij_1}^{(1)}}f_x(W))U_{1i}^{(2)} + \sum_{j_2=1}^{d_0} (D_{W_{ij_2}^{(1)}}D_{W_{ij_1}^{(1)}}f_x(W))U_{ij_2}^{(1)} \ &= \left(\tfrac{1}{\sqrt{d_1}}\sigma'(\tfrac{1}{\sqrt{d_0}}W_i^{(1)}x)\right)(\tfrac{1}{\sqrt{d_0}}x_{j_1}) U_{1i}^{(2)} \ &\quad\quad+ \sum_{j_2=1}^{d_0} \left(\tfrac{1}{\sqrt{d_1}}W_{1i}^{(2)}\sigma''(\tfrac{1}{\sqrt{d_0}}W_i^{(1)}x)\right)(\tfrac{1}{\sqrt{d_0}}x_{j_1})(\tfrac{1}{\sqrt{d_0}}x_{j_2})U_{ij_2}^{(1)} \ &= \tfrac{1}{\sqrt{d_1}}\left(\sigma'(\tfrac{1}{\sqrt{d_0}}W_i^{(1)}x)U_{1i}^{(2)} + W_{1i}^{(2)}\sigma''(\tfrac{1}{\sqrt{d_0}}W_i^{(1)}x)\tfrac{1}{\sqrt{d_0}}U_i^{(1)}x\right)\tfrac{1}{\sqrt{d_0}} x_{j_1} \end{align*}
Therefore we have:
\begin{align*} &|(D_WD_{W^{(1)}} f_x(W))U|F^2 = \sum{i=1}^{d_1} \sum_{j=1}^{d_0} ((D_WD_{W_{ij}^{(1)}} f_x(W)) U)^2 \ &= \sum_{i=1}^{d_1} \sum_{j=1}^{d_0} \left(\tfrac{1}{\sqrt{d_1}}\left(\sigma'(\tfrac{1}{\sqrt{d_0}}W_i^{(1)}x)U_{1i}^{(2)} + W_{1i}^{(2)}\sigma''(\tfrac{1}{\sqrt{d_0}}W_i^{(1)}x)\tfrac{1}{\sqrt{d_0}}U_i^{(1)}x\right)\tfrac{1}{\sqrt{d_0}} x_j\right)^2 \ &= \frac{1}{d_1}\sum_{i=1}^{d_1} \left(\sigma'(\tfrac{1}{\sqrt{d_0}}W_i^{(1)}x)U_{1i}^{(2)} + W_{1i}^{(2)}\sigma''(\tfrac{1}{\sqrt{d_0}}W_i^{(1)}x)\tfrac{1}{\sqrt{d_0}}U_i^{(1)}x\right)^2 \ &\leq \frac{1}{d_1}\sum_{i=1}^{d_1} \left(C|U_{1i}^{(2)}| + |W_{1i}^{(2)}|\cdot C \cdot |\tfrac{1}{\sqrt{d_0}}U_i^{(1)}x|\right)^2 \ &\leq C^2\frac{1}{d_1}\sum_{i=1}^{d_1} \left(|U_{1i}^{(2)}| + |W^{(2)}|_\infty|\tfrac{1}{\sqrt{d_0}}U_i^{(1)}x|\right)^2 \ &\leq C^2\frac{1}{d_1}\left(|U^{(2)}|F^2 + 2|W^{(2)}|\infty|U^{(2)}|_F|U^{(1)}|F + |W^{(2)}|\infty^2 |U^{(2)}|_F^2\right) \ &= C^2\frac{1}{d_1}\left(|U^{(2)}|F + |W^{(2)}|\infty|U^{(1)}|F\right)^2 \ &\leq C^2\tfrac{1}{d_1}\left(1 + |W^{(2)}|\infty\right)^2 \ \end{align*}
Therefore the overall squared Frobenius norm is bounded by:
\begin{align*} |(D^2f_a(W))U|F^2 &= |(D_WD{W^{(2)}} f_x(W))U|F^2 + |(D_WD{W^{(1)}}f_x(W))U|F^2 \ &= \tfrac{1}{d_1} C^2(1+(1+|W^{(2)}|\infty)^2) \ &\leq 2C^2\tfrac{1}{d_1} (1+|W^{(2)}|_\infty)^2 \end{align*}
which is the theorem.
Intuition: If you make the MLP extremely wide, then you can still have a impact on any given input’s output just by changing the weights by an update of size . However, each neuron’s contribution shrinks by $1/d_1$, and curvature only happens for neurons whose individual connections (incoming or outgoing) change by . So only at most neurons can have any curvature. Indeed, .
Remark: The conditions we placed on the derivatives of allow it to include the sigmoid, GELU, arbitrarily-smoothed-ReLU, and ReLU activations, which is essentially everything used in practice.
Setup: optimization trajectories
Let be the weights of the MLP at initialization. Then we define an optimization trajectory to be a series of weight updates , where each update is given by some linear mixture of the weight-output gradients of each input in the dataset. In particular, we assume that
for some weighting , which may be a function of the current weights. For example, might be the output-loss derivatives for each of the examples, for some loss function.
We also write
to denote the outputs of the model after the th update step.
Note that the number of steps may also be a function of the width or dataset size.
We now begin proving smoothness lemmas about this trajectory. Each holds almost-surely. We use the assumption that throughout, which for example implies .
Smoothness lemmas
Lemma S0. If and , then every weight along the optimization trajectory satisfies .
Proof. The satisfaction of this condition at initialization is given by elementary properties of Gaussian variables.
Now let be any input with . And let be any weight. Then we have:
\begin{align*} |\nabla_{W^{(2)}} f_x(W)|\infty &= |\tfrac{1}{\sqrt d_1}\sigma(\tfrac{1}{\sqrt d_0}W^{(1)}x)|\infty \ &\leq \tfrac{1}{\sqrt d_1}\max_{1 \leq i \leq d_1}|W_i^{(1)}|_2 \end{align*}
and
\begin{align*} \max_{1 \leq i \leq d_1} |\nabla_{W_i^{(1)}} f_x(W)|2 &= \max{1 \leq i \leq d_1} |\tfrac{1}{\sqrt d_1}W_{1i}^{(2)}\tfrac{1}{\sqrt d_0}x|2 \ &\leq \tfrac{1}{\sqrt d_1}|W^{(2)}|\infty \end{align*}
Therefore, the condition , is preserved by any update of the form where satisfies and . In particular, we can perform an arbitrary such updates, and still preserve the property. In particular, we will preserve .
Given Lemma S0, in all future lemmas, when we write , the conditions shall be understood to include . In particular, can be understood to be a supremum over all possible updates in a trajectory (including sums of updates). Similarly, lemmas involving shall hold uniformly for all such that , (i.e., for a fixed function in that growth class).
Lemma S1. Let be the weights at initialization. Then almost-surely we have both:
Proof. For the first statement, We have:
\begin{align*} \sup_{U : |U|F \leq o(d_1^\gamma)} &\left|f_x(W + U) - \left(f_x(W) + (Df_x(W))U\right)\right| \ &\leq \sup_U\sup{\lambda \in [0, 1]}\lambda^2 ((D^2f_x(W + \lambda U))U)U \ &\leq \sup_U\sup_{\lambda \in [0, 1]} |D^2f_a(W + \lambda U)|* |U|F \ &\leq \sup_U\sup{\lambda \in [0, 1]} O(d_1^{-1/2})|W + \lambda U|\infty |U|F \ &= \sup_U\sup{\lambda \in [0, 1]} O(d_1^{-1/2})(|W^{(2)}|\infty + |U^{(2)}|\infty) |U|_F \ &= \sup_U O(d_1^{-1/2})(\tilde O(1) + \tilde O(1)) \tilde o(d_1^\gamma) \ &= \tilde o(d_1^{\gamma-1/2}) \end{align*}
Where we use the Hessian theorem and obtain , where hides logarithmic factors, from a preliminary lemma.
For the second statement, we have:
\begin{align*} |\nabla f_x(W + U) - \nabla f_x(W)|F &\leq \sup{0 \leq \lambda \leq 1}|D^2f_x(W + \lambda U)|* |U|F \ &\leq O(d_1^{-1/2})(|W|\infty + |U|\infty)|U|_F \ &\leq \tilde o(d_1^{\gamma-1/2}). \end{align*}
In addition, as long as we stay within this radius, the dot products between gradients will stay close to what they would have been at initialization.
Lemma S2. Almost-surely:
Proof. Each entry of is a difference of the form
for some pair of columns of . This is bounded by
\begin{align*} &|\langle \nabla f_x(W + U), \nabla f_{\tilde x}(W + U) \rangle - \langle \nabla f_x(W), \nabla f_{\tilde x}(W) \rangle| \ &= \Big|\left(\langle \nabla f_x(W + U), \nabla f_{\tilde x}(W + U) \rangle - \langle \nabla f_x(W + U), \nabla f_{\tilde x}(W) \rangle\right) \ &\quad+ \left(\langle \nabla f_x(W + U), \nabla f_{\tilde x}(W) \rangle - \langle \nabla f_x(W), \nabla f_{\tilde x}(W) \rangle\right)\Big| \ &= \Big|\langle \nabla f_x(W + U), \nabla f_{\tilde x}(W + U) - \nabla f_{\tilde x}(W) \rangle + \langle \nabla f_x(W + U) - \nabla f_x(W), \nabla f_{\tilde x}(W) \rangle\Big| \ &\leq |\nabla f_x(W + U)||\nabla f_{\tilde x}(W + U) - \nabla f_{\tilde x}(W)| + |\nabla f_x(W + U) - \nabla f_x(W)||\nabla f_{\tilde x}(W)| \ &\leq \left(|\nabla f_x(W)| + |\nabla f_x(W + U) - \nabla f_x(W)|\right)|\nabla f_{\tilde x}(W + U) - \nabla f_{\tilde x}(W)| \ &\quad+ |\nabla f_x(W + U) - \nabla f_x(W)||\nabla f_{\tilde x}(W)| \ &\leq \left(|\nabla f_x(W)| + o(d_1^{\gamma-1/2})\right)o(d_1^{\gamma-1/2}) + o(d_1^{\gamma-1/2})||\nabla f_{\tilde x}(W)| \ &= \left(|\nabla f_x(W)| + |\nabla f_{\tilde x}(W)|\right)o(d_1^{\gamma-1/2}) \end{align*}
where we used Lemma S1, assuming that .
Using the NTK convergence theorem, we have , where the assumption that inputs have bounded norm implies that the entries of the NTK are bounded by a constant. Therefore, , uniformly across the columns, and so the asymptotic limit is just .
Lemma S3. Uniformly across all gradient weightings , we have:
Proof.
\begin{align*} |G(W+U)\beta|F^2 &= (G(W+U)\beta)^\top (G(W+U)\beta) \ &= \beta^\top K(W+U)\beta \ &\leq |\beta|1^2 |K(W+U)|\infty \ &= |\beta|1^2 (|K\infty|\infty + \tilde O(d_1^{-1/2}) + \tilde O(d_1^{\gamma-1/2})) \ &= |\beta|_1^2O(1) \end{align*}
where we used Lemma S2 to control by with , and the main NTK convergence theorem to control by .
S4, in which we lose square-root scaling
Lemma S4. Assume that . Then uniformly across all , we have:
where are the weights after taking a gradient step weighted by .
Proof.
First, observe that Lemma S3 implies . Therefore the entire difference from initialization has , so Lemma S1 applies, proving that:
which combine to yield
so it remains to prove that .
Define . Then we have
\begin{align*} |(\beta - K(W)\beta){n_1}| &= |G(W){:n_1}^\top (G(W+U) - G(W))\beta| \ &\leq |G(W){:n_1}|F|(G(W+U) - G(W))\beta|F \ &= O(1)|(G(W+U) - G(W))\beta|F \ &= O(1)\left|\sum{n_2=1}^N \beta{n_2}(\nabla f{x^{(n_2)}}(W+U) - \nabla f{x^{(n_2)}}(W))\right|F \ &\leq O(1) \sum{n_2=1}^N |\beta_{n_2}| |\nabla f_{x^{(n_2)}}(W+U) - \nabla f_{x^{(n_2)}}(W)|F \ &\leq O(1)|\beta|1 \max{n_2 \in {1, \dots, N}} |\nabla f{x^{(n_2)}}(W+U) - \nabla f_{x^{(n_2)}}(W)|_F \ &= |\beta|_1\tilde o(d_1^{\gamma-1/2}) \end{align*}
by Lemma S1. This was uniform across , hence the norm is also .
Remark: The last series of inequalities is essentially tight if, for example, every input is the same.
Trajectory linearization theorem
Denote the NTK by .
Theorem. If , and , then uniformly for all trajectories and timestep pairs $0 \leq t_1 < t_2 \leq T$ we have:
Proof. For any $0 \leq t_1 < t_2 \leq T$, define . Then by the NTK convergence theorem we have uniformly
\begin{align*} |K(W)\beta - \mathrm{NTK}(\tfrac{1}{d_0}X^\top X)\beta|\infty &\leq |K(W) - \mathrm{NTK}(\tfrac{1}{d_0}X^\top X)|\infty|\beta|_1 \ &= \tilde O(d_1^{-1/2}) \tilde O(N) \ &= \tilde o(d_1^{-1/4}) = \tilde o(1/T). \end{align*}
In addition, we have
\begin{align*} &|(\hat y^{(t_2)} - \hat y^{(t_1)}) - K(W)(\alpha^{(t_1+1)} + \dots + \alpha^{(t_2)}))|\infty \ &\quad\leq \sum{s=t_1+1}^{t_2} |(\hat y^{(s)} - \hat y^{(s-1)}) - K(W)\alpha^{(s)}|\infty \ &\quad= \sum{s=t_1+1}^{t_2} |(f_X(\widetilde{W}) - f_X(W + U) - K(W)\alpha^{(s)}|\infty \ &\quad\leq \sum{s=t_1+1}^{t_2} (1 + |\alpha^{(s)}|_1)\tilde o(d_1^{1/4-1/2}) \ &\quad= (t_2-t_1)(1 + \tilde O(N/T))\tilde o(d_1^{-1/4}) \ &\quad= (t_2-t_1)(\tilde o(d_1^{-1/4}) + \tilde o(1/T)) \ &\quad= (t_2-t_1)(\tilde o(1/T) + \tilde o(1/T)) = (t_2-t_1)\tilde o(1/T) \end{align*}
where we define and so that Lemma S4 yields the second inequality, because we have uniformly
by Lemma S3. So combining these yields the theorem.
Application to square-loss gradient descent
Now suppose instead that is a vector of linear regression targets, with loss
Then it can be verified that he gradient descent trajectory with learning rate is given by
We assume that the maximum regression target does not grow super-logarithmically with the dataset size, e.g., can be sampled as Gaussians, or any bounded distribution.
Theorem. If , and $0 < \eta \leq \mathrm{NTK}(\kappa=1)/N$, then uniformly for all timesteps $1 \leq t \leq T$ we have:
Proof. We first analyze the spectral norm . Observe that , so . Therefore, $0 < |\eta K_\infty|* \leq 1$, where we know it is positive since must be nonzero. Therefore $0 \leq |I - \eta K\infty|_\infty < 1$ as well, since is positive semidefinite. (To see that is PSD, note that by definition, it can be arbitrarily well-approximated by where are the gradients from a wide network)
We next observe that each entry , as usual due to standard properties of Gaussian variables and our assumption that . Therefore, in particular, .
Now inductively assume that uniformly across $0 \leq s \leq t$, we have
that is, assume the statement holds for all such , such that we can replace with a single function which is in .
The base case is trivial. We will prove that the statement holds for $0 \leq s \leq t+1$ uniformly as well. First, observe that the inductive assumption implies that for $1 \leq s \leq t$ we have uniformly
\begin{align*} |\hat y^{(s)} - y|1 &\leq \sqrt N |\hat y^{(s)} - y|2 \ &\leq \sqrt N\Big(|(\hat y^{(s)} - y) - (I - \eta K\infty)^s(\hat y^{(0)} - y)|2 + |(I - \eta K\infty)^s(\hat y^{(0)} - y)|2\Big) \ &\leq N\tilde o(1) + \sqrt N|I - \eta K\infty|^s|\hat y^{(0)} - y|_2 \ &\leq \tilde o(N) + \sqrt N \tilde O(\sqrt N) \ &= \tilde O(N) \end{align}
hence using our assumption that , we obtain that uniformly
so we can therefore apply that trajectory linearization theorem to obtain that
uniformly across $1 \leq s \leq t$. This allows us to control the norm via the following.
\begin{align*} &|(\hat y^{(t)} - y) - (I - \eta K_\infty)^t(\hat y^{(0)} - y)|2 \ &\quad\quad\leq \sum{s=1}^t |(I - \eta K_\infty)^{t-s}(\hat y^{(s)} - y) - (I - \eta K_\infty)^{t-s+1}(\hat y^{(s-1)} - y)|2 \ &\quad\quad\leq \sum{s=1}^t |I - \eta K_\infty|*^{t-s}|(\hat y^{(s)} - y) - (I - \eta K\infty)(\hat y^{(s-1)} - y)|2 \ &\quad\quad= \sum{s=1}^t |I - \eta K_\infty|*^{t-s}|(\hat y^{(s)} - \hat y^{(s-1)}) - \eta K\infty(y - \hat y^{(s-1)})|2 \ &\quad\quad\leq \sum{s=1}^t |I - \eta K_\infty|*^{t-s}\sqrt N|(\hat y^{(s)} - \hat y^{(s-1)}) - \eta K\infty(y - \hat y^{(s-1)})|\infty \ &\quad\quad= \sum{s=1}^t |I - \eta K_\infty|*^{t-s}\sqrt N\tilde o(1/T) \ &\quad\quad= \sqrt N \cdot \tilde o(1)(1 - |I - \eta K\infty|_)^{-1} \ &\quad\quad= \sqrt N \cdot \tilde o(1) \end{align}
Therefore, the induction carries through and we obtain uniformly
for all $1 \leq t \leq T$, which is equivalent to the theorem statement.
Rate of convergence
In addition to the setup of the previous theorem, assume that the smallest eigenvalue of is . This implies that where . Then using the theorem we have
\begin{align*} |\hat y^{(t)} - y|2 &\leq |(\hat y^{(t)} - y) - (I - \eta K\infty)^t(\hat y^{(0)} - y)|2 + |(I - \eta K\infty)^t(\hat y^{(0)} - y)|2 \ &\leq \sqrt N \tilde o(1) + |I - \eta K\infty|*^t \tilde O(\sqrt N) \ &= \tilde O(\sqrt N) (\tilde o(1) + |I - \eta K\infty|_^t) \ &\leq \tilde O(\sqrt N) (\tilde o(1) + (1 - c/N)^t) \ &\leq \tilde O(\sqrt N) (\tilde o(1) + e^{-tc/N}) \ \end{align}
Therefore, if we let grow faster than , while still validly satisfying (e.g., ), then we get
which is equivalent to
that is, that the average square loss decreases to zero as we scale everything up.
However, this assumption is not necessarily realistic. It is easily possible that as we scale up the data, the smallest eigenvalue goes to zero. For example, if there are any duplicates then this will be the case. If there are duplicates, then as in any regression problem, we will have to hope that their regression targets are also equal; otherwise the problem is not perfectly solvable.
On the other hand, if all of the points are orthogonal, as is assumed in some theory papers about this topic, then for essentially any nontrivial activation function the condition will be satisfied.
Convergence theorem. Given orthogonal inputs, and arbitrary bounded regression targets, in the limit as we scale everything up, an MLP with one hidden layer will perfectly solve the regression after steps of gradient descent.
It seems tempting to think that, because the inputs are orthogonal, we could realisticly only use steps of gradient descent with a constant learning rate. However, if the targets are all-positive, then this will still lead to diverging oscillation, due to the fact that .
Appendix
Dual of an activation
Definition
Definition. For any activation function , its dual is
That is, the expected outer product of where is centered Gaussian with covariance matrix . If is not positive semidefinite, the output is undefined.
Intuition: The dual activation describes how the activation function transforms the statistics of Gaussian distributions.
We overload the definition of to apply to all at once, so that the following proposition statement makes sense.
Proposition. For any covariance matrix , the outputs of are determined by its outputs on $2\times2$ covariance matrices via:
Proof.
\begin{align*} {\mathbb E}{z \sim {\mathcal N}(0, \Lambda)}\left[\sigma(z)\sigma(z)^\top\right]{ij} &= {\mathbb E}{z \sim {\mathcal N}(0, \Lambda)}\left[\sigma(z)i\sigma(z)j\right] \ &= {\mathbb E}{z, \tilde z \sim {\mathcal N}\left(0, \begin{smallmatrix}\Lambda{ii} & \Lambda{ij} \ \Lambda_{ji} & \Lambda_{jj}\end{smallmatrix}\right)}\left[\sigma(z)\sigma(\tilde z)\right] \ &= \mathring{\sigma}\left(\begin{smallmatrix}\Lambda_{ii} & \Lambda_{ij} \ \Lambda_{ji} & \Lambda_{jj}\end{smallmatrix}\right)_{12} \end{align*}
Proposition. For any PSD input , and any activation , is positive semidefinite.
Proof. It’s a covariance matrix of a random vector with itself, which is always PSD.
We further overload the definition by defining via:
This version can be consistently applied elementwise in the case that has unit diagonal.
Proposition. If is a covariance matrix satisfying , then
Proof. Follows easily from the previous proposition.
ReLU case
Theorem. If , then
\begin{align*} \mathring{\sigma}(\kappa) &= \tfrac{1}{\pi}\sqrt{1-\kappa^2} + \kappa(1 - \tfrac2\pi\sin^{-1}(\sqrt{(1-\kappa)/2})) \ \mathring{\sigma}'(\kappa) &= \tfrac2\pi\sin^{-1}(\sqrt{(1+\kappa)/2}) \end{align*}
Proof. A bunch of calculus.
Gaussians are almost bounded
Proposition. Let be IID Gaussian. Then
Proof.
\begin{align*} P\left(\max_{i=1, \dots, n} X_i^2 \geq \log^{3/2}n\quad \text{i.o.}\right) &= P\left(X_n^2 \geq \log^{3/2}n\quad \text{i.o.}\right) \ &\leq 1\left{\sum_{n=1}^\infty P(|X_n| \geq \log^{3/4}n) = \infty\right} \ &\leq 1\left{\sum_{n=1}^\infty \exp(-O((\log^{3/4}n)^2)) = \infty\right} \ &\leq 1\left{\sum_{n=1}^\infty O(n^{-3/2}) = \infty\right} \ &\leq 0. \end{align*}
Remark: Check a standard textbook for the complete proof of this fact.
Generic sub-exponential large deviation bound
Theorem. Suppose that satisfies for some . And let , and where is an IID copy of . Then for every , we have
Proof. Suppose that a positive variable satisfies for some . Then certainly the variable satisfies and . Therefore for
whenever , that is, .
Now let where are IID copies of . Then we have
Therefore:
\begin{align*} P(S \geq Na) &\leq \inf_{\theta > 0}\frac{{\mathbb E}[e^{\theta S}]}{e^{\theta Na}} \ &\leq \inf_{\theta > 0} e^{N(c\theta)^2/(1-c\theta) - N \theta a} \ &= e^{-N(\sup_{\theta > 0}(\theta a - (c\theta)^2/(1-c\theta)))} \ \end{align*}
which can be solved by setting , that is:
QUADRATIC EQUATION for .
We require for the series to converge, so the solution is
which yields
\begin{align*} \sup_{\theta > 0}(\theta a - (c\theta)^2/(1-c\theta)) &= \theta^a - (1-\sqrt{\tfrac{c}{a+c}})^2/\sqrt{\tfrac{c}{a+c}} \ &= \tfrac{a}{c}(1 - \sqrt{\tfrac{c}{a+c}}) - (\sqrt{\tfrac{a+c}{c}} - 2 + \sqrt{\tfrac{c}{a+c}}) \ &= 2 + \tfrac{a}{c} - \tfrac{a}{c}\sqrt{\tfrac{c}{a+c}} - \sqrt{\tfrac{a+c}{c}} - \sqrt{\tfrac{c}{a+c}} \ &= 2 + \tfrac{a}{c} - (1 + \tfrac{a}{c})\sqrt{\tfrac{c}{a+c}} - \sqrt{\tfrac{a+c}{c}} \ &= 2 + \tfrac{a}{c} - \tfrac{a+c}{c}\sqrt{\tfrac{c}{a+c}} - \sqrt{\tfrac{a+c}{c}} \ &= 2 + \tfrac{a}{c} - 2\sqrt{\tfrac{a+c}{c}} \ &= 2 + \tfrac{a}{c} - 2\sqrt{1 + \tfrac{a}{c}} \ \end{align}
which can be controlled by the observation that if we define , then and . If we assume that , then this is at least . Therefore if then and hence .
Therefore we have
And so, putting it all together, we get
Remark: I have been informed by GPT-o1 that what I’ve done here could also be more easily accomplished by invoking something called the Bernstein inequality for sub-exponential variables.
The remaining two sections are not depended upon by anything else in this note.
Linear regression dynamics
Suppose that we are solving a linear regression problem with dataset and targets using gradient descent. That is, we want to solve
using gradient updates
\begin{align*} w' &= w - \eta \nabla_w \tfrac12 |Xw - y|_2^2 \ &= w - \eta X^\top (Xw - y). \ \end{align*}
Now suppose that we know the kernel matrix of dot products between examples. Then we can write the dynamics of the residuals as
\begin{align*} r' &= (y - Xw') \ &= (y - X(w - \eta X^\top (Xw - y))) \ &= (y - Xw - \eta XX^\top (y - Xw)) \ &= (1 - \eta K)(y - Xw) \ &= (1 - \eta K)r \end{align*}
Therefore, if we know the kernel of a linear regression problem, then we can easily predict the dynamics of its residual under gradient descent.
Application to cross-entropy gradient descent trajectory
We now extend the linearization theorem to apply to a trajectory resulting from gradient descent against a logistic loss function. Let be a vector of logistic targets for the dataset . And define the loss function via:
It can be verified that the gradient descent trajectory with learning rate is defined by
We can easily apply the theorem to prove that this trajectory is linearized, since we have
hence when . Therefore, we get the linearization