Lably
Skip to content

Gated recurrent unit

Memory unit used in neural networks

  • 2 min read
  • 1 chapter

Related on Lably

Through Neural network (machine learning), Recurrent neural network and Logistic function

Architecture

There are several variations on the full gated unit, with gating done using the previous hidden state and the bias in various combinations, and a simplified form called minimal gated unit.

In the following, the operator ⊙ denotes the Hadamard product.

Fully gated unit

Initially, for t=0, the output vector is h0=0.

zt=σ(Wzxt+Uzht−1+bz)rt=σ(Wrxt+Urht−1+br)h^t=ϕ(Whxt+Uh(rt⊙ht−1)+bh)ht=(1−zt)⊙ht−1+zt⊙h^t

Variables (d denotes the number of input features and e the number of output features):

  • xt∈Rd: input vector
  • ht∈Re: output vector
  • h^t∈Re: candidate activation vector
  • zt∈(0,1)e: update gate vector
  • rt∈(0,1)e: reset gate vector
  • W∈Re×d, U∈Re×e and b∈Re: parameter matrices and vector which need to be learned during training

Activation functions

Alternative activation functions are possible, provided that σ(x)∈[0,1].

Alternate forms can be created by changing zt and rt

  • Type 1: each gate depends only on the previous hidden state and the bias.
    zt=σ(Uzht−1+bz)rt=σ(Urht−1+br)
  • Type 2: each gate depends only on the previous hidden state.
    zt=σ(Uzht−1)rt=σ(Urht−1)
  • Type 3: each gate is computed using only the bias.
    zt=σ(bz)rt=σ(br)

Minimal gated unit

The minimal gated unit (MGU) is similar to the fully gated unit, except the update and reset gate vector is merged into a forget gate. This also implies that the equation for the output vector must be changed:

ft=σ(Wfxt+Ufht−1+bf)h^t=ϕ(Whxt+Uh(ft⊙ht−1)+bh)ht=(1−ft)⊙ht−1+ft⊙h^t

Variables

  • xt: input vector
  • ht: output vector
  • h^t: candidate activation vector
  • ft: forget vector
  • W, U and b: parameter matrices and vector

Light gated recurrent unit

The light gated recurrent unit (LiGRU) removes the reset gate altogether, replaces tanh with the ReLU activation, and applies batch normalization (BN):

zt=σ(BN⁡(Wzxt)+Uzht−1)h~t=ReLU⁡(BN⁡(Whxt)+Uhht−1)ht=zt⊙ht−1+(1−zt)⊙h~t

LiGRU has been studied from a Bayesian perspective. This analysis yielded a variant called light Bayesian recurrent unit (LiBRU), which showed slight improvements over the LiGRU on speech recognition tasks.

More in Computing and communication