Title: UNDERSTANDING WHY NEURAL NETWORKS GENER-ALIZE WELL THROUGH GSNR OF PARAMETERS

Abstract: As deep neural networks (DNNs) achieve tremendous success across many application domains, researchers tried to explore in many aspects on why they generalize well. In this paper, we provide a novel perspective on these issues using the gradient signal to noise ratio (GSNR) of parameters during training process of DNNs. The GSNR of a parameter is defined as the ratio between its gradient's squared mean and variance, over the data distribution. Based on several approximations, we establish a quantitative relationship between model parameters' GSNR and the generalization gap. This relationship indicates that larger GSNR during training process leads to better generalization performance. Moreover, we show that, different from that of shallow models (e.g. logistic regression, support vector machines), the gradient descent optimization dynamics of DNNs naturally produces large GSNR during training, which is probably the key to DNNs' remarkable generalization ability.

1. INTRODUCTION:

Deep neural networks typically contain far more trainable parameters than training samples, which seems to easily cause a poor generalization performance. However, in fact they usually exhibit remarkably small generalization gaps. Traditional generalization theories such as VC dimension (Vapnik & Chervonenkis, 1991) or Rademacher complexity (Bartlett & Mendelson, 2002) cannot explain its mechanism. Extensive research focuses on the generalization ability of DNNs (Neyshabur et al., 2017; Arora et al., 2018; Keskar et al., 2016; Dinh et al., 2017; Hoffer et al., 2017; Novak et al., 2018; Dziugaite & Roy, 2017; Jakubovitz et al., 2019; Kawaguchi et al., 2017; Advani & Saxe, 2017) .

Unlike that of shallow models such as logistic regression or support vector machines, the global minimum of high-dimensional and non-convex DNNs cannot be found analytically, but can only be approximated by gradient descent and its variants (Zeiler, 2012; Kingma & Ba, 2014; Graves, 2013) . Previous work (Zhang et al., 2016; Hardt et al., 2015; Dziugaite & Roy, 2017) suggests that the generalization ability of DNNs is closely related to gradient descent optimization. For example, Hardt et al. (2015) claims that any model trained with stochastic gradient descent (SGD) for reasonable epochs would exhibit small generalization error. Their analysis is based on the smoothness of loss function. In this work, we attempt to understand the generalization behavior of DNNs through GSNR and reveal how GSNR affects the training dynamics of gradient descent. Stanislav Fort (2019) studied a new gradient alignment measure called stiffness in order to understand generalization better and stiffness is related to our work.

The GSNR of a parameter is defined as the ratio between its gradient's squared mean and variance over the data distribution. Previous work tried to use GSNR to conduct theoretical analysis on deep learning. For example, Rainforth et al. (2018) used GSNR to analyze variational bounds in unsupervised DNNs such as variational auto-encoder (VAE). Here we focus on analyzing the relation between GSNR and the generalization gap.

Intuitively, GSNR measures the similarity of a parameter's gradients among different training samples. Large GSNR implies that most training samples agree on the optimization direction of this parameter, thus the parameter is more likely to be associated with a meaningful "pattern" and we assume its update could lead to a better generalization. In this work, we prove that the GSNR is strongly related to the generalization performance, and larger GSNR means a better generalization.

To reveal the mechanism of DNNs' good generalization ability, we show that the gradient descent optimization dynamics of DNN naturally leads to large GSNR of model parameters and therefore good generalization. Furthermore, we give a complete analysis and a detailed interpretation to this phenomenon. We believe this is probably the key to DNNs remarkable generalization ability.

In the remainder of this paper we first analyze the relation between GSNR and generalization (Section 2). We then show how the training dynamics lead to large GSNR of model parameters experimentally and analytically in Section 3.

2. LARGER GSNR LEADS TO BETTER GENERALIZATION:

In this section, we establish a quantitative relation between the GSNR of model parameters and generalization gap, showing that larger GSNR during training leads to better generalization.

2.1. GRADIENTS SIGNAL TO NOISE RATIO:

Consider a data distribution Z = X × Y, from which each sample (x, y) is drawn; a model ŷ = f (x, θ) parameterized by θ; and a loss function L.

The parameters' gradient w.r.t. L and sample (x i , y i ) is denoted by

g(x i , y i , θ) or g i (θ) := ∂L(y i , f (x i , θ)) ∂θ (1)

whose j-th element is g i (θ j ). Note that throughout this paper we always use i to index data examples and j to index model parameters.

Given the data distribution Z, we have the (sample-wise) mean and variance of g i (θ). We denote them as g(θ) = E (x,y)∼Z (g(x, y, θ)) and ρ 2 (θ) = Var (x,y)∼Z (g(x, y, θ)), respectively.

The gradient signal to noise ratio (GSNR) of one model parameter θ j is defined as:

