Noisy Recurrent Neural Networks
Year: 2022

Abstract:
We provide a general framework for studying recurrent neural networks (RNNs) trained by injecting noise into hidden states. Specifically, we consider RNNs that can be viewed as discretizations of stochastic differential equations driven by input data. This framework allows us to study the implicit regularization effect of general noise injection schemes by deriving an approximate explicit regularizer in the small noise regime. We find that, under reasonable assumptions, this implicit regularization promotes flatter minima; it biases towards models with more stable dynamics; and, in classification tasks, it favors models with larger classification margin. Sufficient conditions for global stability are obtained, highlighting the phenomenon of stochastic stabilization, where noise injection can improve stability during training. Our theory is supported by empirical results which demonstrate that the RNNs have improved robustness with respect to various input perturbations.

heading: 1 Introduction
text: Viewing recurrent neural networks (RNNs) as discretizations of ordinary differential equations (ODEs) driven by input data has recently gained attention [7, 27, 16, 49]. The “formulate in continuous time, and then discretize” approach [38] motivates novel architecture designs before experimentation, and it provides a useful interpretation as a dynamical system. This, in turn, has led to gains in reliability and robustness to data perturbations.
Recent efforts have shown how adding noise can also improve stability during training, and consequently improve robustness [35]. In this work, we consider discretizations of the corresponding stochastic differential equations (SDEs) obtained from ODE formulations of RNNs through the addition of a diffusion (noise) term. We refer to these as Noisy RNNs (NRNNs). By dropping the noisy elements at inference time, NRNNs become a stochastic learning strategy which, as we shall prove, has a number of important benefits. In particular, stochastic learning strategies (including dropout) are often used as natural regularizers, favoring solutions in regions of the loss landscape with desirable properties (often improved generalization and/or robustness). This mechanism is commonly referred to as implicit regularization [40, 39, 50], differing from explicit regularization where the loss is explicitly modified. For neural network (NN) models, implicit regularization towards wider minima is conjectured to be a prominent ingredient in the success of stochastic optimization [67, 28]. Indeed, implicit regularization has been linked to increases in classification margins [47], which can lead to improved generalization performance [51]. A common approach to identify and study implicit regularization is to approximate the implicit regularization by an appropriate explicit regularizer
35th Conference on Neural Information Processing Systems (NeurIPS 2021).
[40, 39, 1, 6, 21]. Doing so, we will see that NRNNs favor wide minima (like SGD); more stable dynamics; and classifiers with a large classification margin, keeping generalization error small.
SDEs have also seen recent appearances in neural SDEs [59, 24], stochastic generalizations of neural ODEs [9] which can be seen as an analogue of NRNNs for non-sequential data, with a similar relationship to NRNNs as feedforward NNs do to RNNs. They have been shown to be robust in practice [35]. Analogously, we shall show that the NRNN framework leads to more reliable and robust RNN classifiers, whose promise is demonstrated by experiments on benchmark data sets.
Contributions. For the class of NRNNs (formulated first as a continuous-time model, which is then discretized), the following are our main contributions:
• we identify the form of the implicit regularization for NRNNs through a corresponding (datadependent) explicit regularizer in the small noise regime (see Theorem 1);
• we focus on its effect in classification tasks, providing bounds for the classification margin for the deterministic RNN classifiers (see Theorem 2); in particular, Theorem 2 reveals that stable RNN dynamics can lead to large classification margin;
• we show that noise injection can also lead to improved stability (see Theorem 3) via a Lyapunov stability analysis of continuous-time NRNNs;
• we demonstrate via empirical experiments on benchmark data sets that NRNN classifiers are more robust to data perturbations when compared to other recurrent models, while retaining state-of-the-art performance for clean data. Research code is provided here: https://github.com/erichson/NoisyRNN.
Notation. We use ‖v‖ := ‖v‖2 to denote the Euclidean norm of the vector v, and ‖A‖2 and ‖A‖F to denote the spectral norm and Frobenius norm of the matrix A, respectively. The ith element of a vector v is denoted by vi or [v]i, and the (i, j)-entry of a matrix A by Aij or [A]ij . For a vector v = (v1, . . . , vd), diag(v) denotes the diagonalization of v with diag(v)ii = vi. I denotes the identity matrix (with dimension clear from context), while superscript T denotes transposition. For a matrix M , M sym = (M + MT )/2 denotes its symmetric part, λmin(M) and λmax(M) denote its minimum and maximum eigenvalue respectively, σmax(M) denotes its maximum singular value, and Tr(M) denotes its trace. For a function f : Rn → Rm such that each of its first-order partial derivatives (with respect to x) exist, ∂f∂x ∈ R
m×n is the Jacobian matrix of f . For a scalar-valued function g : Rn → R, ∇hg is the gradient of g with respect to the variable h ∈ Rn and Hhg is the Hessian of g with respect to h.

