Title: THE DYNAMICS OF SIGNAL PROPAGATION IN GATED RECURRENT NEURAL NETWORKS

Abstract: Training recurrent neural networks (RNNs) on long sequence tasks is plagued with difficulties arising from the exponential explosion or vanishing of signals as they propagate forward or backward through the network. Many techniques have been proposed to ameliorate these issues, including various algorithmic and architectural modifications. Two of the most successful RNN architectures, the LSTM and the GRU, do exhibit modest improvements over vanilla RNN cells, but they still suffer from instabilities when trained on very long sequences. In this work, we develop a mean field theory of signal propagation in LSTMs and GRUs that enables us to calculate the time scales for signal propagation as well as the spectral properties of the state-to-state Jacobians. By optimizing these quantities in terms of the initialization hyperparameters, we derive a novel initialization scheme that eliminates or reduces training instabilities. We demonstrate the efficacy of our initialization scheme on multiple sequence tasks, on which it enables successful training while a standard initialization either fails completely or is orders of magnitude slower. We also observe a beneficial effect on generalization performance using this new initialization.

1. INTRODUCTION:

A common paradigm for research and development in deep learning involves the introduction of novel network architectures followed by experimental validation on a selection of tasks. While this methodology has undoubtedly generated significant advances in the field, it is hampered by the fact that the full capabilities of a candidate model may be obscured by difficulties in the training procedure. It is often possible to overcome such difficulties by carefully selecting the optimizer, batch size, learning rate schedule, initialization scheme, or other hyperparameters. However, the standard strategies for searching for good values of these hyperparameters are not guaranteed to succeed, especially if the trainable configurations are constrained to a low-dimensional subspace of hyperparameter space, which can render random search, grid search, and even Bayesian hyperparameter selection methods unsuccessful.

In this work, we argue that for long sequence tasks, the trainable configurations of initialization hyperparameters for LSTMs and GRUs lie in just such a subspace, which we characterize theoretically. In particular, we identify precise conditions on the hyperparameters governing the initial weight and bias distributions that are necessary to ensure trainability. These conditions derive from the observation that in order for a network to be trainable, (a) signals from the relevant parts of the input sequence must be able to propagate all the way to the loss function and (b) the gradients must be stable (i.e., they must not explode or vanish exponentially). As shown in Figure 1 , training of recurrent networks with standard initialization on certain tasks begins to fail as the sequence length increases and signal propagation becomes harder to achieve. However, as we shall show, a suitably-chosen initialization scheme can dramatically improve trainability on such tasks.

We study the effect of the initialization hyperparameters on signal propagation for a very broad class of recurrent architectures, which includes as special cases many state-of-the-art RNN cells, including the GRU (Cho et al. (2014) ), the LSTM (Hochreiter & Schmidhuber (1997) ), and the peephole LSTM (Gers et al. (2002) ). The analysis is based on the mean field theory of signal propagation developed in a line of prior work (Schoenholz et al. (2016) ; Xiao et al. (2018) ; Chen et al. (2018) ; Yang et al. (2019) ), as well as the concept of dynamical isometry (Saxe et al. (2013) ; Pennington Test accuracy for peephole LSTM trained to classify sequences of MNIST digits after 8000 iterations. As the sequence length increases, the network is no longer trainable with standard initialization, but still trainable using critical initialization. et al. (2017; 2018) ) that is necessary for stable gradient backpropagation and which was shown to be crucial for training simpler RNN architectures (Chen et al. (2018) ). We perform a number of experiments to corroborate the results of the calculations and use them to motivate initialization schemes that outperform standard initialization approaches on a number of long sequence tasks.

2. BACKGROUND AND RELATED WORK:



2.1. MEAN FIELD ANALYSIS OF NEURAL NETWORKS:

Signal propagation at initialization can be controlled by varying the hyperparameters of fullyconnected (Schoenholz et al. (2016) ; Yang & Schoenholz (2017) ) and convolutional (Xiao et al. (2018) ) feed-forward networks, as well as for simple gated recurrent architectures (Chen et al. (2018) ). In all these cases, such control was used to obtain initialization schemes that outperformed standard initializations on benchmark tasks. In the feed-forward case, this enabled the training of very deep architectures without the use of batch normalization or skip connections.

By forward signal propagation, we specifically refer to the propagation of correlations between inputs at the start of an input sequence through the hidden states of the recurrent network at later times, as will be made precise in Section 4.2. This appears to be a necessary but not sufficient condition for trainability on certain tasks. Another is the stability of the gradients, which depend on the state-to-state Jacobian matrix, as discussed in Bengio et al. (1994) . In our context, the goal of the backward propagation analysis is to improve the conditioning of the Jacobian by controlling the first two moments of its squared singular values. Forward signal propagation and the spectral properties of the Jacobian at initialization can be studied using mean field theory and random matrix theory (Poole et al. (2016); Schoenholz et al. (2016) ; Yang & Schoenholz (2017; 2018) ; Xiao et al. (2018) ; Pennington et al. (2017; 2018) ; Chen et al. (2018) ; Yang et al. (2019) ).

As neural network training is a nonconvex problem, using a modified initialization scheme could lead to convergence to different points in parameter space in a way that adversely affects the generalization error. We provide some empirical evidence that this does not occur, and in fact, the use of initialization schemes satisfying these conditions has a beneficial effect on the generalization error.

2.2. THE EXPLODING/VANISHING GRADIENT PROBLEM AND SIGNAL PROPAGATION IN:



RECURRENT NETWORKS:

The exploding/vanishing gradient problem is a well-known phenomenon that hampers training on long time sequence tasks (Bengio et al. (1994) ; Pascanu et al. (2013) ). Apart from the gating mechanism, there have been numerous proposals to alleviate the vanishing gradient problem by constraining the weight matrices to be exactly or approximately orthogonal (Pascanu et al. (2013) ; Wisdom et al. (2016) ; Vorontsov et al. (2017) ; Jose et al. (2017) ), or more recently by modifying some terms in the gradient (Arpit et al. (2018) ), while exploding gradients can be handled by clipping (Pascanu et al. (2013) ). Another recently proposed approach to ensuring signal propagation in long sequence tasks introduces auxiliary loss functions (Trinh et al. (2018) ). This modification of the loss can be seen as a form of regularization. Chang et al. (2019) study the connections between recurrent networks and certain ordinary differential equations and propose the AntisymmetricRNN that can capture long term dependencies in the inputs. While many of these approaches have been quite successful, they typically require modifying the training algorithm, the loss function, or the architecture, and as such exist as complementary methods to the one we investigate here. We postpone the investigation of a combination of techniques to future work.

2.3. DYNAMICS BEYOND INITIALIZATION:

While the analysis below applies to the network at initialization, it was recently shown that as the network width becomes large, parameters move very little from their initial values (Jacot et al. (2018) ; Lee et al. (2019) ). A non-trivial and surprising consequence is that covariance matrices like those studied here remain constant during training. While Jacot et al. (2018) ; Lee et al. (2019) do not specifically study RNNs, the analysis of Yang (2019) suggests the conclusions are likely to carry over. Moreover, even for finite-width networks, simply satisfying the conditions derived in this work at initialization can lead to a dramatic improvement in trainability as we show below.

3. NOTATION:

We denote matrices by bold upper case Latin characters and vectors by bold lower case Latin characters. Dx denotes a standard Gaussian measure. The normalized trace of a random N × N matrix A,1 N Etr(A), is denoted by τ (A). • is the Hadamard product, σ(•) is a sigmoid function and both σ(•), tanh(•) act element-wise. We denote by D a a diagonal matrix with a on the diagonal. 

4. MEAN FIELD ANALYSIS OF SIGNAL PROPAGATION AND DYNAMICAL:

K {f } {f, r} {i, f, r, o} g k . σ(u r ) . f σ(u t f ) σ(u t f ) • s t-1 +(1 -σ(u t f )) • tanh(u t r2 ) σ(u t o ) • tanh(c 0 + t j=1 t Π l=j σ(u l f ) • σ(u j i ) • tanh(u j r ))

Table 1 : A number of recurrent architectures written in the form 1. K is the set of pre-activation subscripts, f is the state update function in eqn. (1a) and g k is the function in eqn. (1c). The LSTM cell state is unrolled in order to emphasize that it can be written as a function of variables that are Gaussian at the large N limit. See Table 3 for additional architectures.

We begin with a general description of recurrent architectures that can be specialized to the GRU, LSTM and peephole LSTM among others. We denote the state of a recurrent network at time t by s t ∈ R N with s 0 i ∼ D 0 , and a sequence of inputs to the network by {z 1 , ..., z T },

z t ∈ R N .

The state evolution of the network is given by

EQUATION

)

where f is an element-wise, affine function of s t-1 and {u t k } is a set of pre-activations u t k ∈ R N , k ∈ K defined for a set of subscripts K. They are given by

u t k = W k s t-1 + U k z t + b k (1b)

where

W k , U k ∈ R N ×N , b k ∈ R N .

We define additional pre-activations

EQUATION

where g k : R N → R N is an element-wise function and u t k is defined as in eqn. (1b) 1 . In cases where there is no need to distinguish between variables of the form (1b) and (1c) we will refer to both as u t k . This state update equation describes all the architectures studied in this paper, as well as many others, as detailed in Tables 1, 3 . The pre-activations u t k , which are typically used to construct gates in recurrent network with the application of appropriate nonlinearities, will be of interest because they will tend in distribution to Gaussians as the network width is taken to infinity. Chen et al. (2018) , we make the untied weights assumption that W k is independent of s t . Although the assumption of untied weights may seem counter-intuitive in the context of recurrent networks, recall that we are only interested in characterizing various statistics of the network, not in computing the entire input-output map, for which using tied weights would certainly be crucial. For merely characterizing certain statistics, the untied weights assumption actually has long history of yielding correct predictions, and therefore it is not at all unnatural to adopt: 1) when computing the covariance of gradients in an MLP, the weights during backpropagation can be treated as independently sampled from the weights used during the forward propagation (Schoenholz et al., 2016; Yang & Schoenholz, 2017) ; 2) when computing the Jacobian singular value distribution of an MLP, the pre-activations h = Wx can be treated as the result of multiplying an iid copy W of W (i.e. h = W x) (Pennington et al., 2017; 2018; Hayase, 2019) ; 3) a wide, randomly initialized MLP corresponds to the same Gaussian process whether or not its weights across layers are tied (Poole et al., 2016) , and similarly, a simple RNN evolves the same whether or not its weights are tied across time, as long as its width is large (Chen et al., 2018) . Indeed, we provide empirical evidence that calculations performed under this assumption still have considerable predictive power, even in cases where it is violated.

We assume W k,ij ∼ N (0, σ 2 k /N ), U k,ij ∼ N (0, ν 2 k /N ), b k,i ∼ N (µ k , ρ 2 k ) i.i.d. and denote Θ = k {σ 2 k , ν 2 k , ρ 2 k , µ k }. As in

4.2. FORWARD SIGNAL PROPAGATION:

We now study how correlations between inputs propagate into the hidden states of a recurrent network. This section follows closely the development in Chen et al. (2018) . We now consider two sequences of normalized inputs {z t a }, {z t b } with zero mean and covariance

R = R 1 Σ z Σ z 1 fed into two

copies of a network with identical weights, and resulting in sequences of states {s t a }, {s t b }. We consider the time evolution of the moments and correlations

EQUATION

where we define

Σ t2 s = Q t s -(µ t s ) 2 .

Returning to the pre-activations defined in eqn. (1). We make the mean field approximation2 that the pre-activations are jointly Gaussian at the infinite width N → ∞ limit:

u t kia u t kib ∼ N µ k µ k , Q t k -µ 2 k 1 C t k C t k 1 (3)

where the second moment

Q t k is given by Q t k = E[u t kia u t kia ] = σ 2 k E[s t ia s t ia ] + ν 2 k E[z t ia z t ia ] + ρ 2 k + µ 2 k = σ 2 k Q t s + ν 2 k R + ρ 2 k + µ 2 k (4a)

and defining

EQUATION

)

The variables u t k2ia , u t k2ib given by eqn. (1c) are also asymptotically Gaussian, with their covariance detailed in Appendix A. We will subsequently drop the vector subscript i since all elements are identically distributed and f , g k act element-wise, and the input sequence index in expressions that involve only one sequence.

For any l ≤ t, the u l k are independent of s l at the large N limit. Combining this with the fact that their distribution is determined completely by µ l-1 s , Q l-1 s , C l-1 s and that f is affine, one can rewrite eqn. (2a-c) using eqn. (1a-c) as the following deterministic dynamical system

EQUATION

where the dependence on Θ and the data distribution has been suppressed. In the peephole LSTM and GRU, the form will be greatly simplified to

M(µ t-1 s , Q t-1 s , C t-1 s ).

In Appendix E we compare the predicted dynamics to simulations, showing good agreement.

One can now study the fixed points of eqn. ( 5) and the rates of convergence by linearizing the dynamics. The fixed point of eqn. ( 5) is pathological, in the sense that any information that distinguishes two input sequences is lost. Therefore, delaying the convergence to the fixed point should allow for signals to propagate across longer time horizons. Quantitatively, the rate of convergence of eqn. ( 5) to a fixed point gives an effective time scale for signal propagation from the inputs to the hidden state at later times.

While the dynamical system is two-dimensional and analysis of convergence rates should be performed by linearizing the full system and studying the smallest eigenvalue of the resulting matrix, in practice as in Chen et al. (2018) this eigenvalue appears to always corresponds to the C t s direction3 . Hence, if we assume convergence of Q t s , µ t s we need only study

EQUATION

where M C also depends on expectations of functions of {u 1 k }, ...{u t-2 k } that do not depend on C t-1 s . While this dependence is in principle on an infinite number of Gaussian variables as the dynamics approach the fixed point, M C can still be reasonably approximated in the case of the LSTM as detailed in Appendix D. We show that in the case of the peephole LSTM this map is convex in Appendix C. This can be shown for the GRU by a similar argument. It follows directly that it has a single stable fixed point in these cases.

The rate of approach to the fixed point, χ C * s , is given by linearizing around it. Setting C t s = C * s + ε t , we have

EQUATION

The time scale of convergence to the fixed point is thus given by

EQUATION

which diverges as χ C * s approaches 1 from below. Due to the detrimental effect of convergence to the fixed point described above, it stands to reason that a choice of Θ such that χ C * s = 1 -δ for some small δ > 0 would enable signals to propagate from the initial inputs to the final hidden state when training on long sequences.

4.3. BACKWARDS SIGNAL PROPAGATION -THE STATE-TO-STATE JACOBIAN:

We now turn to controlling the gradients of the network. A useful object to consider in this case is the asymptotic state-to-state transition Jacobian J = lim t→∞ ∂s t+1 ∂s t . J and powers of it will appear in the gradient as the covariance dynamics described in Section 4.2 approach their fixed point (specifically, the gradient of a network trained on a sequence of length T will depend on a matrix polynomial of order T in J), hence we desire to control the squared singular value distribution of J. This distribution is described by moments of the form m JJ T ,n = τ ((JJ T ) n ), with mean and variance of the distribution given by

m JJ T ,1 = E k∈K∪{0} a k (9) σ 2 JJ T = m JJ T ,2 -m 2 JJ T ,1 = E k,l∈K∪{0} 2a k a l -a 2 0 -   E k∈K∪{0} a k   2 (10)

where the scalars {a k } k∈K∪{0} are architecture and hyperparameter dependent and are given in Appendix A.2.

Forward and backward signal propagation are in fact intimately related, as the following lemma shows: Lemma 1. For a recurrent neural networks defined by (1), the mean squared singular value of the state-to-state Jacobian defined in ( 16) and χ Cs that determines the time scale of forward signal propagation (given by ( 7)) are related by

EQUATION

Proof. See Appendix C.

If one can find a setting of the hyperparameters such that m JJ T ,1 is close to 1 and σ 2 JJ T is small, then the spectrum of powers of J should remain well-conditioned ensuring that gradients will not explode or vanish.

4.4. DYNAMICAL ISOMETRY:

Combining the results of Sections 4.2 and 4.3, we conclude that an effective choice of initialization hyperparamters should satisfy

EQUATION

)

We refer to these as dynamical isometry conditions. eqn. (12)a ensures stable signal propagation from the inputs to the loss, and eqn. (12)b-c are motivated by the additional requirement of preventing the gradients from exploding/vanishing. Both of these conditions appear to be necessary in order for a network to be trainable. Combining eqns. (9, 10, 11) we find that if Σ z = 1, the dynamical isometry conditions are satisfied if a 0 = 1, a k =0 = 0, which can be achieved by setting ∀k : σ 2 k = 0 and taking µ f → ∞. This motivates the general form of the initializations used in the experiments.

We demand that these equations are only satisfied approximately since for a given architecture, there may not be a value of Θ that satisfies them all. Additionally, even if such a value exists, the optimal value of χ C * s for a given task may not be 1. There is some empirical evidence that if the characteristic time scale defined by χ C * s is much larger than that required for a certain task, performance is degraded.