EQUATION

At a particular point of the parameter space, GSNR measures the consistency of a parameter's gradients across different data samples. Figure 1 intuitively shows that if GSNR is large, the parameter gradient space tends to be distributed in the similar direction and if GSNR is small, the gradient vectors are then scatteredly distributed.

2.2. ONE-STEP GENERALIZATION RATIO:

In this section we introduce a new concept to help measure the generalization performance during gradient descent optimization, which we call one-step generalization ratio (OSGR). Consider training set D = {(x 1 , y 1 ), ..., (x n , y n )} ∼ Z n with n samples drawn from Z, and a test set

D ′ = {(x ′ 1 , y ′ 1 ), ..., (x ′ n ′ , y ′ n ′ )} ∼ Z n ′

. In practice we use the loss on D ′ to measure generalization. For simplicity, we assume the sizes of training and test datasets are equal, i.e. n = n ′ . We denote the empirical training and test loss as:

EQUATION

respectively. Then the empirical generalization gap is given by L 

[D ′ ] -L[D].

R(Z, n):

EQUATION

Note that this ratio also depends on current model parameters θ and learning rate λ. We are not including them in the above notation as we will not explicitly model these dependencies, but rather try to quantitatively characterize R for very small λ and for θ at the early stage of training (satisfying Assumption 2.3.1).

Also note that the expectation of ∆L[D ′ ] is over D and D ′ . This is because the optimization step is performed on D. We refer to R(Z, n) as OSGR of gradient descent optimization. Statistically the training loss decreases faster than the test loss and 0 < OSGR(t) < 1 (Middle panel of Figure 2 ), which usually results in a non-zero generalization gap at the end of training. If OSGR(t) is large (≈ 1) in the whole training process (Right panel of Figure 2 ), generalization gap would be small when training completes, implying good generalization ability of the model. If OSGR(t) is small (= 0), the test loss will not decrease while the training loss normally drops (Left panel of Figure 2 ), corresponding to a large generalization gap.

2.3. RELATION BETWEEN GSNR AND OSGR:

In this section, we derive a relation between the OSGR during training and the GSNR of model parameters. This relation indicates that, for the first time as far as we know, the sample-wise gradient distribution of parameters is related to the generalization performance of gradient descent optimization.

In gradient descent optimization, we take the average gradient over training set D, which we denote as g D (θ). Note that we have used g i (θ) to denote gradient evaluated on one data sample and g(θ) to denote its expectation over the entire data distribution. Similarly we define g D ′ (θ) to be the average gradient over test set D ′ .

g D (θ) = 1 n n ∑ i=1 g(x i , y i , θ) = ∂L[D] ∂θ , g D ′ (θ) = 1 n n ∑ i=1 g(x ′ i , y ′ i , θ) = ∂L[D ′ ] ∂θ (5)

Both the training and test dataset are randomly generated from the same distribution Z n , so we can treat g D (θ) and g D ′ (θ) as random variables. At the beginning of the optimization process, θ is randomly initialized thus independent of D, so g D (θ) and g D ′ (θ) would obey the same distribution. After a period of training, the model parameters begin to fit the training dataset and become a function of D, i.e. θ = θ(D), therefore distributions of g D (θ(D)) and g D ′ (θ(D)) become different. However we choose not to model this dependency and make the following assumption for our analysis:

Assumption 2.3.1 (Non-overfitting limit approximation) The average gradient over the training dataset and test dataset g D (θ) and g D ′ (θ) obey the same distribution.

Obviously the mean of g D (θ) and g D ′ (θ) is just the mean gradient over the data distribution g(θ).

EQUATION

We denote their variance as σ 2 (θ), i.e.

EQUATION

It is straightforward to show that:

EQUATION

where σ 2 (θ) is the variance of the average gradient over the dataset of size n, and ρ 2 (θ) is the variance of the gradient of a single data sample.

In one gradient descent step, the model parameter is updated by ∆θ

= θ t+1 -θ t = -λg D (θ)

where λ is the learning rate. If λ is small enough, the one-step training and test loss decrease can be approximated by

∆L[D] ≈ -∆θ • ∂L[D] ∂θ + O(λ 2 ) = λg D (θ) • g D (θ) + O(λ 2 ) (9) ∆L[D ′ ] ≈ -∆θ • ∂L[D ′ ] ∂θ + O(λ 2 ) = λg D (θ) • g D ′ (θ) + O(λ 2 ) (10)

Usually there are some differences between the directions of g D (θ) and g D ′ (θ), so statistically ∆L[D] tends to be larger than ∆L[D ′ ] and the generalization gap would increase during training. When λ → 0, in one single training step the empirical generalization gap increases by

∆L[D] - ∆L[D ′ ],

for simplicity we denote this quantity as ▽:

▽ := ∆L[D] -∆L[D ′ ] ≈ λg D (θ) • g D (θ) -λg D (θ) • g D ′ (θ) (11) = λ(g(θ) + ϵ)(g(θ) + ϵ -g(θ) -ϵ ′ ) (12) = λ(g(θ) + ϵ)(ϵ -ϵ ′ ) (13)

Here we replaced the random variables by g D (θ) = g(θ) + ϵ and g D ′ (θ) = g(θ) + ϵ ′ , where ϵ and ϵ ′ are random variables with zero mean and variance σ 2 (θ). Since E(ϵ ′ ) = E(ϵ) = 0, ϵ and ϵ ′ are independent, the expectation of ▽ is

EQUATION

)

where σ 2 (θ j ) is the variance the of average gradient of the parameter θ j .

For simplicity, when it involves a single model parameter θ j , we will use only a subscript j instead of the full notation. For example, we use σ 2 j , r j , and g D,j to denote σ 2 (θ j ), r(θ j ), and g D (θ j ) respectively.

Consider the expectation of ∆L[D] and ∆L[D:

′ ] when λ → 0 E D∼Z n (∆L[D]) ≈ λE D∼Z n (g D (θ) • g D (θ)) = λ ∑ j E D∼Z n (g 2 D,j ) (15) E D,D ′ ∼Z n (∆L[D ′ ]) = E D,D ′ ∼Z n (∆L[D] -▽) (16) ≈ λ ∑ j (E D∼Z n (g 2 D,j ) -σ 2 j ) (17) = λ ∑ j (E D∼Z n (g 2 D,j ) -ρ 2 j /n) (18)

Substituting ( 18) and ( 15) into (4) we have:

EQUATION

Although we derived eq. ( 19) from simplified assumptions, we can empirically verify it by estimating two sides of the equation on real data. We will elaborate on this estimation method in section 2.4.

We can rewrite eq. ( 19) as:

R(Z, n) = 1 - 1 n ∑ j E D∼Z n (g 2 D,j ) ∑ j ′ E D∼Z n (g 2 D,j ′ ) ρ 2 j E D∼Z n (g 2 D,j ) (20) = 1 - 1 n ∑ j E D∼Z n (g 2 D,j ) ∑ j ′ E D∼Z n (g 2 D,j ′ ) 1 r j + 1 n (21)

where

E D∼Z n (g 2 D,j ) = V ar D∼Z n (g D,j ) + E 2 D∼Z n (g D,j ) = 1 n ρ 2 j + g2 j .

We define ∆L j [D] to be the training loss decrease caused by updating θ j . We can show that when λ is very small ∆L j [D] = λg 2 D,j + O(λ 2 ). Therefore when λ → 0, we have

R(Z, n) = 1 - 1 n ∑ j W j 1 r j + 1 n , where W j := E D∼Z n (∆L j [D]) E D∼Z n (∆L[D]) with ∑ j W j = 1 (22)

Eq. ( 22) shows that the GSNR r j plays a crucial role in the model's generalization ability-the onestep generalization ratio in gradient descent equals one minus the weighted average of 1 rj + 1 n over all model parameters divided by n. The weight is proportional to the expectation of the training loss decrease resulted from updating that parameter. This implies that larger GSNR of model parameters during training leads to smaller generalization gap growth thus better generalization performance of the trained model. Also note when n → ∞, we have R(Z, n) → 1, meaning that training on more data helps generalization.

2.4. EXPERIMENTAL VERIFICATION OF THE RELATION BETWEEN GSNR AND OSGR:

The relation between GSNR and OSGR, i.e. eq. ( 19) or ( 22) can be empirically verified using any dataset if: (1) The dataset includes enough samples to construct many training sets and a large enough test set so that we can reliably estimate ρ 2 j , E D∼Z n (g 2 D,j ) and OSGR.

(2) The learning rate is small enough. (3) In the early training stage of gradient descent.

To empirically verify eq. ( 19), we show how to estimate its left and right hand sides, i. 

R t (Z, n) ≈ ∑ M m=1 L ′ (m) t+1 -L ′ (m) t ∑ M m=1 L (m) t+1 -L (m) t (23)

For the model trained on the m-th training set, we can compute the t-th step average gradient and sample-wise gradient variance of θ j on the corresponding training set, denoted as g m,j,t and ρ 2 m,j,t , respectively. Therefore the right hand side of eq. ( 19) can be estimated by

EQUATION

We performed the above estimations on MNIST with a simple CNN structure consists of 2 Conv-Relu-MaxPooling blocks and 2 fully-connected layers. First, to estimate eq. ( 24) with M = 10, we randomly sample 10 training sets with size n and a test set with size 10,000.

To cover different conditions, we (1) choose n ∈ {1000, 2000, 4000, 6000, 8000, 10000, 15000}, respectively;

