Noisy Activation Functions

Caglar Gulcehre, Marcin Moczulski, Misha Denil, Yoshua Bengio

Introduction

The introduction of the piecewise-linear activation functions such as ReLU and Maxout Goodfellow et al. (2013) units had a profound effect on deep learning, and was a major catalyst in allowing the training of much deeper networks. It is thanks to ReLU that for the first time it was shown (Glorot et al., 2011) that deep purely supervised networks can be trained, whereas using tanh\tanh nonlinearity only allowed to train shallow networks. A plausible hypothesis about the recent surge of interest on these piecewise-linear activation functions (Glorot et al., 2011), is due to the fact that they are easier to optimize with SGD and backpropagation than smooth activation functions, such as sigmoid\operatorname{sigmoid} and tanh\tanh. The recent successes of piecewise linear functions is particularly evident in computer vision, where the ReLU has become the default choice in convolutional networks.

We propose a new technique to train neural networks with activation functions which strongly saturate when their input is large. This is mainly achieved by injecting noise to the activation function in its saturated regime and learning the level of noise. Using this approach, we have found that it was possible to train neural networks with much wider family of activation functions than previously. Adding noise to the activation function has been considered for ReLU units and was explored in Bengio et al. (2013); Nair & Hinton (2010) for feed-forward networks and Boltzmann machines to encourage units to explore more and make the optimization easier.

More recently there has been a resurgence of interest in more elaborated “gated” architectures such as LSTMs Hochreiter & Schmidhuber (1997) and GRUs Cho et al. (2014), but also encompassing neural attention mechanisms that have been used in the NTM Graves et al. (2014), Memory Networks Weston et al. (2014), automatic image captioning Xu et al. (2015), video caption generation Yao et al. (2015) and wide areas of applications LeCun et al. (2015). A common thread running through these works is the use of soft-saturating non-linearities, such as the sigmoid or softmax, to emulate the hard decisions of digital logic circuits. In spite of its success, there are two key problems with this approach.

Since the non-linearities still saturate there are problems with vanishing gradient information flowing through the gates; and

since the non-linearities only softly saturate they do not allow one to take hard decisions.

Although gates often operate in the soft-saturated regime Karpathy et al. (2015); Bahdanau et al. (2014); Hermann et al. (2015) the architecture prevents them from being fully open or closed. We follow a novel approach to address both of these problems. Our method addresses the second problem through the use of hard-saturating nonlinearities, which allow gates to make perfectly on or off decisions when they saturate. Since the gates are able to be completely open or closed, no information is lost through the leakiness of the soft-gating architecture.

By introducing hard-saturating nonlinearities, we have exacerbated the problem of gradient flow, since gradients in the saturated regime are now precisely zero instead of being negligible. However, by introducing noise into the activation function which can grow based on the magnitude of saturation, we encourage random exploration.

At test time the noise in the activation functions can be removed or replaced with the expectation, and as our experiments show, the resulting deterministic networks outperform their soft-saturating counterparts on a wide variety of tasks, and allow to reach state-of-the-art performance by simple drop-in replacement of the nonlinearities in existing training code.

The technique that we propose, addresses the difficulty of optimization and having hard-activations at the test time for gating units and we propose a way of performing simulated annealing for neural networks.

Hannun et al. (2014); Le et al. (2015) used ReLU activation functions with simple RNNs. In this paper, we successfully show that, it is possible to use piecewise-linear activation functions with gated recurrent networks such as LSTM and GRU’s.

Saturating Activation Functions

(Activation Function). An activation function is a function h:RR\text{h}:\mathcal{R}\to\mathcal{R} that is differentiable almost everywhere.

(Saturation). An activation function h(x)\text{h}(x) with derivative h(x)\text{h}^{\prime}(x) is said to right (resp. left) saturate if its limit as xx\to\infty (resp. xx\to-\infty) is zero. An activation function is said to saturate (without qualification) if it both left and right saturates.