The typical values of Σ z will depend on the data set, yet satisfying the dynamical isometry conditions is simplified if Σ z = 1 due to Lemma 1. It is thus a natural choice, yet we acknowledge that a more comprehensive treatment should consider the case of general Σ z . We also find empirically that the results obtained under the Σ z = 1 assumption prove to be predictive and enable training on a number of tasks without requiring a detailed analysis of Σ z .

4.5. THE STATIONARY DISTRIBUTION OF THE LSTM CELL STATE:

In architectures that were considered in previous works, as well as the peephole LSTM and GRU, all the quantities required to calculate the dynamical isometry conditions through eqns. (9, 10) can be written in terms of integrals over a finite number of Gaussian variables at the large width and time 8). As can be seen, this time scale predicts the transition between the regions of high and low accuracy across the different architectures and directions in hyperparameter space.

limit and are thus easy to evaluate. This is not the case in the standard LSTM due to the presence of the cell state. By unrolling the cell state update equation

EQUATION

in time, we find that c t depends on the entire sequence of u t k from the first time step4 . From eqn. 13 we find that the asymptotic cell state distribution is that of a perpetuity, which is a random variable X that obeys X d = XY + Z where Y, Z are random variables and d = denotes equality in distribution. The stationary distribution of a perpetuity generally does not have a closed form, and neither does its likelihood (Goldie (1991)). In practice, one can overcome this difficulty by sampling from the stationary cell state distribution, as described in Appendix D.

5. EXPERIMENTS:



5.1. PADDED MNIST CLASSIFICATION:

The calculations presented above predict a characteristic time scale ξ (defined in (8)) for forward signal propagation in a recurrent network. It follows that on a task where success depends on propagation of information from the first time step to the final T -th time step, the network will not be trainable for T ξ. In order to test this prediction, we consider a classification task where the inputs are sequences consisting of a single MNIST digit followed by T -1 steps of i.i.d Gaussian noise and the targets are the digit labels. By scanning across certain directions in hyperparameter space, the predicted value of ξ changes. We plot training accuracy of a network trained with untied weights after 1000 iterations for the GRU and 2000 for the LSTM, as a function of T and the hyperparameter values, and overlay this with multiples of ξ. As seen in Figure 2 , we observe good agreement between the predicted time scale of signal propagation and the success of training. As expected, there are some deviations when training without enforcing untied weights, and we present the corresponding plots in the supplementary materials. LSTM with hard sigmoid nonlinearities on unrolled CIFAR-10 images feeding in 3 pixels at every time step, resulting in sequences of length 1024. We also apply standard data augmentation for this task. We present accuracy on the test set in Table 2 . Interestingly, in the case of CIFAR-10 the best performance is achieved by an initialization with a forward propagation time scale ξ that is much smaller than the sequence length, suggesting that information sufficient for successful classification may be obtained from a subset of the sequence.

5.2. UNROLLED MNIST:



5.3. REPEATED PIXEL MNIST AND MULTIPLE DIGIT MNIST:

In order to generate longer sequence tasks, we modify the unrolled MNIST task by repeating every pixel a certain number of times and set the input dimension to 7. To create a more challenging task, we also combine this pixel repetition with concatenation of multiple MNIST digits (either 0 or 1), and label such sequences by a product of the original labels. In this case, we set the input dimension to 112 and repeat each pixel 10 times. We train a peephole LSTM with both a critical initialization and a standard initialization on both of these tasks using SGD with momentum. In this former task, the dimension of the label space is constant (and not exponential in the number of digits like in the latter). In both tasks, we observe three distinct phases. If the sequence length is relatively short the critical and standard initialization perform equivalently. As the sequence length is increased, training with a critical initialization is faster by orders of magnitude compared to the standard initialization.

As the sequence length is increased further, training with a standard initialization fails, while training with a critical initialization still succeeds. The results are shown in Figure 3 .

6. DISCUSSION:

We have derived initialization schemes for recurrent networks motivated by ensuring stable signal propagation from the inputs to the loss and of gradient information from the loss to the weights. These schemes dramatically improve performance on long sequence tasks.

The subspace of initialization hyperparameters Θ that satisfy the dynamical isometry conditions is multidimensional, and there is no clear principled way to choose a preferred initialization within it. It would be of interest to study this subspace and perhaps identify preferred initializations based on additional constraints. One could also use the satisfaction of the dynamical isometry conditions as a guiding principle in simplifying these architectures. A direct consequence of the analysis is that the forget gate, for instance, is critical, while some of the other gates or weights matrices can be removed while still satisfying the conditions. A related question is the optimal choice of the forward propagation time scale ξ for a given task. As mentioned in Section 5.2, this scale can be much shorter than the sequence length. It would also be valuable understand better the extent to which the untied weights assumption is violated, since it appears that the violation is non-uniform in Θ, and to relax the constant Σ z assumption by introducing a time dependence.

Another compelling issue is the persistence of the dynamical isometry conditions during training and their effect on the solution. It has been recently shown that in sufficiently wide networks the gradient flow dynamics in function space are effectively linear (Jacot et al. (2018) ; Lee et al. (2019) ) and under these same conditions the dynamical isometry conditions persist during training. Understanding the finite width and learning rate corrections to such calculations could help extend the analysis of signal propagation at initialization to trained networks in this regime.

Appendices:



APPENDIX A DETAILS OF RESULTS:

A.1 COVARIANCES OF u t k2

The variables u t k 2 ia , u t k 2 ib given by 1c are asymptotically Gaussian at the N → ∞, with

Q t k 2 = σ 2 k 2 g 2 k (u a )D k Q t s + ν 2 k 2 R + ρ 2 k 2 + µ 2 k 2 (14a) C t k 2 = σ 2 k 2 g k (u a )g k (u a )D k (Σ t2 s C t s + µ 2 s ) +ν 2 k 2 RΣ z + ρ 2 k 2 Q t k 2 -µ 2 k 2 (14b)

where D k is a Gaussian measure on (u a , u b ) corresponding to the distribution in eqn.

(3).

