Gating mechanism - Wikipedia


Article Images

In neural networks, the gating mechanism is an architectural motif for controlling the flow of activation and gradient signals. They are most prominently used in recurrent neural networks (RNNs), but have also found applications in other architectures.

Gating mechanisms are the centerpiece of long short-term memory (LSTM).[1] It was proposed to solve the vanishing gradient problem that made training RNNs for long-sequence modelling unstable. An LSTM contains three gates: the input gate, the forget gate, and the output gate. The input gate controls the flow of new information into the memory cell, the forget gate controls how much information is retained from the previous time step, and the output gate controls how much information is passed to the next layer.

The equations for LSTM are:[2] Here,   represents elementwise multiplication.

  • LSTM architecture, with gates

The gated recurrent unit (GRU) simplifies the LSTM.[3] Compared to the LSTM, the GRU has just two gates: reset gate and update gate, and also merges the cell state and hidden state. The reset gate roughly corresponds to the forget gate, and the update gate roughly corresponds to the input gate. The output gate is removed. There are several variants of GRU. One particular variant has these equations:[4] 

  • Gated Recurrent Unit architecture, with gates

Gated Linear Units (GLUs)[5] adapt the gating mechanism for use in feedforward networks, often within Transformer-based architectures. They are defined as: where   is the first input and   is the second input. The   represents the sigmoid activation function.

Replacing   by other activation functions leads to variants of GLU: where ReLU, GELU, and Swish are different activation functions (see the main page for definitions).

In a Transformer, such gating units are often used in the feedforward modules. For a single vector input, this results in:[6]

Gating mechanism is used in highway networks, which were designed by unrolling an LSTM.

Channel gating[7] uses a gate to control the flow of information through different channels inside a convolutional neural network (CNN).

  1. ^ Sepp Hochreiter; Jürgen Schmidhuber (1997). "Long short-term memory". Neural Computation. 9 (8): 1735–1780. doi:10.1162/neco.1997.9.8.1735. PMID 9377276. S2CID 1915014.
  2. ^ Zhang, Aston; Lipton, Zachary; Li, Mu; Smola, Alexander J. (2024). "10.1. Long Short-Term Memory (LSTM)". Dive into deep learning. Cambridge New York Port Melbourne New Delhi Singapore: Cambridge University Press. ISBN 978-1-009-38943-3.
  3. ^ Cho, Kyunghyun; van Merrienboer, Bart; Bahdanau, DZmitry; Bougares, Fethi; Schwenk, Holger; Bengio, Yoshua (2014). "Learning Phrase Representations using RNN Encoder-Decoder for Statistical Machine Translation". Association for Computational Linguistics. arXiv:1406.1078.
  4. ^ Zhang, Aston; Lipton, Zachary; Li, Mu; Smola, Alexander J. (2024). "10.2. Gated Recurrent Units (GRU)". Dive into deep learning. Cambridge New York Port Melbourne New Delhi Singapore: Cambridge University Press. ISBN 978-1-009-38943-3.
  5. ^ Dauphin, Yann N.; Fan, Angela; Auli, Michael; Grangier, David (2017-07-17). "Language Modeling with Gated Convolutional Networks". Proceedings of the 34th International Conference on Machine Learning. PMLR: 933–941.
  6. ^ Shazeer, Noam (February 14, 2020). "GLU Variants Improve Transformer". arXiv:2002.05202 [cs.LG].
  7. ^ Hua, Weizhe; Zhou, Yuan; De Sa, Christopher M; Zhang, Zhiru; Suh, G. Edward (2019). "Channel Gating Neural Networks". Advances in Neural Information Processing Systems. 32. Curran Associates, Inc.