Most common activation functions used in recurrent networks (for example, tanh\tanh and sigmoid\operatorname{sigmoid}) are saturating. In particular they are soft saturating, meaning that they achieve saturation only in the limit.

(Hard and Soft Saturation). Let cc be a constant such that x>cx>c implies h(x)=0\text{h}^{\prime}(x)=0 and left hard saturates when x<cx<c implies h(x)=0\text{h}^{\prime}(x)=0, x\forall x. We say that h()\text{h}(\cdot) hard saturates (without qualification) if it both left and right hard saturates. An activation function that saturates but achieves zero gradient only in the limit is said to soft saturate.

We can construct hard saturating versions of soft saturating activation functions by taking a first-order Taylor expansion about zero and clipping the results to an appropriate range.

For example, expanding tanh\tanh and sigmoid\operatorname{sigmoid} around , with x0x\approx 0, we obtain linearized functions ut\text{u}^{t} and us\text{u}^{s} of tanh\tanh and sigmoid\operatorname{sigmoid} respectively:

0.25𝑥0.5\displaystyle\approx\text{u}^{s}(x)=0.25x+0.5 (1) tanh(x)\displaystyle\tanh(x) ut(x)=x.\displaystyle\approx\text{u}^{t}(x)=x. (2) Clipping the linear approximations result to,

The motivation behind this construction is to introduce linear behavior around zero to allow gradients to flow easily when the unit is not saturated, while providing a crisp decision in the saturated regime.

The ability of the hard-sigmoid and hard-tanh to make crisp decisions comes at the cost of exactly 0 gradients in the saturated regime. This can cause difficulties during training: a small but not infinitesimal change of the pre-activation (before the nonlinearity) may help to reduce the objective function, but this will not be reflected in the gradient.

In the rest of the document we will use h(x)h(x) to refer to a generic activation function and use u(x)u(x) to denote its linearization based on the first-order Taylor expansion about zero. hard-sigmoid\operatorname{hard-sigmoid} saturates when x2x\leqslant-2 or x2x\geqslant 2 and hard-tanh\operatorname{hard-tanh} saturates when x1x\leqslant-1 or x1x\geqslant 1. We denote the threshold by xtx_{t}. Absolute values of the threshold are xt=2x_{t}=2 for hard-sigmoid\operatorname{hard-sigmoid} and xt=1x_{t}=1 for the hard-tanh\operatorname{hard-tanh}.

Let us note that both hard-sigmoid(x)\operatorname{hard-sigmoid}(x), sigmoid(x)\operatorname{sigmoid}(x) and tanh(x)\tanh(x) are all contractive mapping. hard-tanh(x)\operatorname{hard-tanh}(x), becomes a contractive mapping only when its input is greater than the threshold. An important difference among these activation functions is their fixed points. hard-sigmoid(x)\operatorname{hard-sigmoid}(x) has a fixed point at x=23x=\frac{2}{3}. However the fixed-point of sigmoid\operatorname{sigmoid} is x0.69x\approx 0.69. Any xRx\in\mathcal{R} between 1-1 and 11 can be the fixed-point of hard-tanh(x)\operatorname{hard-tanh}(x), but the fixed-point of tanh(x)\tanh(x) is . tanh(x)\tanh(x) and sigmoid(x)\operatorname{sigmoid}(x) have point attractors at their fixed-points. Those mathematical differences among the saturating activation functions can make them behave differently with RNNs and deep networks.

The highly non-smooth gradient descent trajectory may bring the parameters into a state that pushes the activations of a unit towards the gradient regime for a particular example, from where it may become difficult to escape and the unit may get stuck in the gradient regime.

When units saturate and gradients vanish, an algorithm may require many training examples and a lot of computation to recover.

Annealing with Noisy Activation Functions