heading: 2 Related Work
text: Dynamical Systems and Machine Learning. There are various interesting connections between machine learning and dynamical systems. Formulating machine learning in the framework of continuous-time dynamical systems was recently popularized by [62]. Subsequent efforts focus on constructing learning models by approximating continuous-time dynamical systems [9, 29, 48] and studying them using tools from numerical analysis [36, 64, 69, 68]. On the other hand, dynamical systems theory provides useful theoretical tools for analyzing NNs, including RNNs [60, 15, 34, 7, 16], and useful principles for designing NNs [23, 54]. Other examples of dynamical systems inspired models include the learning of invariant quantities via their Hamiltonian or Lagrangian representations [37, 22, 10, 71, 58]. Another class of models is inspired by Koopman theory, yielding models where the evolution operator is linear [56, 43, 17, 45, 33, 4, 3, 13].
Stochastic Training and Regularization Strategies. Regularization techniques such as noise injection and dropout can help to prevent overfitting in NNs. Following the classical work [5] that studies regularizing effects of noise injection on data, several work studies the effects of noise injection into different parts of networks for various architectures [25, 44, 35, 54, 2, 26, 66, 61]. In particular, recently [6] studies the regularizing effect of isotropic Gaussian noise injection into the layers of feedforward networks. For RNNs, [12] shows that noise additions on the hidden states outperform Bernoulli dropout in terms of performance and bias, whereas [18] introduces a variant of stochastic RNNs for generative modeling of sequential data. Some specific formulations of RNNs as SDEs were
also considered in Chapter 10 of [41]. Implicit regularization has also been studied more generally than stochastic gradient based training of NNs [40, 39, 19, 11].

heading: 3 Noisy Recurrent Neural Networks
text: We formulate continuous-time recurrent neural networks (CT-RNNs) at full generality as a system of input-driven ODEs: for a terminal time T > 0 and an input signal x = (xt)t∈[0,T ] ∈ C([0, T ];Rdx), the output yt ∈ Rdy , for t ∈ [0, T ], is a linear map of hidden states ht ∈ Rdh satisfying
dht = f(ht, xt)dt, yt = V ht, (1)
where V ∈ Rdy×dh , and f : Rdh × Rdx → Rdh is typically Lipschitz continuous, guaranteeing existence and uniqueness of solutions to (1).
A natural stochastic variant of CT-RNNs arises by replacing the ODE in (1) by an Itô SDE, that is,
dht = f(ht, xt)dt+ σ(ht, xt)dBt, yt = V ht, (2)
where σ : Rdh × Rdx → Rdh×r and (Bt)t≥0 is an r-dimensional Brownian motion. The functions f, σ are referred to as the drift and diffusion coefficients, respectively. Intuitively, (2) amounts to a noisy perturbation of the corresponding deterministic CT-RNN (1). At full generality, we refer to the system (2) as a continuous-time Noisy RNN (CT-NRNN). To guarantee the existence of a unique solution to (2), in the sequel, we assume that {f(·, xt)}t∈[0,T ] and {σ(·, xt)}t∈[0,T ] are uniformly Lipschitz continuous, and t 7→ f(h, xt), t 7→ σ(h, xt) are bounded in t ∈ [0, T ] for each fixed h ∈ Rdh . For further details, see Section B in Supplementary Material (SM). While much of our theoretical analysis will focus on this general formulation of CT-NRNNs, our empirical and stability analyses focus on the choice of drift function
f(h, x) = Ah+ a(Wh+ Ux+ b), (3)
where a : R → R is a Lipschitz continuous scalar activation function extended to act on vectors pointwise, A,W ∈ Rdh×dh , U ∈ Rdh×dx and b ∈ Rdh . Typical examples of activation functions include a(x) = tanh(x). The matrices A,W,U, V, b are all assumed to be trainable parameters. This particular choice of drift dates back to the early Cohen-Grossberg formulation of CT-RNNs, and was recently reconsidered in [16].