A.2 MOMENTS OF THE STATE-TO-STATE JACOBIAN:

The moments of the squared singular value distribution are given by the normalized traces m JJ T ,n = τ ((JJ T ) n ).

Since U t , t < t is independent of s t , if we index by k, k the variables defined by eqn. ( 1b) and (1c) respectively we obtain

EQUATION

)

Under the untied assumption W k , W k 2 are independent of s t , u t k at the large N limit, and are also independent of each other and their elements have mean zero. Using this and the fact that f acts element-wise, we have

EQUATION

)

where Controlling the first moment of JJ T is not sufficient to ensure that the gradients do not explode or vanish, since the variance of the singular values may still be large. This variance is given by

EQUATION

σ 2 JJ T = m JJ T ,2 -m 2 JJ T ,1 .

The second moment m JJ T ,2 can be calculated from (15), and is given by

m JJ T ,2 = E k,l∈K∪{0} 2a k a l -a 2 0 (18)

where the a k are defined in eqn. ( 17). We arrange the scalars a 0 , {a k } into a vector a. In Appendix B we show that the results of the calculations in this section match the empirical spectrum of the Jacobian.

For all the architectures considered in this paper, we find that D 0 = σ(u * f ) while D k are finite as ∀k : σ 2 k → 0. Combining this with ( 11), ( 16), ( 18), we find that if Σ z = 1 the dynamical isometry conditions are satisfied if a 0 = 1, a k =0 = 0, which can be achieved by setting ∀k : σ 2 k = 0 and taking µ f → ∞. This motivates the general form of the initializations used in the experiments5 although there are many other possible choices of Θ such that the a k =0 vanish.

Given the above general form of the dynamical isometry conditions for recurrent networks, we now provide the detailed forms that apply to the LSTM, peephole LSTM and GRU.

A.3 DYNAMICAL ISOMETRY CONDITIONS FOR SELECTED ARCHITECTURES:

We specify the form of χ C * s ,Σ and a for the architectures considered in this paper:

A.3.1 GRU χ C * s ,Σ = E     σ(u * f a )σ(u * f b ) + σ 2 f tanh(u * r 2 a ) tanh(u * r 2 b ) +h * a h * b σ (u * f a )σ (u * f b ) +σ 2 r 2 (1 -σ(u * f a ))(1 -σ(u * f b )) tanh (u * r 2 a ) tanh (u * r 2 b ) σ(u * r 1 a )σ(u * r 1 b ) +σ 2 r 1 h * a h * b σ (u * r 1 a )σ (u * r 1 b )     a =     σ 2 (u * f ) σ 2 f tanh 2 (u * r 2 ) + Q * h σ 2 (u * f ) σ 2 r 1 σ 2 r 2 h * 2 (1 -σ(u * f )) 2 tanh 2 (u * r 2 )σ 2 (u * r 1 ) σ 2 r 2 (1 -σ(u * f )) 2 tanh 2 (u * r 2 )σ 2 (u * r 1 )     A.3.2 PEEPHOLE LSTM χ C * s ,Σ = E σ(u * f a )σ(u * f b ) + σ 2 i σ (u * ia )σ (u * ib ) tanh(u * ra ) tanh(u * rb ) σ 2 f c * a c * b σ (u * f a )σ (u * f b ) + σ 2 r σ(u * ia )σ(u * ib ) tanh (u * ra ) tanh (u * rb ) a =     σ 2 (u * f ) σ 2 i σ 2 (u * i ) tanh 2 (u * r ) σ 2 f c * 2 σ 2 (u * f ) σ 2 r σ 2 (u * i ) tanh 2 (u * r )     0.0 0.5 1.0 1.5 2.0 2.5

Typical Hyperparameters 0.85 0.90 0.95 1.00 1.05 1.10 1.15

Approximate Dynamical Isometry Figure 4 : Squared singular values of the state-to-state Jacobian in eqn. ( 15) for two choices of hyperparameter settings Θ. The red lines denote the empirical mean and standard deviations, while the dotted lines denote the theoretical prediction based on the calculation described in Section 4.3. Note the dramatic difference in the spectrum caused by choosing an initialization that approximately satisfies the dynamical isometry conditions.

A.3.3 LSTM χ C * s ,Σz = E     σ(u * f a )σ(u * f b ) + σ 2 o σ (u * oa )σ (u * ob ) tanh(c * a ) tanh(c * b ) +σ(u * oa )σ(u * ob ) tanh (c * a ) tanh (c * b )   σ 2 f c * a c * b σ (u * f a )σ (u * f b ) +σ 2 i σ (u * ia )σ (u * ia ) tanh(u * ra ) tanh(u * rb ) +σ 2 r σ(u * ia )σ(u * ia ) tanh (u * ra ) tanh (u * rb )       a =       σ 2 (u * f ) σ 2 i σ 2 (u * o ) tanh 2 (c * )σ 2 (u * i ) tanh 2 (u * r ) σ 2 f σ 2 (u * o ) tanh 2 (c * )c * 2 σ 2 (u * f ) σ 2 r σ 2 (u * o ) tanh 2 (c * )σ 2 (u * i ) tanh 2 (u * r ) σ 2 o σ 2 (u * o ) tanh 2 (c * )      

When evaluating 7 in this case, we write the cell state as c t = tanh -1 s t σ(o t ) , and assume σ(o t ) σ(o t-1 ) ≈ 1 for large t. The stability of the first equation and the accuracy of the second approximation are improved if o t is not concentrated around 0. 

A.4 RNN:

) • tanh(s t ) f σ(u t f ) • s t-1 +(1 -σ(u t f )) • x t σ(u t f ) • s t-1 +σ(u t i ) • tanh(u t r )

Table 3 : Additional recurrent architectures written in the form 1. p t is the output of the network at every time step. See Table 1 for more details.

APPENDIX B SQUARED JACOBIAN SPECTRUM HISTOGRAMS:

To verify the results of the calculation of the moments of the squared singular value distribution of the state-to-state Jacobian presented in Section 4.3 we run an untied peephole LSTM for 100 iterations with i.i.d. Gaussian inputs. We then compute the state-to-state Jacobian and calculate its spectrum. This can be used to compare the first two moments of the spectrum to the result of the calculation, as well as to observe the difference between a standard initialization and one close to satisfying the dynamical isometry conditions. The results are shown in Figure 4 . The validity of this experiment rests on making an ergodicity assumption, since the calculated spectral properties require taking averages over realizations of random matrices, while in the experiment we instead calculate the moments by averaging over the eigenvalues of a single realization. The good agreement between the prediction and the empirical average suggests that the assumption is valid.

APPENDIX C AUXILIARY LEMMAS AND PROOFS:

Proof of Lemma 1. Despite the fact that each u kai as defined in 1 depends in principle upon the entire state vector s a , at the large N limit due to the isotropy of the input distribution we find that these random variables are i.i.d. and independent of the state. Combining this with the fact that f is an element-wise function, it suffices to analyse a single entry of s t = f (s t-1 , {u 1 k }, ..., {u t k }), which at the large t limit gives

M C (µ * s , Q * s , C s ) = E [f (s a , U * a )f (s b , U * b )] -(µ * s ) 2 Q * s -(µ * s ) 2

where

U * a = {u * ka |k ∈ K, u * ka ∼ N (µ k , Q * k -µ 2 k }

and U * b is defined similarly (i.e. we assume the first two moments have converged but the correlations between the sequences have not, and in cases where f depends on a sequence of {u 1 k }, ..., {u t k } we assume the constituent variables have all converged in this way). We represent u * ka , u * kb via a Cholesky decomposition as

u * ka = Σ k z ka + µ * k (19a) u * kb = Σ k C * k z ka + 1 -(C * k ) 2 z kb + µ * k (19b)

where z ka , z kb ∼ N (0, 1) i.i.d. We thus have

∂u * kb ∂C k = Q * k -(µ * k ) 2 z ka -C k √ 1-C 2 k z kb .

Combining this with the fact that Dzg(z)z = Dzg (z) for any g(z), integration by parts gives for any g 1 , g 2

EQUATION

)

dC kb dCs = σ 2 kb Σ 2 s Σ 2 kb * g k (u * ka )g k (u * kb ) + σ 2 k 2 (Σ 2 s Cs+(µ * s ) 2 ) Σ 2 k 2 ∂g k (u * ka )g k (u * kb ) ∂C k dC k dCs D k = σ 2 k 2 Σ 2 s Σ 2 k 2 *   g k (u * ka )g k (u * kb ) +σ 2 k Σ 2 s C s +µ * 2 s g k (u * ka )g k (u * kb )   D k

where in the last equality we used 20. Using 20 again gives

∂M C (µ * s , Q * s , C s ) ∂C k = Σ 2 k Dz ka Dz kb ∂f (u * ka ) ∂u * ka ∂f (u * kb ) ∂u * kb We now note, using 4, that if C s = 1, Σ z = 1 we obtain C k = 1 and thus dC k 2 dC s Cs=1,Σz=1 = σ 2 k 2 Σ 2 s Σ 2 k 2 g 2 k (u * k )D k +σ 2 k Q * s (g k (u * k )) 2 D k ∂M C (µ * s , Q * s , C s ) ∂C k Cs=1,Σz=1 = Σ 2 k Dz k ( ∂f (u * k ) ∂u * k ) 2 ∂M C (µ * s , Q * s , C s ) ∂C s Cs=1,Σz=1 = E ( ∂f (s) ∂s ) 2

combining the above equations with 21 and comparing the result to 16 completes the proof.

Lemma 2. For any odd function g

(x), x y ∼ N µ µ , Σ 1 C C 1 , 0 ≤ C ≤ 1 we have Eg(x)g(y) ≥ 0.

Proof of Lemma 2. For C = 1 the proof is trivial. We now assume 0 ≤ C < 1. We split up R 2 into four orthants and consider a point where p is the probability density function of (x, y) and hence the points where the integrand is positive will contribute more to the integral than the ones where it is negative. Plugging these points into p(x, y) gives

p(a, b) + p(-a, -b) p(a, -b) + p(-a, b) = e -α[(a-µ) 2 -2C(b-µ)(a-µ)+(b-µ) 2 ] + e -α[(a+µ) 2 -2C(b+µ)(a+µ)+(b+µ) 2 ] e -α[(a-µ) 2 +2C(b+µ)(a-µ)+(b+µ) 2 ] + e -α[(a+µ) 2 +2C(b-µ)(a+µ)+(b-µ) 2 ]

where α is some positive constant that depends on the determinant of the covariance (since C < 1 the matrix is invertible and the determinant is positive).

= exp (2αCab) exp (-2αCab) cosh (2µα(1 -C)(a + b)) cosh (2µα(1 -C)(a -b)) ≥ 1

where the last inequality holds for 0 ≤ C < 1. It follows that the positive contribution to the integral is larger than the negative one, and repeating this argument for every (a, b) in the positive orthant gives the desired claim (if a = 0 or b = 0 the four points in the analysis are not distinct but the inequality still holds and the integrand vanishes in any case).

Lemma 3. The map 5 is convex in the case of the peephole LSTM.

Proof of Lemma 3. We have

M(C t c ) = f t a f t b ((Q * c -(µ * c ) 2 )C t c + µ * 2 c ) + i t a i t b r t a r t b + 2 f t i t r t µ * c -µ * 2 c Q * c -µ * 2 c .

From the definition of u t kb and C t k we have

∂u t kb ∂C t c = Q * k -(µ * k ) 2 z ka - C t k 1 -C t2 k z kb ∂C t k ∂C t c = z ka - C t k 1 -C t2 k z kb σ 2 k (Q * c -µ * 2 c ) Q * k -µ * 2 k .