Consider a noisy activation function ϕ(x,ξ)\phi(x,\xi) in which we have injected iid noise ξ\xi, to replace a saturating nonlinearity such as the hard-sigmoid\operatorname{hard-sigmoid} and hard-tanh\operatorname{hard-tanh} introduced in the previous section. In the next section we describe the proposed noisy activation function which has been used for our experiments, but here we want to consider a larger family of such noisy activation functions, when we use a variant of stochastic gradient descent (SGD) for training.

Let ξ\xi have variance σ2\sigma^{2} and mean . We want to characterize what happens as we gradually anneal the noise, going from large noise levels (σ\sigma\rightarrow\infty) to no noise at all (σ0)(\sigma\rightarrow 0).

Furthermore, we will assume that ϕ\phi is such that when the noise level becomes large, so does its derivative with respect to xx:

italic-ϕ𝑥𝜉𝑥\lim_{|\xi|\rightarrow\infty}|\frac{\partial\phi(x,\xi)}{\partial x}|\rightarrow\infty. (5)

In the noise limit, we recover a deterministic nonlinearity, ϕ(x,0)\phi(x,0), which in our experiments is piecewise linear and allows us to capture the kind of complex function we want to learn. As illustrated in Figure 2, in the large noise limit, large gradients are obtained because backpropagating through ϕ\phi gives rise to large derivatives. Hence, the noise drowns the signal: the example-wise gradient on parameters is much larger than it would have been with σ=0\sigma=0. SGD therefore just sees noise and can move around anywhere in parameter space without “seeing” any trend.

Annealing is also related to the signal to noise ratio where SNRSNR can be defined as the ratio of the variance of noise σsignal\sigma_{\text{signal}} and σnoise\sigma_{\text{noise}}, SNR=σsignalσnoiseSNR=\frac{\sigma_{\text{signal}}}{\sigma_{\text{noise}}}. If SNR0SNR\rightarrow 0, the model will do pure random exploration. As we anneal SNRSNR will increase, and when σnoise\sigma_{\text{noise}} converges to , the only source of exploration during the training will come from the noise of Monte Carlo estimates of stochastic gradients.

This is precisely what we need for methods such as simulated annealing (Kirkpatrick et al., 1983) and continuation methods (Allgower & Georg, 1980) to be helpful, in the context of the optimization of difficult non-convex objectives. With high noise, SGD is free to explore all parts of space. As the noise level is decreased, it will prefer some regions where the signal is strong enough to be “visible” by SGD: given a finite number of SGD steps, the noise is not averaged out, and the variance continues to dominate. Then as the noise level is reduced SGD spends more time in “globally better” regions of parameter space. As it approaches to zero we are fine-tuning the solution and converging near a minimum of the noise-free objective function. A related approach of adding noise to gradients and annealing the noise was investigated in Neelakantan et al. (2015) as well. Ge et al. (2015) showed that SGD with annealed noise will globally converge to a local-minima for non-convex objective functions in polynomial number of iterations. Recently, Mobahi (2016) propose an optimization method that applies Gaussian smoothing on the loss function such that annealing weight noise is a Monte Carlo estimator of that.

Adding Noise when the Unit Saturate

A novel idea behind the proposed noisy activation is that the amount of noise added to the nonlinearity is proportional to the magnitude of saturation of the nonlinearity. For hard-sigmoid(x)\operatorname{hard-sigmoid}(x) and hard-tanh(x)\operatorname{hard-tanh}(x), due to our parametrization of the noise, that translates into the fact that the noise is only added when the hard-nonlinearity saturates. This is different from previous proposals such as the noisy rectifier from Bengio (2013) where noise is added just before a rectifier (ReLU) unit, independently of whether the input is in the linear regime or in the saturating regime of the nonlinearity.

The motivation is to keep the training signal clean when the unit is in the non-saturating (typically linear) regime and provide some noisy signal when the unit is in the saturating regime.