heading: 3.1 Noise Injections as Stochastic Learning Strategies
text: While precise choices of drift functions f are the subject of existing deterministic RNN theory, good choices of the diffusion coefficient σ are less clear. Here, we shall consider a parametric class of diffusion coefficients given by:
σ(h, x) ≡ (σ1I + σ2diag(f(h, x))), (4) where the noise level > 0 is small, and σ1 ≥ 0 and σ2 ≥ 0 are tunable parameters describing the relative strength of additive noise and a multiplicative noise respectively.
While the stochastic component is an important part of the model, one can set ≡ 0 at inference time. In doing so, noise injections in NRNNs may be viewed as a learning strategy. A similar stance is considered in [35] for treating neural SDEs. From this point of view, we may relate noise injections generally to regularization mechanisms considered in previous works. For example, additive noise injection was studied in the context of feedforward NNs in [6], in which case a Gaussian noise is injected to the activation function at each layer of the NN. Furthermore, multiplicative noise injections includes stochastic depth and dropout strategies as special cases [36, 35]. By taking a Gaussian approximation to Bernoulli noise and taking a continuous-time limit, NNs with stochastic dropout can be weakly approximated by an SDE with appropriate multiplicative noise, see [36]. All of these works highlight various advantages of noise injection for training NNs.

heading: 3.2 Numerical Discretizations
text: As in the deterministic case, exact simulation of the SDE in (2) is infeasible in practice, and so one must specify a numerical integration scheme. We will focus on the explicit Euler-Maruyama (E-M) integrators [30], which are the stochastic analogues of Euler-type integration schemes for ODEs.
Let 0 := t0 < t1 < · · · < tM := T be a partition of the interval [0, T ]. Denote δm := tm+1 − tm for each m = 0, 1, . . . ,M − 1, and δ := (δm). The E-M scheme provides a family (parametrized by δ) of approximations to the solution of the SDE in (2):
hδm+1 = h δ m + f(h δ m, x̂m)δm + σ(h δ m, x̂m) √ δmξm, (5)
for m = 0, 1, . . . ,M − 1, where (x̂m)m=0,...,M−1 is a given sequential data, the ξm ∼ N (0, I) are independent r-dimensional standard normal random vectors, and hδ0 = h0. As ∆ := maxm δm → 0, the family of approximations (hδm) converges strongly to the Itô process (ht) satisfying (2) (at rate O( √
∆) when the step sizes are uniform; see Theorem 10.2.2 in [30]). See Section C in SM for details on the general case.

