Skip to article frontmatterSkip to article content
Site not loading correctly?

This may be due to an incorrect BASE_URL configuration. See the MyST Documentation for reference.

Recurrent Neural Network

Recurrent Neural Network

Normal neural network is insufficient to train sequence data. Some examples of sequence data are:

Sequential data contains multiple entities and the order in which these entities are present is important.

In RNN each activation is dependent on two things: the activation in the previous layer l-1 at the current timestep t, and the activation in the same layer l at the previous timestep t-1

Figure 1:In RNN each activation is dependent on two things: the activation in the previous layer l1l-1 at the current timestep tt, and the activation in the same layer ll at the previous timestep t1t-1

Types of RNN

Backpropagation Through Time (BPTT)

Any given term in an RNN depends not only on the current input but also on the input from previous timesteps. The gradients not only flow back from the output layer to the input layer, but they also flow back in time from the last timestep to the first timestep. Hence the name backpropagation through time.

Exploding and Vanishing gradient:

How to understand

How to rectify

Bidirectional RNNs

There are two kinds of problems in sequences:

You can make use of offline sequences by looking ahead. You can feed the offline sequences to an RNN in regular order as well as the reverse order to get better results in whatever task you’re doing. Such an RNN is called a bidirectional RNN. In a bidirectional RNN, the input at each timestep is a concatenation of the entity present in regular order and the entity present in reverse order. For example, for a sentence of length 100, the input at the first timestep will be a concatenation of the first word x1x_1 and the last word x100x_{100}. A bidirectional RNN has 2x number of parameters than a vanilla RNN.

LSTM