h(x)\text{h}(x) refer to hard saturation activation function such as the hard-sigmoid and hard-tanh introduced in Sec. 2, we consider noisy activation functions of the following form:

h𝑥𝑠\phi(x,\xi)=\text{h}(x)+s (6) and s=μ+σξs=\mu+\sigma\xi. Here ξ\xi is an iid random variable drawn from some generating distribution, and the parameters μ\mu and σ\sigma (discussed below) are used to generate a location scale family from ξ\xi.

Intuitively when the unit saturates we pin its output to the threshold value tt and add noise. The exact behavior of the method depends on the type of noise ξ\xi and the choice of μ\mu and σ\sigma, which we can pick as functions of xx in order to let some gradients be propagated even when we are in the saturating regime.

A desirable property we would like ϕ\phi to approximately satisfy is that, in expectation, it is equal to the hard-saturating activation function, i.e.

If the ξ\xi distribution has zero mean then this property can be satisfied by setting μ=0\mu=0, but for biased noise it will be necessary to make other choices for μ\mu. In practice, we used slightly biased ϕ\phi with good results.

Intuitively we would like to add more noise when xx is far into the saturated regime, since a large change in parameters would be required desaturate hh. Conversely, when xx is close to the saturation threshold a small change in parameters would be sufficient for it to escape. To that end we make use of the difference between the original activation function hh and its linearization uu

when choosing the scale of the noise. See Eqs.1 for definitions of uu for the hard-sigmoid\operatorname{hard-sigmoid} and hard-tanh\operatorname{hard-tanh} respectively. The quantity Δ\Delta is zero in the unsaturated regime, and when hh saturates it grows proportionally to the distance between x|x| and the saturation threshold xtx_{t}. We also refer Δ|\Delta| as the magnitude of the saturation.

We experimented with different ways of scaling σ\sigma with Δ\Delta, and empirically found that the following formulation performs better:

In Equation 9 a free scalar parameter pp is learned during the course of training. By changing pp, the model is able to adjust the magnitude of the noise and that also effects the sign of the gradient as well. The hyper-parameter cc changes the scale of the standard deviation of the noise.

In the simplest case of our method we draw ξ\xi from an unbiased distribution, such as a standard normal. In this case we choose μ=0\mu=0 to satisfy Equation 7 and therefore we will have,

h𝑥𝜎𝑥𝜉\displaystyle\phi(x,\xi)=\text{h}(x)+\sigma(x)\xi Figure 3: A simple depiction of adding Gaussian noise on the linearized activation function, which brings the average back to the hard-saturating nonlinearity h(x)\text{h}(x), in bold. Its linearization is u(x)\text{u}(x) and the noisy activation is ϕ\phi. The difference h(x)u(x)\text{h}(x)-\text{u}(x) is Δ\Delta which is a vector indicates the discrepancy between the linearized function and the actual function that the noise is being added to h(x)\text{h}(x). Note that, Δ\Delta will be zero, at the non-saturating parts of the function where u(x)\text{u}(x) and h(u)\text{h}(u) matches perfectly. Due to our parameterization of σ(x)\sigma(x), when xxt|x|\leq x_{t} our stochastic activation function behaves exactly as the linear function u(x)\text{u}(x), leading to familiar territory. Because Δ\Delta will be . Let us for the moment restrict our attention to the case when x>xt|x|>x_{t} and hh saturates. In this case the derivative of h(x)\text{h}(x) is precisely zero, however, if we condition on the sample ξ\xi we have

𝑥italic-ϕ𝑥𝜉superscript𝜎′𝑥𝜉\displaystyle\phi^{\prime}(x,\xi)=\frac{\partial}{\partial x}\phi(x,\xi)=\sigma^{\prime}(x)\xi (10) which is non-zero almost surely.