heading: 4 Implicit Regularization
text: To highlight the advantages of NRNNs over their deterministic counterpart, we show that, under reasonable assumptions, NRNNs exhibit a natural form of implicit regularization. By this, we mean regularization imposed implicitly by the stochastic learning strategy, without explicitly modifying the loss, but that, e.g., may promote flatter minima. Our goal is achieved by deriving an appropriate explicit regularizer through a perturbation analysis in the small noise regime. This becomes useful when considering NRNNs as a learning strategy, since we can precisely determine the effect of the noise injection as a regularization mechanism.
The study for discrete-time NRNNs is of practical interest and is our focus here. Nevertheless, analogous results for continuous-time NRNNs are also valuable for exploring other discretization schemes. For this reason, we also study the continuous-time case in Section E in SM. Our analysis covers general NRNNs, not necessarily those with the drift term (3) and diffusion term (4), that satisfy the following assumption, which is typically reasonable in practice. We remark that a ReLU activation will violate the assumption. However, RNNs with ReLU activation are less widely used in practice. Without careful initialization [31, 57], they typically suffer more from exploding gradient problems compared to those with bounded activation functions such as tanh. Assumption A. The drift f and diffusion coefficient σ of the SDE in (2) satisfy the following:
(i) for all t ∈ [0, T ] and x ∈ Rdx , h 7→ f(h, x) and h 7→ σij(h, x) have Lipschitz continuous partial derivatives in each coordinate up to order three (inclusive);
(ii) for any h ∈ Rdh , t 7→ f(h, xt) and t 7→ σ(h, xt) are bounded and Borel measurable on [0, T ].
We consider a rescaling of the noise σ 7→ σ in (2), where > 0 is assumed to be a small parameter, in line with our noise injection strategies in Subsection 3.1.
In the sequel, we let h̄δm denote the hidden states of the corresponding deterministic RNN model, satisfying
h̄δm+1 = h̄ δ m + δmf(h̄ δ m, x̂m), m = 0, 1, . . . ,M − 1, (6)
with h̄δ0 = h0. Let ∆ := maxm∈{0,...,M−1} δm, and denote the state-to-state Jacobians by
Ĵm = I + δm ∂f
∂h (h̄δm, x̂m). (7)
For m, k = 0, . . . ,M − 1, also let Φ̂m,k = ĴmĴm−1 · · · Ĵk, (8)
where the empty product is assumed to be the identity. Note that the Φ̂m,k are products of the state-to-state Jacobian matrices, important for analyzing signal propagation in RNNs [8]. For the sake of brevity, we denote fm = f(h̄δm, x̂m) and σm = σ(h̄ δ m, x̂m) for m = 0, 1, . . . ,M .
The following result, which is our first main result, relates the loss function, averaged over realizations of the injected noise, used for training NRNN to that for training deterministic RNN in the small noise regime. Theorem 1 (Implicit regularization induced by noise injection). Under Assumption A,
E`(hδM ) = `(h̄δM ) + 2
2 [Q̂(h̄δ) + R̂(h̄δ)] +O( 3), (9)
as → 0, where the terms Q̂ and R̂ are given by
Q̂(h̄δ) = ∇l(h̄δM )T M∑ k=1 δk−1Φ̂M−1,k M−1∑ m=1 δm−1vm, (10)
R̂(h̄δ) = M∑ m=1 δm−1tr(σ T m−1Φ̂ T M−1,mHh̄δ l Φ̂M−1,mσm−1), (11)
with vm a vector with the pth component:
[vm] p = tr(σTm−1Φ̂ T M−2,mHh̄δ [fM ] pΦ̂M−2,mσm−1), (12)
for p = 1, . . . , dh. Moreover,
|Q̂(h̄δ)| ≤ CQ∆2, |R̂(h̄δ)| ≤ CR∆, (13)
for CQ, CR > 0 independent of ∆.
If the loss is convex, then R̂ is non-negative, but Q̂ needs not be. However, Q̂ can be made negligible relative to R̂ provided that ∆ is taken sufficiently small. This also ensures that the E-M approximations are accurate.
To summarize, Theorem 1 implies that the injection of noise into the hidden states of deterministic RNN is, on average, approximately equivalent to a regularized objective functional. Moreover, the explicit regularizer is solely determined by the discrete-time flow generated by the Jacobians ∂fm ∂h̄
(h̄δm), the diffusion coefficients σn, and the Hessian of the loss function, all evaluated along the dynamics of the deterministic RNN. We can therefore expect that the use of NRNNs as a regularization mechanism should reduce the state-to-state Jacobians and Hessian of the loss function according to the noise level . Indeed, NRNNs exhibit a smoother Hessian landscape than that of the deterministic counterpart (see Figure 3 in SM).
The Hessian of the loss function commonly appears in implicit regularization analyses, and suggests a preference towards wider minima in the loss landscape. Commonly considered a positive attribute [28], this, in turn, suggests a degree of robustness in the loss to perturbations in the hidden states [65]. More interesting, however, is the appearance of the Jacobians, which is indicative of a preference towards slower, more stable dynamics. Both of these attributes suggest NRNNs could exhibit a strong tendency towards models which are less sensitive to input perturbations. Overall, we can see that the use of NRNNs as a regularization mechanism reduces the state-to-state Jacobians and Hessian of the loss function according to the noise level.