(2) inject noise by randomly changing the labels with probability p random ∈ {0.0, 0.1, 0.2, 0.3, 0.5};

(3) change the model structure by varying number of channels in the layers, ch ∈ {6, 8, 10, 12, 14, 16, 18, 20}. See Appendix A for more details of the setup. We use the gradient descent training (not SGD), with a small learning rate of 0.001. The left and right hand sides of 19 at different epochs are shown in Figure 3 , where each point represents one specific choice of the above settings.

At the beginning of training, the data points are closely distributed along the dashed line corresponding to LHS=RHS. This shows that eq. ( 19) fits quite well under a variety of different settings. As training proceeds, the points become more scattered as the non-overfitting limit approximation no longer holds, but correlation between the LHS and RHS remains high even when the training converges (at epoch 2,500). We also conducted the same experiment on CIFAR10 A.2 and a toy dataset A.3 observed the same behavior. See Appendix for these experiments.

The empirical evidence together with our previous derivation of eq. ( 19) clearly show the relation between GSNR and OSGR and its implication in the model's generalization ability.

3. TRAINING DYNAMICS OF DNNS NATURALLY LEADS TO LARGE GSNR:

In this section, we analyze and explain one interesting phenomenon: the parameters' GSNR of DNNs rises in the early stages of training, whereas the GSNR of shallow models such as logistic regression or support vector machines declines during the entire training process. This difference gives rise to GSNR's large practical values during training, which in turn is associated with good generalization. We analyze the dynamics behind this phenomenon both experimentally and theoretically.

3.1. GSNR BEHAVIOR OF DNNS TRAINING:

For shallow models, the GSNR of parameters decreases in the whole training process because gradients become small as learning converges. But for DNNs it is not the case. We trained DNNs on the CIFAR datasets and computed the GSNR averaged over all model parameters. Because E D∼Z n (g 2 D,j ) = 1 n ρ 2 j + g2 j and we assume n is large, E D∼Z n (g 2 D,j ) ≈ g2 j . In the case of only one large training datasets, we estimate GSNR of t-th iteration by

EQUATION

As shown in Figure 4 , the GSNR starts out low with randomly initialized parameters. As learning progresses, the GSNR increases in the early training stage and stays at a high level in the whole learning process. For each model parameter, we also computed the proportion of the samples with the same gradient sign, denoted as p same_sign . In Figure 4c , we plot the mean of time series of this proportion for all the parameters. This value increases from about 50% (half positive half negetive due to random initialization) to about 56% finally, which indicates that for most parameters, the gradient signs on different samples become more consistent. This is because meaningful features begin to emerge in the learning process and the gradients of the weights on these features tend to have the same sign among different samples.

Previous research (Zhang et al., 2016) showed that DNNs achieved zero training loss by memorizing training samples even if the labels were randomized. We also plot the average GSNR for model trained using data with randomized labels in Figure 4 and find that the GSNR stays at a low level throughout the training process. Although the training loss of both the original and randomized labels go to zero (not shown), the GSNR curves clearly distinguish between these two cases and reveal the lack of meaningful patterns in the latter one. We believe this is the reason why DNNs trained on real and random data lead to completely different generalization behaviors. 

3.2. TRAINING DYNAMICS BEHIND THE GSNR BEHAVIOR:

In this section we show that the feature learning ability of DNNs is the key reason why the GSNR curve behavior of DNNs is different from that of shallow models during the gradient descent training.

To demonstrate this, a simple two-layer perceptron regression model is constructed. A synthetic dataset is generated as following. Each data point is constructed i.i.d. using y = x 0 x 1 + ϵ, where x 0 and x 1 are drawn from uniform distribution [-1, 1] and ϵ is drawn from uniform distribution [-0.01, 0.01]. The training set and test set sizes are 200 and 10,000, respectively. We use a very simple two-layer MLP structure with 2 inputs, 20 hidden neurons and 1 output.

We randomly initialized the model parameters and trained the model on the synthetic training dataset.

As a control setup we also tried to freeze model weights in the first layer to prevent it from learning features. Note that a two layer MLP with the first layer frozen is equivalent to a linear regression model. That is, regression weights are learned on the second layer using fixed features extracted by the first layer. We plot the average GSNR of the second layer parameters for both the frozen and non-frozen cases. Figure 5 shows that in the non-frozen case, the average GSNR over parameters of the second layer shows a significant upward process, whereas in the frozen case the average GSNR decreases in the beginning and remains at a low level during the whole training process.

In the non-frozen case, GSNR curve of individual parameters of the second layer are shown in Figure 5 . The GSNR for some parameters show a significant upward process. To measure the quality of these features, we computed the Pearson correlation between them and the target output y, both at the beginning of training and at the maximum point of their GSNR curves. We can see that the learning process learns "good" features (high correlation value, i.e. with stronger correlation with y) from random initialized ones, as shown in Table 1 . This shows that the GSNR increasing process is related to feature learning.

