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.

RNNs

edit

Gating mechanisms are the centerpiece of long short-term memory (LSTM).[1] They were proposed to mitigate the vanishing gradient problem often encountered by regular RNNs.

An LSTM unit contains three gates:

  • An input gate, which controls the flow of new information into the memory cell
  • A forget gate, which controls how much information is retained from the previous time step
  • An output gate, which controls how much information is passed to the next layer.

The equations for LSTM are:[2]

 

Here,   represents elementwise multiplication.

The gated recurrent unit (GRU) simplifies the LSTM.[3] Compared to the LSTM, the GRU has just two gates: a reset gate and an update gate. GRU 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 Linear Unit

edit

Gated Linear Units (GLUs)[5] adapt the gating mechanism for use in feedforward neural networks, often within transformer-based architectures. They are defined as:

 

where   are the first and second inputs, respectively.   represents the sigmoid activation function.

Replacing   with other activation functions leads to variants of GLU:

 

where ReLU, GELU, and Swish are different activation functions (see this table for definitions).

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

 

Other architectures

edit

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).

See also

edit

References

edit
  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. arXiv:1612.08083.
  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. arXiv:1805.12549.

Further reading

edit