heading: 5 Implications in Classification Tasks
text: Our focus now turns to an investigation of the benefits of NRNNs over their deterministic counterparts for classification tasks. From Theorem 1, it is clear that adding noise to deterministic RNN implicitly regularizes the state-to-state Jacobians. Here, we show that doing so also enhances an implicit tendency towards classifiers with large classification margin. Our analysis here covers general deterministic RNNs, although we also apply our results to obtain explicit expressions for Lipschitz RNNs.
Let SN denote a set of training samples sn := (xn, yn) for n = 1, . . . , N , where each input sequence xn = (xn,0, xn,1, . . . , xn,M−1) ∈ X ⊂ RdxM has a corresponding class label yn ∈ Y = {1, . . . , dy}. Following the statistical learning framework, these samples are assumed to be independently drawn from an underlying probability distribution µ on the sample space S = X × Y . An RNN-based classifier gδ(x) is constructed in the usual way by taking
gδ(x) = argmaxi=1,...,dyp i(V h̄δM [x]), (14)
where pi(x) = ex i / ∑ j e xj is the softmax function. Letting ` denoting the cross-entropy loss, such a classifier is trained from SN by minimizing the empirical risk (training error), RN (gδ) := 1N ∑N n=1 `(g δ(xn), yn), as a proxy for the true (population) risk (test error), R(gδ) =
E(x,y)∼µ`(gδ(x), y), with (x, y) ∈ S. The measure used to quantify the prediction quality is the generalization error (or estimation error), which is the difference between the empirical risk of the classifier on the training set and the true risk: GE(gδ) := |R(gδ)−RN (gδ)|. The classifier is a function of the output of the deterministic RNN, which is an Euler discretization of the ODE (1) with step sizes δ = (δm). In particular, for the Lipschitz RNN,
Φ̂m,k = ĴmĴm−1 · · · Ĵk, (15)
where Ĵl = I + δl(A+DlW ), with D ij l = a ′([Wh̄δl + Ux̂l + b] i)eij .
In the following, we let conv(X ) denote the convex hull of X . We let x̂0:m := (x̂0, . . . , x̂m) so that x̂ = x̂0:M−1, and use the notation f [x] to indicate the dependence of the function f on the vector x. Our result will depend on two characterizations of a training sample si = (xi, yi). Definition 1 (Classification Margin). The classification margin of a training sample si = (xi, yi) measured by the Euclidean metric d is defined as the radius of the largest d-metric ball in X centered at xi that is contained in the decision region associated with the class label yi, i.e., it is: γd(si) = sup{a : d(xi,x) ≤ a⇒ gδ(x) = yi ∀x}.
Intuitively, a larger classification margin allows a classifier to associate a larger region centered on a point xi in the input space to the same class. This makes the classifier less sensitive to input perturbations, and a perturbation of xi is still likely to fall within this region, keeping the classifier prediction. In this sense, the classifier becomes more robust. In our case, the networks are trained by a loss (cross-entropy) that promotes separation of different classes in the network output. This, in turn, maximizes a certain notion of score of each training sample. Definition 2 (Score). For a training sample si = (xi, yi), we define its score as o(si) = minj 6=yi √ 2(eyi − ej)TSδ[xi] ≥ 0, where ei ∈ Rdy is the Kronecker delta vector with eii = 1 and eji = 0 for i 6= j, Sδ[xi] := p(V h̄δM [xi]) with h̄δM [xi] denoting the hidden state of the RNN, driven by the input sequence xi, at terminal index M .
Recall that the classifier gδ(x) = arg maxi∈1,...,dy [S δ]i[x], and the decision boundary between class i and class j in the feature space is given by the hyperplane {z = Sδ : zi = zj}. A positive score implies that at the network output, classes are separated by a margin that corresponds to the score. However, a large score may not imply a large classification margin.
Following the approach of [52, 63], we obtain the second main result, providing bounds for classification margin for the deterministic RNN classifiers gδ. We also provide a generalization bound in terms of the classification margin under additional assumptions (see Theorem 11 in SM). Theorem 2. Suppose that Assumption A holds. Assume that the score o(si) > 0 and
γ(si) := o(si) C ∑M−1 m=0 δm supx̂∈conv(X ) ‖Φ̂M,m+1[x̂]‖2 > 0, (16)
where C = ‖V ‖2 ( maxm=0,1,...,M−1 ∥∥∥∂f(h̄δm,x̂m)∂x̂m ∥∥∥2) > 0 is independent of si (in particular, C = ‖V ‖2[maxm=0,...,M−1 ‖DmU‖2] for Lipschitz RNNs), the Φ̂m,k are defined in (15) and the δm are the step sizes. Then, the classification margin for the training sample si:
γd(si) ≥ γ(si). (17)
Now, recalling from Section 4, up to O( 2) and under the assumption that Q̂ vanishes, the loss minimized by the NRNN classifer is, on average, `(h̄δM ) + 2R̂(h̄δ), as → 0, with regularizer
R̂(h̄δ) = 1
2 M∑ m=1 δm−1‖M̂M−1Φ̂M−1,mσm−1‖2F , (18)
where M̂TMM̂M := Hh̄δM l is the Cholesky decomposition of the Hessian matrix of the convex crossentropy loss. The appearance of the state-to-state Jacobians in Φm,k in both the regularizer (18) and the lower bound (16) suggests that noise injection implicitly aids generalization performance. More precisely, in the small noise regime and on average, NRNNs promote classifiers with large
classification margin, an attribute linked to both improved robustness and generalization [63]. In this sense, training with NRNN classifiers is a stochastic strategy to improve generalization over deterministic RNN classifiers, particularly in learning tasks where the given data is corrupted (c.f. the caveats pointed out in [53]).
Theorem 2 implies that the lower bound for the classification margin is determined by the spectrum of the Φ̂M−1,m. To make the lower bound large, keeping δm and M fixed, the spectral norm of the Φ̂M−1,m should be made small. Doing so improves stability of the RNN, but may also lead to vanishing gradients, hindering capacity of the model to learn. To maximize the lower bound while avoiding the vanishing gradient problem, one should tune the numerical step sizes δm and noise level in NRNN appropriately. RNN architectures for the drift which help to ensure moderate Jacobians (e.g., ‖Φ̂M−1,m‖2 ≈ 1 for all m [8]) also remain valuable in this respect.