3.3. ANALYSIS OF TRAINING DYNAMICS BEHIND DNNS' GSNR BEHAVIOR:

In this section, we will investigate the training dynamics behind the GSNR curve behavior. In the case of fully connected network structure, we can analytically show that the numerator of GSNR, i.e. the squared gradient mean of model parameters, tends to increase in the early training stage through feature learning.

Consider a fully connected network, whose parameters are θ = {W (1) , b (1) , ..., W (lmax) , b (lmax) }, where W (1) , b (1) are the weight matrix and bias of the first layer, and so on. We denote the activations of the l-th layer as a (l) = {a (l)

s (θ (l-) )}, where s is the index for nodes/channels of this layer, and θ (l-) is the collection of model parameters in the layers before l, i.e. θ (l-) = {W (1) , b (1) , ..., W (l-1) , b (l-1) }. In the forward pass on data sample i, {a l s (θ (l-) )} is multiplied by the weight matrix W (l) :

EQUATION

where

o (l) = {o (l)

i,c } is the output of the matrix multiplication, for the i-th data sample, on the l-th layer, c = {1, 2, ..., C} is the index of nodes/channels in the (l + 1)-th layer. We use g

(l):

D to denote the average gradient of weights of the l-th layer W (l) , i.e. g (l)

D = 1 n ∑ n i=1 ∂Li ∂W (l)

, where L i is the loss of the i-th sample.

Here we show that the feature learning ability of DNNs plays a crucial role in the GSNR increasing process. More precisely, we show that the learning of features a (l) (θ (l-) ), i.e. the learning of parameters θ (l-) tends to increase the absolute value of g (l)

D . Consider the one-step change of gradient mean ∆g

(l) D = g (l) D,t+1 -g (l)

D,t with the learning rate λ → 0. In one training step, θ is updated by ∆θ = θ t+1 -θ t = -λg D (θ). Using linear approximation with λ → 0, we have

EQUATION

)

where θ (l-) and θ (l+) denote model parameters before and after the l-the layer (including the l-th), respectively.

We focus on the first term of eq. ( 27), i.e. the one-step change of g (l)

D caused by learning θ (l-) . Substituting g 27), we have

(l) D = 1 n ∑ n i=1 ∂Li ∂W (l) and ∆θ j = (-λ 1 n ∑ n i=1 ∂Li ∂θj ) into eq. (

∆g (l) D,s,c = - λ n 2 ∑ θj ∈θ (l-) W (l) s,c ( n ∑ i=1 ∂L i ∂o (l) i,c ∂a (l) i,s ∂θ j ) 2 + other terms (28)

The detailed derivation of eq. ( 28) can be found in Appendix B. We can see the first term (which is a summation over parameters in θ (l-) ) in eq. ( 28) has opposite sign with W (l) s,c . This term will make ∆g Here we show that this negative correlation between ∆g 

(l) s,c with {W (l) s,c > 0, g (l) D,s,c < 0}. Learning θ l-would decrease g (l)

D,s,c and thus increase its absolute value because the first term in eq. ( 28) is negative. On the other hand, learning

W (l) s,c would increase W (l)

s,c and its absolute value because ∆W

(l) s,c = -λg (l)

D,s,c is positive. This will form a positive feedback process, in which the numerator of GSNR, (g

(l)

D,s,c ) 2 , would increase and so is the GSNR. Similar analysis can be done for the case with {W

(l) s,c < 0, g (l) D,s,c > 0}.

On the other hand, when {W 

D,s,c > 0}, the first term in eq. ( 28) is negative, learning θ (l-) tends to decrease g D,s,c < 0} than the opposite. Because weights with small absolute value easily change sign during training, we also plot this proportion for the top-10% weights with larger absolute values. We can see that for the weights with large absolute values, nearly 80% of them have opposite signs with their gradient mean, confirming our earlier analysis. For these weights, the numerator of GSNR, (g

(l)

D,s,c ) 2 , tends to increase through the positive feedback process as discussed above. Different from the experiment on MNIST, we use a deeper network on CIFAR10. We also include the Batch Normalization (BN) layer, because we find that it's difficult for the network to converge in the absence of it. The network consists of 4 Conv-BN-Relu-Conv-BN-Relu-MaxPooling blocks and 3 fully-connected layers. More details are shown in Table 3 . 32 * q 8 * q fc + relu 8 * q 8 * q fc 8 * q 10 softmax --

The experiment is conducted under a similar setting as that of MNIST in section 2.4. We choose n ∈ {2000, 4000, 6000, 8000, 10000}, p random ∈ {0.0, 0.2, 0.4}, ch ∈ {6, 8, 10, 12, 14, 16, 18}.

