Bridging Nonlinearities and Stochastic Regularizers with Gaussian Error Linear Units

Dan Hendrycks, Kevin GimpelarXiv 2016

Introduction

In deep learning, the choice of activation function is a critical architectural decision. For years, the Rectified Linear Unit (ReLU) has served as the industry standard, primarily due to its ability to enable faster convergence compared to traditional sigmoid activations. However, ReLUs function as "hard" gates—they multiply an input by zero or one based strictly on its sign.

Parallel to the development of nonlinearities, stochastic regularizers like Dropout have become essential for preventing overfitting by randomly zeroing out activations. Historically, these two components—the nonlinearity and the regularizer—have remained distinct. This paper proposes a unified, probabilistic framework for neuron activation: the Gaussian Error Linear Unit (GELU), which incorporates the benefits of stochasticity directly into the nonlinearity itself.

The Gaussian Error Linear Unit (GELU)

Instead of the deterministic gating of a ReLU ($x \cdot \mathbf{1}_{x>0}$), the GELU weights the input $x$ by the probability that the input is greater than other inputs, assuming a standard normal distribution. Formally, the GELU is defined as:

$$GELU(x) = x\Phi(x)$$

where $\Phi(x)$ is the standard Gaussian cumulative distribution function (CDF).

Comparison of GELU, ReLU, and ELU activation functions. Note the smooth curvature and the small negative dip of the GELU.

Probabilistic Interpretation and Approximations

The GELU can be viewed as the expectation of an input $x$ being multiplied by a mask $m \sim \text{Bernoulli}(\Phi(x))$. As $x$ decreases, the probability of it being "dropped" increases, providing an input-dependent gating mechanism. Since the exact Gaussian CDF is computationally expensive, the authors provide two fast approximations:

  1. $0.5x(1 + \tanh[\sqrt{2/\pi}(x + 0.044715x^3)])$
  2. $x\sigma(1.702x)$ (where $\sigma$ is the sigmoid function)

Empirical Performance

The authors evaluated GELUs against ReLUs and ELUs across a diverse set of benchmarks spanning computer vision, natural language processing, and speech recognition.

Log loss curves for training and testing across 50 epochs. GELU consistently achieves lower loss and faster convergence than ReLU and ELU.

Key Results

  • Computer Vision: On CIFAR-10, a 9-layer CNN using GELUs achieved a 7.89% error rate, outperforming ReLU (8.16%) and ELU (8.41%). On CIFAR-100, using a Wide Residual Network, GELU reached a 20.74% error, significantly better than ReLU (21.77%).
  • MNIST Autoencoder: GELU converged faster and reached lower reconstruction error across multiple learning rates compared to other nonlinearities.
  • NLP and Speech: In Twitter part-of-speech (POS) tagging and TIMIT speech recognition, GELU consistently yielded the lowest median test error (e.g., 12.57% on Twitter POS vs. 12.67% for ReLU).

Key Insights and Discussion

Unlike ReLU and ELU, which are monotonic and linear in the positive domain, the GELU is non-convex and non-monotonic. It features a small "dip" below zero for small positive values. This increased curvature allows it to approximate complex functions more effectively than the piecewise linear ReLU.

Furthermore, GELU can be viewed as a "Smooth ReLU." As the variance of the underlying distribution goes to zero, the GELU mathematically converges to a ReLU. While Dropout ignores the input value when deciding what to mask, GELU makes the masking probability dependent on the input itself, offering a more principled approach to handling stochasticity in deep networks.

Conclusion

The Gaussian Error Linear Unit provides a high-performing alternative to standard activation functions by bridging the gap between deterministic gating and stochastic regularization. By weighting inputs by their magnitude rather than just their sign, GELUs have demonstrated consistent performance gains across a wide array of state-of-the-art deep learning tasks.

Summary updated

BibTeX
@misc{hendrycks2016bridging,
  author = {Dan Hendrycks and Kevin Gimpel},
  title = {{Bridging Nonlinearities and Stochastic Regularizers with Gaussian Error Linear Units}},
  year = {2016},
  eprint = {1606.08415},
  archivePrefix = {arXiv},
  url = {https://arxiv.org/abs/1606.08415},
}
Figure