heading: 6 Stability and Noise-Induced Stabilization
text: Here we obtain sufficient conditions to guarantee stochastic stability of CT-NRNNs. This will also provide another lens to highlight the potential of NRNNs for improved robustness. A dynamical system is considered stable if trajectories which are close to each other initially remain close at subsequent times. As observed in [46, 42, 7], stability plays an essential role in the study of RNNs to avoid the exploding gradient problem, a property of unstable systems where the gradient increases in magnitude with the depth. While gradient clipping during training can somewhat alleviate this issue, better performance and robustness is achieved by enforcing stability in the model itself.
Our stability analysis will focus on establishing almost sure exponential stability (for other notions of stability, see SM) for CT-NRNNs with the drift function (3). To preface the definition, consider initializing the SDE at two different random variables h0 and h′0 := h0 + 0, where 0 ∈ Rdh is a constant non-random perturbation with ‖ 0‖ ≤ δ. The resulting hidden states, ht and h′t, are set to satisfy (2) with the same Brownian motion Bt, starting from their initial values h0 and h′0, respectively. The evolution of t = h′t − ht satisfies
d t = A tdt+ ∆at( t)dt+ ∆σt( t)dBt, (19)
where ∆at( t) = a(Wh′t+Uxt+b)−a(Wht+Uxt+b) and ∆σt( t) = σ(ht+ t, xt)−σ(ht, xt). Since ∆at(0) = 0, ∆σt(0) = 0 for all t ∈ [0, T ], t = 0 admits a trivial equilibrium for (19). Our objective is to analyze the stability of the solution t = 0, that is, to see how the final state T (and hence the output of the RNN) changes for an arbitrarily small initial perturbation 0 6= 0. To this end, we consider an extension of the Lyapunov exponent to SDEs at the level of sample path [41].
Definition 3 (Almost sure global exponential stability). The sample (or pathwise) Lyapunov exponent of the trivial solution of (19) is Λ = lim supt→∞ t
−1 log ‖ t‖. The trivial solution t = 0 is almost surely globally exponentially stable if Λ is almost surely negative for all 0 ∈ Rdh .
For the sample Lyapunov exponent Λ(ω), there is a constant C > 0 and a random variable 0 ≤ τ(ω) <∞ such that for all t > τ(ω), ‖ t‖ = ‖h′t − ht‖ ≤ CeΛt almost surely. Therefore, almost sure exponential stability implies that almost all sample paths of (19) will tend to the equilibrium solution = 0 exponentially fast. With this definition in tow, we obtain the following stability result.
Theorem 3. Assume that a is monotone non-decreasing, and σ1‖ ‖ ≤ ‖∆σt( )‖F ≤ σ2‖ ‖ for all nonzero ∈ Rdh , t ∈ [0, T ]. Then for any 0 ∈ Rdh , with probability one,
φ+ λmin(A sym) ≤ Λ ≤ ψ + Laσmax(W ) + λmax(Asym), (20)
with φ = −σ22 + σ21 2 and ψ = −σ 2 1 + σ22 2 , where La is the Lipschitz constant of a.
In the special case without noise (σ1 = σ2 = 0), we recover case (a) of Theorem 1 in [16]: whenAsym is negative definite and σmin(Asym) > Laσmax(W ), Theorem 3 implies that (2) is exponentially stable. Most strikingly, and similar to [35], Theorem 3 implies that even if the deterministic CT-RNN is not exponentially stable, it can be stabilized through a stochastic perturbation. Consequently, injecting noise appropriately can improve training performance.