In the non-saturated regime, where ϕ(x,ξ)=h(x)\phi^{\prime}(x,\xi)=\text{h}^{\prime}(x) the optimization can exploit the linear structure of hh near the origin in order to tune its output. In the saturated regime the randomness in ξ\xi drives exploration, and gradients still flow back to xx since the scale of the noise still depends on xx. To reiterate, we get gradient information at every point in spite of the saturation of h, and the variance of the gradient information in the saturated regime depends on the variance of σ(x)ξ\sigma^{\prime}(x)\xi.

2 Pushing Activations towards Linear Regime

An unsatisfying aspect of the formulation with unbiased noise is that, depending on the value of ξ\xi occasionally the gradient of ϕ\phi will point the wrong way. This can cause a backwards message that would push xx in a direction that would worsen the objective function on average over ξ\xi. Intuitively we would prefer these messages to “push back” the saturated unit towards a non-saturated state where the gradient of h(x)\text{h}(x) can be used safely.

A simple way to achieve this is to make sure that the noise ξ\xi is always positive and adjust its sign manually to match the sign of xx. In particular we could set

𝜇𝑥d𝑥𝜎𝑥𝜉\displaystyle\mu(x)+\text{d}(x)\sigma(x)|\xi|. where ξ\xi and σ\sigma are as before and sgn\operatorname{sgn} is the sign function, such that sgn(x)\operatorname{sgn}(x) is 11 if xx is greater than or equal to otherwise it is 1-1. We also use the absolute value of ξ\xi in the reparametrization of the noise, such that the noise is being sampled from a half-Normal distribution. We ignored the sign of ξ\xi, such that the direction that the noise pushes the activations are determined by d(x)\text{d}(x) and it will point towards h(x)\text{h}(x). Matching the sign of the noise to the sign of xx would ensure that we avoid the sign cancellation between the noise and the gradient message from backpropagation. sgn(1α)\operatorname{sgn}(1-\alpha) is required to push the activations towards h(x)\text{h}(x) when the bias from α\alpha is introduced.

In practice we use a hyperparameter α\alpha that influences the mean of the added term, such that α\alpha near 1 approximately satisfies the above condition, as seen in Fig. 4. We can rewrite the noisy term ss in a way that the noise can either be added to the linearized function or h(x)\text{h}(x). The relationship between Δ\Delta, u(x)\text{u}(x) and h(x)\text{h}(x) is visualized Figure 3 can be expressed as in Eqn 11.

We have experimented with different types of noise. Empirically, in terms of performance we found, half-normal and normal noise to be better. In Eqn 11, we provide the formulation for the activation function where ϵ=ξ\epsilon=|\xi| if the noise is sampled from half-normal distribution, ϵ=ξ\epsilon=\xi if the noise is sampled from normal distribution.

u𝑥𝛼Δd𝑥𝜎𝑥italic-ϵ\displaystyle=\text{u}(x)+\alpha\Delta+\text{d}(x)\sigma(x)\epsilon (11) By using Eqn 11, we arrive at the noisy activations, which we used in our experiments.

𝛼h𝑥1𝛼u𝑥d𝑥𝜎𝑥italic-ϵ\phi(x,\xi)=\alpha\text{h}(x)+(1-\alpha)\text{u}(x)+\text{d}(x)\sigma(x)\epsilon (12) As can be seen in Eqn 12, there are three paths that gradients can flow through the neural network, the linear path (u(x)\text{u}(x)), nonlinear path (h(x)\text{h}(x)) and the stochastic path (σ(x)\sigma(x)). The flow of gradients through these different pathways across different layers makes the optimization of our activation function easier.

At test time, we used the expectation of Eqn 12 in order to get deterministic units,