and using Dxg(x)x = Dxg (x) we then obtain for any g(x)

EQUATION

(Q * c -µ * 2 c ) ∂ 2 M(C c ) ∂C 2 c = ∂ 2 ∂C 2 c f a f b (Q * c -(µ * c ) 2 )C c + µ * 2 c + i a i b r a r b = ∂ 2 faf b ∂C 2 c ((Q * c -(µ * c ) 2 )C c + µ * 2 c ) + 2 ∂ ∂Cc f a f b (Q * c -(µ * c ) 2 ) + ∂ 2 iai b ∂C 2 c r a r b + ∂ iai b ∂Cc ∂ rar b ∂Cc + i a i b ∂ 2 rar b ∂C 2 c

From 22 and non-negativity of some of the integrands

≥ ∂ 2 f a f b ∂C 2 c (Q * c -(µ * c ) 2 )C c + µ * 2 c + ∂ 2 i a i b ∂C 2 c r a r b + i a i b ∂ 2 r a r b ∂C 2 c .

From Lemma 2 we have r a r b ≥ 0 and

∂ 2 gag b ∂C 2 c = α g a g b ≥ 0 for g = f, i, r. We thus have ∂ 2 M(C c ) ∂C 2 c ≥ 0 for 0 ≤ C c ≤ 1.

Convexity of this map has a number of consequences. One immediate one is that the map has at most one stable fixed point.

APPENDIX D THE LSTM CELL STATE DISTRIBUTION:

Algorithm 1 LSTM hidden state moment fixed point iteration using cell state sampling function FIXEDPOINTITERATION(µ t-1 s , Q t-1 s , Θ, n s , n iters )

Q t-1 k ← CALCULATEQK(Q t-1 s , Θ)

Using 4 Initialize c ∈ R ns for i ← 1 to n iters do u i , u f , u r ← SAMPLEUS(Q t-1 k , Θ) Using 3 c ← UPDATEC(c, u i , u f , u r )

Using 13 end for (µ t s , Q t s ) ← CALCULATEM(µ t-1 s , Q t-1 s , Θ, c) Using 5 return (µ t s , Q t s ) end function

As mentioned in the main text, the cell state differs substantially from other random variables that appear in this analysis since it cannot be expressed as a function of a finite number of variables that are Gaussian at the large N and t limit (see Table 1 ). Since at this limit the u t i are independent, by examining the cell state update eqn. ( 13) we find that the asymptotic cell state distribution is that of a perpetuity, which obeys

X d = XY + Z

for some random variables Y, Z. Its stationary distributions will have heavy tails Goldie (1991) . Due to the bounds on Y, Z in the case of the LSTM, one expects based on results in (Goldie & Grübel (1996) ) that the tails of the stationary cell state distribution will be exponential in the case of hard sigmoid nonlinearities or decay like x -x in the case of soft sigmoid nonlinearities, and this tail behavior is indeed observed in simulations. Aside from the tails, the bulk of the distribution can take a variety of different forms and can be highly multimodal, depending on the choice of Θ which in turn determines the distributions of Y, Z.

We overcome this difficulty by sampling from the stationary cell state distribution. For a given value of Q h , the variables u t k appearing in (13) can be sampled since their distribution is given by (3) at the large N limit. The update equation ( 13) can then be iterated and the resulting samples approximate well the stationary cell state distribution for a range of different choices of Θ, which result in a variety of stationary distribution profiles (see Appendix E3). The fixed points of (5) can then be calculated numerically as in the deterministic cases, yet care must be taken since the sampling introduces stochasticity into the process.

An example of the fixed point iteration eqn. (5) implemented using sampling is presented in Algorithm 1. The correlations between the hidden states can be calculated in a similar fashion. In practice, once the number of samples n s and sampling iterations n iters is of order 100 reasonably accurate values for the moment evolution and the convergence rates to the fixed point are obtained (see for instance the right panel of Figure 2 ). The computational cost of the sampling is linear in both n s , n iters (as opposed to say simulating a neural network directly in which case the cost is quadratic in n s ). We generally observe improved performance when the predicted value of ξ is high, yet the behavior of the network with tied weights is not part of the scope of the current analysis and deviations from the prediction are indeed observed. 

:

Variables of the form (1c) will be present only in the GRU (see Table1).

For feed-forward networks, it has been shown using the Central Limit Theorem for exchangeable random variables that the pre-activations at all layers indeed converge in distribution to a multivariate Gaussian(Matthews et al. (2018)).

This observation is explained in the case of fully-connected feed-forward networks inSchoenholz et al. (2016).

In contrast, the hidden state distribution of the GRU at time t for instance can be expressed as an integral over {u t-1 k } alone (which are Gaussian at the large t fixed point) through eqn. 2.

In the case of the LSTM, we also want to prevent the output gate from taking very small values, as explained in Section A.3.

Figures and Tables:

Figure1: Critical initialization improves trainability of recurrent networks. Test accuracy for peephole LSTM trained to classify sequences of MNIST digits after 8000 iterations. As the sequence length increases, the network is no longer trainable with standard initialization, but still trainable using critical initialization.

Figure2: Training accuracy on the padded MNIST classification task described in 5.1 at different sequence lengths T and hyperparameter values Θ 0 + αΘ 1 for networks with untied weights, with different values of Θ 0 , Θ 1 chosen for each architecture. The dark and light green curves are respectively 3ξ, 6ξ where ξ is the theoretical signal propagation time scale in eqn. (8). As can be seen, this time scale predicts the transition between the regions of high and low accuracy across the different architectures and directions in hyperparameter space.

) and D 0 = ∂f ∂s * , D k = ∂f ∂u * k . The values of D 0 , D k for the architectures considered in the paper are detailed in Appendix A.3.

