We already the formula for calculating the activation at any time t of an RNN. It is as follows :

Now here we take the activation of the previous layer along with the input of the current layer and pass it through a activation function which mostly is tanh. Then we use the calculated activation to calculate our output for that layer.

Note

I have previously used the term network to word the different layers of a RNN. Well technically they can be consider as networks, but the term layer is also not incorrect.

The GRU unit is going to have a new variable called C, which stands for memory cell. At time t, the memory cell will have a value . In the GRU unit the values and are the same.

At every time step we are going to consider an overwriting the memory cell with a value . This is going to be a candidate for replacing .

Now a GRU has a gate named Gamma which has value between 0 and 1. The gate is defined as :

The job of the gate is to decide when do we update the value of . Also here denotes the sigmoid function.

So the actual value of is given by :

So in short, we have the previous value of the memory function i.e. and as the input. By using the inputs we calculate the candidate value to replace the memory function value which is and the gate Gamma . Using the value of the gate, the candidate value and the previous value we update the new value.

Of course in practice the gate Gamma would not be exactly 0 or 1 sometimes we will get values in middle as well. Till now we have discussed the simplified version of the GRU unit.

Full GRU unit

So while calculating the candidate value (), we also might find the previous value of the memory function sometimes irrelevant. To make sure that we take this into consideration we use another gate denoted by . So the equation now becomes :

where is defined as :

We use rest of the equation as mentioned above.

Now along with the GRU unit there is another unit called as the Long short term memory unit (LSTM) which perform even better then the GRU unit.