We use the gradient descent training (Not SGD), with a small learning rate of 0.001. The left and right hand sides of 19 at different epochs are shown in Figure 7 , where each point represents one specific combination of the above settings. Note that at the evaluation step of every epoch, we use At the beginning of training, compared to that of MNIST, the data points no longer perfectly resides on the diagonal dashed line. We suppose that's beacuse of the presence of BN layer, whose internal parameters, i.e. running mean and running variance, are not regular learnable parameters in the optimization process, but change their values in a different way. Their change affects the OSGR, yet we could not include them in the estimation of OSGR. However, the strong positive correlation between the left and right hand sides of eq. ( 19) can always be observed until the training begins to converge.

A.3 EXPERIMENT ON TOY DATASET:

In this section we show a simple two-layer regression model consists of a FC-Relu structure with only 2 inputs, 1 hidden layer with N neurons and 1 output. A similar synthetic dataset with the training data used in the experiment of Section 3.2 is generated as follows. Each data point is constructed i.i.d. using y = x 0 x 1 + ϵ, where x 0 and x 1 are drawn from uniform distribution of [-1, 1] and ϵ is drawn from uniform distribution of [-η noise , η noise ].

To estimate eq. ( 24), we randomly generate 100 training sets with n samples each, i.e. M =100, and a test set with 20,000 samples. To cover different conditions, we (1) choose n ∈ {50, 100, 300, 600, 1000, 2000, 6000};

(2) inject noise with η noise ∈ {0.2, 2, 4, 6, 8};

(3) perturb model structures by choosing N ∈ {6, 8, 10, 12, 14, 16, 18, 20}. We use gradient descent with learning rate of 0.001.

Figure 8 shows a similar behavior as Fig. 3 . During the early training stages, the LHS and RHS of eq. ( 19) are very close. Their highly correlated relation remains until training converges, whereas the RHS of eq. ( 19) decreases significantly.

B APPENDIX B:

Derivation of eq. ( 28) i,s that can both be derived from eq. ( 26). Consider the first term of eq. (33). When s ′ = s, c ′ = c, we have ∆g (l) s,c = - i,s and the terms when s ′ ̸ = s or c ′ ̸ = c in eq. ( 33) are merged into other terms of eq. ( 34). 