(a, b) with a, b ≥ 0. We have g(a)g(b) = g(-a)g(-b) = -g(a)g(-b) = -g(-a)g(b) ≥ 0. We will show that p(a, b) + p(-a, -b) > p(a, -b) + p(-a, b)

Figure6: Training accuracy on the padded MNIST classification task described in 5.1 at different sequence lengths T and hyperparameter values Θ for networks with tied weights. The green curves are multiples of the forward propagation time scale ξ calculated under the untied assumption. We generally observe improved performance when the predicted value of ξ is high, yet the behavior of the network with tied weights is not part of the scope of the current analysis and deviations from the prediction are indeed observed.

Figure 7: Sampling from the LSTM cell state distribution using Algorithm 1, showing good agreement with the cell state distribution obtained by simulating a network with untied weights. The two panels correspond to two different choices of Θ



Table content: <table><tr><td/><td>Minimal RNN</td><td>peephole LSTM</td></tr><tr><td/><td>Chen et al. (2018)</td><td>Gers et al. (2002)</td></tr><tr><td>K</td><td>{f, r}</td><td>{i, f, r, o}</td></tr><tr><td>p t</td><td>s t</td><td>σ(u t o</td></tr></table>

Peer review (iclr2020):
The aim of this paper is to suggest randomized initializations for the various weights of a recurrent neural network (GRUs and various LSTMs are covered), such that training these networks gets to a successful start, when the model is trained on long sequences. Instead of being heuristic, their approach follows first principles of analyzing signal propagation through time, using ideas from statistical thermodynamics (mean field approximations). Some experiments, on toy datasets, validate their approach. I am quite intrigued by this paper. It is using interesting theory, shapes it to a practically highly relevant and difficult applied problem, and in the end comes up with a computable criterion of how to choose hyperparameters (means and variances of Gaussians to sample initial weights from). While the results in practice are still not too convincing, I am strongly in favour of giving this approach the benefit of doubt, as it could lead to practically very useful downstream work. The main direction of improvement for this paper (given that experiments are what they are -- somewhat limited to toy situations right now) is to better explain the methodology to researchers not familiar with mean field methods. Most importantly, it is not explained in the main text how hyperparameters are really chosen in the end. Looking at Appendix E, I find some pretty basic choices, and no other alternatives considered. It is not explained why these choices satisfy the theory, why they*d be the only ones, etc. This creates a disconnect between the very nice (and seemingly useful) theory and its implications (they are not really well spelled out). Here is what I understood (and I am not specifically an expert on stat mech). The authors assume that the dimension of latent states (N) grows large. They assume that weights are sampled independently, and identical distributed in groups k (different cell types, weight vs bias), and that inputs are correlated with each other in each dimension. Based on these assumption, they follow Gaussians statistics through a number of time steps. In the limit, one gets a deterministic dynamical system, and as t -> infty, this may converge to a fixed point. In a very nice argument (which they could explain better), they state that such rapid convergence is bad news, because then information cannot spread across long time scales, so one has to find hyperparameters for which the system behaves *critically*. A second arguments tries to keep gradient sizes (under MF assumptions) of O(1), so neither -> 0, not -> infty, which is again some *critical* range. Under their assumption, these critical conditions can be computed depending on the hyperparameters. Unfortunately, this is where the paper somewhat stops, it does not give specific methods for finding hyperpars that satisfy the criteria, at least not in the sense of characterising the whole space of such hyperpars (instead, in Appendix E, they just state some few settings that do). As a direction for future work, this would be very important. Another side question is whether for what the authors call *trainability*, the only point that matters is whether for the initial weights, signals can spread and gradients are O(1). It is certainly necessary, I see that. Detailed comments: - Please fix Table 1, the expressions seem broken. What does *r2* mean in the GRU column? - At least for me, (1a) to (1c) really was too short. At least in the Appendix, please do explain how this gives GRU and LSTM - Please explain the untied weight assumption somewhere. s^t is a map of s^(t-1) and W_k, so how can W_k be independent of all s^t? What are you really assuming here? - It took some repeated reading until I understood why the expressions in (2a) to (4b) do not depend on i, j, a, b (except whether a = b or a != b). Explain that properly - The core of the whole approach seems to be first half of page 5. This seems like a very nice argument, but hard to understand. Try making it more crisp. I kind of get the rough idea why fast convergence over t would be bad, but would total divergence over t not also be bad? - In (12a-c), do you mean *equal* or *approximately equal*? - In 4.4: *This motivates the general form of the initializations used in the experiments*: You have to make this more explicit. Why are your choices the only ones? Could there not be other choices satisfying (12a-c) approx, and be better? - Value of Sigma_z = 1: This seems odd to me, then your covariances are degenerate (rank 1 instead of 2). Please explain - Standard LSTM harder than GRU or peephole LSTM: Again, this sounds real interesting, but I did not get it from the explanation - I did not understand Figure 2. How are Theta_0, Theta_1 chosen? - As said above, the experiments are interesting, but somewhat artificial. Please do at least comment on real-world applications, and whether (and how) the ideas here would apply - Discussion: *there is no clear principled way...*: Well, but practitioners need something. I*d disagree, at least one could attempt to navigate this space by global optimization techniques... ADDITIONAL COMMENT: I tried to append the following as comment, but the (pretty broken) system would not let me, insisting that *reader is not valid* (???). Anyway, here it is. I hope I am allowed to add to my own review. I*ve seen the argument in reviews that assumptions made by this paper about independencies between weights and inner states are wrong, and therefore conclusions are not valid. First, such assumptions are indeed pretty common in such statistical mech analyses of learning methods. Second, you have to distinguish between weights after (random) initialization and after training. Of course, LSTM represents long term dependencies after training, but initialization is a different story. If I was the AC for this paper, I*d ask somebody with at least some background in statistical mech to provide some additional opinions, as the reviewers (including myself) are not fully qualified.