heading: 7 Empirical Results
text: The evaluation of robustness of neural networks (RNNs in particular) is an often neglected yet crucial aspect. In this section, we investigate the robustness of NRNNs and compare their performance to other recently introduced state-of-the-art models on both clean and corrupted data. We refer to Section G in SM for further details of our experiments.
Here, we study the sensitivity of different RNN models with respect to a sequence of perturbed inputs during inference time. We consider different types of perturbations: (a) white noise; (b) multiplicative white noise; (c) salt and pepper; and (d) adversarial perturbations. To be more concrete, let x be a sequence. The perturbations in consideration are as follows.
• Additive white noise perturbations are constructed as x̃ = x+∆x, where the additive noise is drawn from a Gaussian distribution ∆x ∼ N (0, σ). This perturbation strategy emulates measurement errors that can result from data acquisition with poor sensors (where σ can be used to vary the strength of these errors). Multiplicative white noise perturbations are constructed as x̃ = x ·∆x, where the additive noise is drawn from a Gaussian distribution ∆x ∼ N (1, σM ).
• Salt and pepper perturbations emulate defective pixels that result from converting analog signals to digital signals. The noise model takes the form P(X̃ = X) = 1 − α, and P(X̃ = max) = P(X̃ = min) = α/2, where X̃(i, j) denotes the corrupted image and min and max denote to the minimum and maximum pixel values. The parameter α controls the proportion of defective pixels.
• Adversarial perturbations are “worst-case” non-random perturbations maximizing the loss `(gδ(X + ∆X), y) subject to the constraint that the norm of the perturbation ‖∆X‖ ≤ r. We consider the fast gradient sign method for constructing these perturbations [55].
We consider in addition to the NRNN three other RNNs derived from continuous-time models, including the Lipschitz RNN [16] (the deterministic counterpart to our NRNN), the coupled oscillatory RNN (coRNN) [49] and the antisymmetric RNN [7]. We also consider the exponential RNN [32], a discrete-time model that uses orthogonal recurrent weights. We train each model with the prescribed tuning parameters for the ordered (see Sec. 7.1) and permuted (see SM) MNIST task. For the Electrocardiogram (ECG) classification task we performed a non-exhaustive hyper-tuning parameter search. For comparison, we train all models with hidden-to-hidden weight matrices of dimension dh = 128. We average the classification performance over ten different seed values.

heading: 7.1 Ordered Pixel-by-Pixel MNIST Classification
text: First, we consider the ordered pixel-by-pixel MNIST classification task [31]. This task sequentially presents 784 pixels to the model and uses the final hidden state to predict the class membership probability of the input image. In the SM we present additional results for the situation when instead of an ordered sequence a fixed random permutation of the input sequence is presented to the model.
Table 1 shows the average test accuracy (evaluated for models that are trained with 10 different seed values) for the ordered task. Here we present results for white noise and salt and pepper (S&P) perturbations. While the Lipschitz RNN performs best on clean input sequences, the NRNNs show an improved resilience to input perturbations. Here, we consider two different configuration for the NRNN. In both cases, we set the multiplicative noise level to 0.02, whereas we consider the additive noise levels 0.02 and 0.05. We chose these configurations as they appear to provide a good trade-off between accuracy and robustness. Note that the predictive accuracy on clean inputs starts to drop when the noise level becomes too large.
Table 2 shows the average test accuracy for the ordered MNIST task for adversarial perturbations. Again, the NRNNs show a superior resilience even to large perturbations, whereas the Antisymmetric and Exponential RNN appear to be sensitive even to small perturbations.
Figure 1 summarizes the performance of different models with respect to white noise and salt and pepper perturbations. The colored bands indicate ±1 standard deviation around the average performance. In all cases, the NRNN appears to be less sensitive to input perturbations as compared to the other models, while maintaining state-of-the-art performance for clean inputs.

heading: 7.2 Electrocardiogram (ECG) Classification
text: Next, we consider the Electrocardiogram (ECG) classification task that aims to discriminate between normal and abnormal heart beats of a patient that has severe congestive heart failure [20]. We use 500 sequences of length 140 for training, 500 sequences for validation, and 4000 sequences for testing.
Table 3 shows the average test accuracy (evaluated for models that are trained with 10 different seed values) for this task. We present results for additive white noise and multiplicative white noise perturbations. Here, the NRNN, trained with multiplicative noise level set to 0.03 and additive noise levels set to 0.06, performs best both on clean as well as on perturbed input sequences.
Figure 2 summarizes the performance of different models with respect to additive and multiplicative white noise perturbations. Again, the NRNN appears to be less sensitive to input perturbations as compared to the other models, while achieving state-of-the-art performance for clean inputs.

heading: 8 Conclusion
text: In this paper we provide a thorough theoretical analysis of RNNs trained by injecting noise into the hidden states. Within the framework of SDEs, we study the regularizing effects of general noise injection schemes. The experimental results are in agreement with our theory and its implications, finding that Noisy RNNs achieve superior robustness to input perturbations, while maintaining state-of-the-art generalization performance. We believe our framework can be used to guide the principled design of a class of reliable and robust RNN classifiers.
Our work opens up a range of interesting future directions. In particular, for deterministic RNNs, it was shown that the models learn optimally near the edge of stability [8]. One could extend these analyses to NRNNs with the ultimate goal of improving their performance. On the other hand, as discussed in Section 5, although the noise is shown here to implicitly stabilize RNNs, it could negatively impact capacity for long-term memory [42, 70]. Providing analyses to account for this and the implicit bias due to the stochastic optimization procedure [50, 14] is the subject of future work.

heading: Acknowledgements
text: We are grateful for the generous support from Amazon AWS. S. H. Lim would like to acknowledge Nordita Fellowship 2018-2021 for providing support of this work. N. B. Erichson, L. Hodgkinson, and M. W. Mahoney would like to acknowledge the IARPA (contract W911NF20C0035), ARO, NSF, and and ONR via its BRC on RandNLA for providing partial support of this work. Our conclusions do not necessarily reflect the position or the policy of our sponsors, and no official endorsement should be inferred.

Review summaries:
This paper studies noise injection in RNNs, which can be regarded as a discretized SDE driven by external inputs. The first main result of the paper is the derivation of the implicit regularization caused by noise injection (similar to noise injection for feed-forward models), which is shown to be related to the Hessian of the loss (promoting flatter minima) and the Jacobian of the dynamics (promoting slower/more stable dynamics). A further implication on the classification margin is presented. Lastly, the paper presents a result showing that noise injection can further improve the temporal stability of the RNN dynamics. These motivate the use of the noise injection for recurrent neural networks, and experiments are provided to justify the theoretical results.

The authors study the recurrent neural networks with injecting noise to hidden states. They consider RNNs as data driven discretization of stochastic differential equations. Analysis for global stability is presented, and it is also shown that noise injection may improve training stability.

This work studies RNNs that are trained with noise injection in the framework of ODEs.  The method is called NRNN. The authors provided Theorems to: (1) identify the form of implicit regularization of NRNN; (2) show the improved model stability; (3) provide the bounds for RNN classifiers. The experiments are conducted on two classification tasks: Sequential MNIST and heart beats classification.