∆g (l) D,s,c = ∑ θj ∈θ (l-) ∂g (l) D,s,c ∂θ j ∆θ j + other terms (29) = ∑ θj ∈θ (l-) ∂( 1 n ∑ n i=1 ∂Li ∂W (l) s,c ) ∂θ j (-λ 1 n n ∑ i=1 ∂L i ∂θ j ) + other terms (30) = ∑ θj ∈θ (l-) ∂( 1 n ∑ n i=1 ∂Li ∂o (l) i,c ∂o (l) i,c ∂W (l) s,c ) ∂θ j (- λ n n ∑ i=1 ∑ s ′ ,c ′ ∂L i ∂o (l) i,c ′ ∂o (l) i,c ′ ∂a (l) i,s ′ ∂a (l) i,s ′ ∂θ j ) + other terms (31) = - λ n 2 ∑ θj ∈θ (l-) ∂( ∑ n i=1 ∂Li ∂o (l) i,c a (l) i,s ) ∂θ j ( n ∑ i=1 ∑ s ′ ,c ′ ∂L i ∂o (l) i,c ′ W (l) s ′ ,c ′ ∂a (l) i,s ′ ∂θ j ) + other terms (32) = - λ n 2 ∑ θj ∈θ (l-) n ∑ i=1 ( ∂L i ∂o (l) i,c ∂a (l) i,s ∂θ j + ∂ 2 L i ∂o (l) i,c ∂θ j a (l) i,s )( ∑ s ′ ,c ′ W (l) s ′ ,c ′ n ∑ i=1 ∂L i ∂o (l) i,c ′ ∂a (l) i,s ′

C APPENDIX C:



:



Figures and Tables:

Figure 1: Schematic diagram of the sample-wise parameter gradient distribution corresponding to greater (Left) and smaller (Right) GSNR. Pink arrows denote the gradient vectors for each sample while the blue arrow indicates their mean.

Figure 2: Schematic diagram of the training behavior satisfies OSGR(t) = 0 (Left), 0 < OSGR(t) < 1 (Middle) and OSGR(t) ≈ 1 (Right). Note that the Middle scenario most commonly happens in regular tasks.

e. OSGR by definition and OSGR as a function of GSNR. Suppose we have M training sets each with size n, and a test set of size n ′ . We initialize a model and train it separately on the M training sets and test it with the same test set. For the t-th training iteration, we denote the training loss and test loss of the model trained on the m-th training dataset as L (m) t and L ′ (m) t , respectively. Then the left hand

Figure 3: Left hand (LHS or OSGR by definition) and right side (RHS or OSGR as a function of GSNR) of eq. (19). Points are drawn under different experiment settings. Left: LHS vs RHS at epoch 20, 100, 500, 2500. Each point is drawn by LHS and RHS computed at the given epoch under different model structure (number of channels) or training data size; red dotted line is the line of best fit computed by least squares; blue dotted line is the line of reference representing LHS = RHS; the value of c in each title represents the Pearson correlation coefficient between LHS and RHS computed by points in figure. Right: The legend. Different symbols and colors stand for different number of channels and training data size. Different random noise levels are not distinguished. side, i.e. OSGR by definition, of the t-th iteration can be estimated by

Figure 4: (a): GSNR curves generated by a simple network based on real and random data. An obvious upward process in the early training stage was observed for real data only. (b): Same plot for ResNet18. (c): Average of p same_sign for the same model as in (a).

Figure 5: Average GSNR (a) and loss (b) curves for the frozen and non-frozen case. (c): GSNR curves of individual parameters for the non-frozen case.

for a model trained on MNIST for 200 epochs in Figure6a. In the early training stage, they are indeed negatively correlated. For top-10% weights with larger absolute values, the negative correlation is even more significant.

through an interesting mechanism. Consider the weights W

,c > 0}, we show that the weights tend to change into the earlier case, i.e. {W ,c < 0} during training. Consider the case of {W (l) s,c > 0, g

,c is negative. In both cases the weights change into the earlier case with {W ,c < 0}. Similar analysis can be done for the case of {W ,c < 0} is a more stable state in the training process. For a simple model trained on MNIST, We plot the proportion of weights satisfying {W (l) s,c g (l) D,s,c < 0} in Figure 6b and find that there are indeed more weights with {W

Figure 6: MNIST experiments. Left: Correlation between ∆g (l) D,s,c

Figure 7: Left hand (LHS) and right side (RHS) of eq. (19). Points are drawn under different experiment settings. Left figure: LHS vs RHS relation at epoch 20, 100, 500, 1000.

Figure 8: Similar with Fig. 3, but for a toy regression model discussed in in Appendix A.3.

Same as σ 2 (θ j ) r j or r(θ j )Gradient signal to noise ratio (GSNR) of model parameter θ jL[D]Empirical training loss, i.e.,1 n ∑ n i=1 L(y i , f (x i , θ)) L[D ′ ]Empirical test loss, i.e., 1n ′ ∑ n ′ i=1 L(y ′ i , f (x ′ i , θ))) ∆L[D]One-step training loss decrease ∆L j [D] One-step training loss decrease caused by updating one parameter θ j R(Z, n) One-step generalization ratio (OSGR) for the training and test sets of size n sampled from data distribution Z, i.e., E D,D ′ ∼Z n (∆L[D ′ ]) E D∼Z n (∆L[D]) λ Learning rate ▽ One-step generalization gap increment, i.e., ∆L[D] -∆L[D ′ ] ϵ Random variables with zero mean and variance σ 2 (θ) W (l) and b (l) Model parameters (weight matrix and bias) of the l-th layer θ (l-) Collection of model parameters over all the layers before the l-th layer g (l) D Average gradient of W (l) over the training dataset θ (l+) Collection of model parameters over all the layers after the l-th layer, including the l-th layer a (l) = {a (l) s (θ (l-) )} Activations of the l-th layer, where s = {1, 2, ..., S} is the index of nodes/channels in the l-th layer. o (l) = {o (l) c } Outputs of matrix multiplication of the l-th layer, where c = {1, 2, ..., C} is index of nodes/channels in the (l + 1)-th layer. a evaluated on data sample i

Pearson correlation between features and target output y, where c t0 and c tmaxAs shown in Table2, all models in the experiment consist of 2 Conv-Relu-MaxPooling blocks and 2 fully-connected layers, but they are different in the number of channels. We choose the number of channels p from{6, 8, 10, 12, 14, 16, 18, 20}.

Table content: <table><tr><td colspan="3">are correlations at the begin-</td></tr><tr><td colspan="3">ning of training and maxi-</td></tr><tr><td colspan="3">mum of GSNR curve respec-</td></tr><tr><td>tively.</td><td/><td/></tr><tr><td>feature id</td><td>c t0</td><td>c tmax</td></tr><tr><td>0</td><td colspan="2">-0.11 0.47</td></tr><tr><td>5</td><td>0.11</td><td>0.44</td></tr><tr><td>13</td><td>0.07</td><td>0.40</td></tr><tr><td>14</td><td colspan="2">-0.21 -0.27</td></tr><tr><td>17</td><td colspan="2">-0.33 0.53</td></tr></table>

Model structure On MNIST in Section 2.4. p is the number of channels and q = int(2.5 * p)

Table content: <table><tr><td>Layer</td><td colspan="2">input #channels output #channels</td></tr><tr><td colspan="2">conv + relu + maxpooling 1</td><td>p</td></tr><tr><td colspan="2">conv + relu + maxpooling p</td><td>q</td></tr><tr><td>flatten</td><td>-</td><td>-</td></tr><tr><td>fc + relu</td><td>16 * q</td><td>10 * q</td></tr><tr><td>fc + relu</td><td>10 * q</td><td>10</td></tr><tr><td>softmax</td><td>-</td><td>-</td></tr><tr><td>A.2 EXPERIMENT ON CIFAR10</td><td/><td/></tr></table>

Model structure on CIFAR10. p is the number of channels.

Table content: <table><tr><td>Layer</td><td colspan="2">input #channels output #channels</td></tr><tr><td colspan="2">conv + bn + relu 3</td><td>p</td></tr><tr><td colspan="2">conv + bn + relu p</td><td>p</td></tr><tr><td>maxpooling</td><td>-</td><td>-</td></tr><tr><td colspan="2">conv + bn + relu p</td><td>2p</td></tr><tr><td colspan="2">conv + bn + relu 2p</td><td>2p</td></tr><tr><td>maxpooling</td><td>-</td><td>-</td></tr><tr><td colspan="2">conv + bn + relu 2p</td><td>4p</td></tr><tr><td colspan="2">conv + bn + relu 4p</td><td>4p</td></tr><tr><td>maxpooling</td><td>-</td><td>-</td></tr><tr><td colspan="2">conv + bn + relu 4p</td><td>8p</td></tr><tr><td colspan="2">conv + bn + relu 8p</td><td>8p</td></tr><tr><td>maxpooling</td><td>-</td><td>-</td></tr><tr><td>flatten</td><td>-</td><td>-</td></tr><tr><td>fc + relu</td><td/><td/></tr></table>

Test set consists of n ′ samples drawn from Z θ Model parameters, whose components are denoted as θ j g s (θ) or g i (θ) Parameters' gradient w.r.t. a single data sample s or (x i , y i ) g(θ) Mean values of parameters' gradient over a total data distribution, i.e., E s∼Z (g s (θ)) g D (θ) Average gradient over the training dataset, i.e., 1 Note that, in eq. (5), we assume n ′ = n g D,j Same as g D (θ j ) ρ 2 (θ) Variance of parameters' gradient of a single sample, i.e., Var s∼Z (g s (θ))

Table content: <table><tr><td/><td>Notations</td></tr><tr><td>Z</td><td>A data distribution satisfies X × Y</td></tr><tr><td>s or (x, y)</td><td>A single data sample</td></tr><tr><td>D</td><td>Training set consists of n samples drawn from Z</td></tr><tr><td>D ′</td><td/></tr><tr><td colspan="2">n ∑ n ′ ∑ n i=1 g i (θ) i=1 g ′ i (θ). ρ 2 g D ′ (θ) Average gradient over the test dataset, i.e., 1 n ′</td></tr></table>

Peer review (iclr2020):
The paper defines the quantity of *gradient SNR* (GSNR), shows that larger GSNR leads to better generalization, and shows that SGD training of deep networks has large GSNR. It tells a great story on why SGD-trained DNNs have good generalization. This topic is highly relevant to this conference. However, I struggle to rate this paper, since I feel swamped with math. It is hard work to read this paper, and I can honestly say that I could semi-confidently follow until about Eq. (8). To even get there, I had to scroll back and forth to remember the definitions of the various symbols. The math may be very well correct, but it is infeasible to verify (or follow) it fully. It does not make it easier that one cannot really search a PDF for greek symbols with indices etc. Someone who reads theoretical papers all day long might do better here. This is the reason I rate the paper Weak Reject. Some feedback points: Section 2.1: Eq. (1): It seems the common definition of SNR is the ratio of mean standard deviation. Your SNR is its square. This should be explained. I think it would help the reader a lot to give some intuitive meaning to the GSNR value. Can you, in Section 2.1, explain with examples what typical (or extreme) values would be? Assumption 2.3.1: This is dropped on the reader without any motivation. It is also confusing: *we will make our derivation under the non-overfitting limit approximation* conflicts with *In the early training stage,...* So is this whole derivation only true in the early stages? Assumption 2.3.1 seems to address a thought I had when reading this: At the end of the training, I would expect mu_q(theta) to be zero (the definition of convergence). At the start, it is arbitrary as it entirely depends on the initial values. So this paper must look at some part between the two extremes to make sense. Is it? Is this assumption related? What is the difference between sigma and ho? Seems one is on the data distribution and one on a sampled set. But then why is mu the same in both cases (Eq. (1) vs. Eq. (5))? All plots: The plot labels are far too small to be readable.