𝛼h𝑥1𝛼u𝑥d𝑥𝜎𝑥subscriptE𝜉delimited-[]italic-ϵ\mathrm{E}_{\xi}[\phi(x,\xi)]=\alpha\text{h}(x)+(1-\alpha)\text{u}(x)+\text{d}(x)\sigma(x)\mathrm{E}_{\xi}[\epsilon] (13) If ϵ=ξ\epsilon=\xi, then Eξ[ϵ]\mathrm{E}_{\xi}[\epsilon] is . Otherwise if ϵ=ξ\epsilon=|\xi|, then Eξ[ϵ]\mathrm{E}_{\xi}[\epsilon] is 2π\sqrt{\frac{2}{\pi}}.

𝛼h𝑥1𝛼u𝑥d𝑥𝜎𝑥𝜉\phi(x,\xi)\leftarrow\alpha\text{h}(x)+(1-\alpha)\text{u}(x)+(\text{d}(x)\sigma(x)|\xi|) To illustrate the effect of α\alpha and noisy activation of the hard-tanh\operatorname{hard-tanh}, We provide plots of our stochastic activation functions in Fig 4.

Adding Noise to Input of the Function

Adding noise with fixed standard deviation to the input of the activation function has been investigated for ReLU activation functions Nair & Hinton (2010); Bengio et al. (2013).

𝑥𝜎𝜉and𝜉similar-to𝒩01\phi(x,\xi)=\text{h}(x+\sigma\xi)~{}\text{and}~{}\xi\sim\mathcal{N}(0,1). (14) In Eqn 14, we provide a parametrization of the noisy activation function. σ\sigma can be either learned as in Eqn 9 or fixed as a hyperparameter.

The condition in Eqn 5 is satisfied only when σ\sigma is learned. Experimentally we found small values of σ\sigma to work better. When σ\sigma is fixed and small, as xx gets larger and further away from the threshold xtx_{t}, noise will less likely be able to push the activations back to the linear regime. We also investigated the effect of injecting input noise when the activations saturate:

Experimental Results

In our experiments, we used noise only during training: at test time we replaced the noise variable with its expected value. We performed our experiments with just a drop-in replacement of the activation functions in existing experimental setups, without changing the previously set hyper-parameters. Hence it is plausible one could obtain better results by performing a careful hyper-parameter tuning for the models with noisy activation functions. In all our experiments, we initialized pp uniform randomly from the range [1, 1]\left[-1,~{}1\right].

We provide experimental results using noisy activations with normal (NAN), half-normal noise (NAH), normal noise at the input of the function (NANI), normal noise at the input of the function with learned σ\sigma (NANIL) and normal noise injected to the input of the function when the unit saturates (NANIS). Codes for different types of noisy activation functions can be found at https://xx.

As a sanity-check, we performed small-scale control experiments, in order to observe the behavior of the noisy units. In Fig 5, we showed the learning curves of different types of activations with various types of noise in contrast to the tanh\tanh and hard-tanh\operatorname{hard-tanh} units. The models are single-layer MLPs trained on MNIST for classification and we show the average negative log-likelihood logP(correct  classinput)-\log P({\rm correct\;class}|{\rm input}). In general, we found that models with noisy activations converge faster than those using tanh\tanh and hard-tanh\operatorname{hard-tanh} activation functions, and to lower NLL than the tanh\tanh network.

We trained 33-layer MLP on a dataset generated from a mixture of 33 Gaussian distributions with different means and standard deviations. Each layer of the MLP contains 88-hidden units. Both the model with tanh\tanh and noisytanh-\tanh activations was able to solve this task almost perfectly. By using the learned pp values, in Figure 6 and 7, we showed the scatter plot of the activations of each unit at each layer and the derivative function of each unit at each layer with respect to its input.

italic-ϕsubscriptsuperscript𝑥𝑘𝑖subscriptsuperscript𝜉𝑘𝑖subscriptsuperscript𝑥𝑘𝑖\frac{\partial\phi(x^{k}_{i},\xi^{k}_{i})}{\partial x^{k}_{i}} at the end of training for ithi^{th} unit at kthk^{th} layer. ξk\xi^{k} is sampled from Normal distribution with α=1\alpha=1. Figure 7: Activations of each unit at each layer of a three-layer MLP trained on a dataset generated by three normal distributions with different means and standard deviations. In other words learned ϕ(xik,ξik)\phi(x^{k}_{i},\xi^{k}_{i}) at the end of training for ithi^{th} unit at kthk^{th} layer. ξk\xi^{k} is sampled from Half-Normal distribution with α=1\alpha=1. Figure 8: We show the learning curves of a simple character-level GRU language model over the sequences of length 200200 on PTB. NANI and NAN, have very similar learning curves. NANIS in the beginning of the training has a better progress than NAN and NANIS, but then training curve stops improving. We further investigated the performances of network with activation functions using NAN, NANI and NANIS on penntreebank (PTB) character-level language modeling. We used a GRU language model over sequences of length 200200. We used the same model and train all the activation functions with the same hyperparameters except we ran a grid-search for σ\sigma for NANI and NANIS from [1, 0.01][1,~{}0.01] with 88 values. We choose the best σ\sigma based on the validation bit-per-character (BPC). We have not observed important difference among NAN and NANI in terms of training performance as seen on Figure 8.

2 Learning to Execute

The problem of predicting the output of a short program introduced in Zaremba & Sutskever (2014) 111The code is residing at https://github.com/wojciechz/learning_to_execute. We thank authors for making it publicly available. proved challenging for modern deep learning architectures. The authors had to use curriculum learning (Bengio et al., 2009) to let the model capture knowledge about the easier examples first and increase the level of difficulty of the examples further down the training.

We replaced all sigmoid\operatorname{sigmoid} and tanh\tanh non-linearities in the reference model with their noisy counterparts. We changed the default gradient clipping to 55 from 1010 in order to avoid numerical stability problems. When evaluating a network, the length (number of lines) of the executed programs was set to 66 and nesting was set to 33, which are default settings in the released code for these tasks. Both the reference model and the model with noisy activations were trained with “combined” curriculum which is the most sophisticated and the best performing one.

Our results show that applying the proposed activation function leads to better performance than that of the reference model. Moreover it shows that the method is easy to combine with a non-trivial learning curriculum. The results are presented in Table 1 and in Figure 10

3 Penntreebank Experiments

We trained a 22-layer word-level LSTM language model on Penntreebank. We used the same model proposed by Zaremba et al. (2014). 222We used the code provided in https://github.com/wojzaremba/lstmWe simply replaced all sigmoid\operatorname{sigmoid} and tanh\tanh units with noisy hard-sigmoid\operatorname{hard-sigmoid} and hard-tanh\operatorname{hard-tanh} units. The reference model is a well-finetuned strong baseline from Zaremba et al. (2014). For the noisy experiments we used exactly the same setting, but decreased the gradient clipping threshold to 55 from 1010. We provide the results of different models in Table 2. In terms of validation and test performance we did not observe big difference between the additive noise from Normal and half-Normal distributions, but there is a substantial improvement due to noise, which makes this result the new state-of-the-art on this task, as far as we know.

4 Neural Machine Translation Experiments

We have trained a neural machine translation (NMT) model on the Europarl dataset with the neural attention model Bahdanau et al. (2014).333Again, we have used existing code, provided in https://github.com/kyunghyuncho/dl4mt-material, and only changed the nonlinearities We have replaced all sigmoid\operatorname{sigmoid} and tanh\tanh units with their noisy counterparts. We have scaled down the weight matrices initialized to be orthogonal scaled by multiplying with 0.010.01. Evaluation is done on the newstest2011 test set. All models are trained with early-stopping. We also compare with a model with hard-tanh\operatorname{hard-tanh} and hard-sigmoid\operatorname{hard-sigmoid} units and our model using noisy activations was able to outperform both, as shown in Table 4. Again, we see a substantial improvement (more than 22 BLEU points) with respect to the reference for English to French machine translation.

5 Image Caption Generation Experiments

We evaluated our noisy activation functions on a network trained on the Flickr8k dataset. We used the soft neural attention model proposed in Xu et al. (2015) as our reference model.444We used the code provided at https://github.com/kelvinxu/arctic-captions. We scaled down the weight matrices initialized to be orthogonal scaled by multiplying with 0.010.01. As shown in Table 3, we were able to obtain better results than the reference model and our model also outperformed the best model provided in Xu et al. (2015) in terms of Meteor score.

(Xu et al., 2015)’s model was using dropout with the ratio of 0.50.5 on the output of the LSTM layers and the context. We have tried both with and without dropout, as in Table 3, we observed improvements with the addition of dropout to the noisy activation function. But the main improvement seems to be coming with the introduction of the noisy activation functions since the model without dropout already outperforms the reference model.

6 Experiments with Continuation

We performed experiments to validate the effect of annealing the noise to obtain a continuation method for neural networks.

We designed a new task where, given a random sequence of integers, the objective is to predict the number of unique elements in the sequence. We use an LSTM network over the input sequence, and performed a time average pooling over the hidden states of LSTM to obtain a fixed-size vector. We feed the pooled LSTM representation into a simple (one hidden-layer) ReLU MLP in order to predict the unique number of elements in the input sequence. In the experiments we fixed the length of input sequence to 2626 and the input values are between and 1010. In order to anneal the noise, we started training with the scale hyperparameter of the standard deviation of noise with c=30c=30 and annealed it down to 0.50.5 with the schedule of ct+1\frac{c}{\sqrt{t+1}} where tt is being incremented at every 200200 minibatch updates. When noise annealing is combined with a curriculum strategy (starting with short sequences first and gradually increase the length of the training sequences), the best models are obtained.

As a second test, we used the same annealing procedure in order to train a Neural Turing Machine (NTM) on the associative recall task Graves et al. (2014). We trained our model with a minimum of 22 items and a maximum of 1616 items. We show results of the NTM with noisy activations in the controller, with annealed noise, and compare with a regular NTM in terms of validation error. As can be seen in Figure 11, the network using noisy activation converges much faster and nails the task, whereas the original network failed to approach a low error.

Conclusion

Nonlinearities in neural networks are both a blessing and a curse. A blessing because they allow to represent more complicated functions and a curse because that makes the optimization more difficult. For example, we have found in our experiments that using a hard version (hence more nonlinear) of the sigmoid and tanh\tanh nonlinearities often improved results. In the past, various strategies have been proposed to help deal with the difficult optimization problem involved in training some deep networks, including curriculum learning, which is an approximate form of continuation method. Earlier work also included softened versions of the nonlinearities that are gradually made harder during training. Motivated by this prior work, we introduce and formalize the concept of noisy activations as a general framework for injecting noise in nonlinear functions so that large noise allows SGD to be more exploratory. We propose to inject the noise to the activation functions either at the input of the function or at the output where unit would otherwise saturate, and allow gradients to flow even in that case. We show that our noisy activation functions are easier to optimize. It also, achieves better test errors, since the noise injected to the activations also regularizes the model as well. Even with a fixed noise level, we found the proposed noisy activations to outperform their sigmoid or tanh\tanh counterpart on different tasks and datasets, yielding state-of-the-art or competitive results with a simple modification, for example on PennTreebank. In addition, we found that annealing the noise to obtain a continuation method could further improved performance.

References

Acknowledgements

The authors would like to acknowledge the support of the following agencies for research funding and computing support: NSERC, Calcul Québec, Compute Canada, Samsung, the Canada Research Chairs and CIFAR. We would also like to thank the developers of Theano 555http://deeplearning.net/software/theano/, for developing such a powerful tool for scientific computing. Caglar Gulcehre also thanks to IBM Watson Research and Statistical Knowledge Discovery Group at IBM Research for supporting this work during his internship.