Recurrent Neural Networks (RNN)
Definition:
Recurrent Neural Networks (RNNs) are a class of artificial neural networks designed for modeling sequential data by introducing loops that allow information to persist across time steps. They are widely used for tasks like time-series forecasting, natural language processing (NLP), and speech recognition because of their ability to process and maintain information from previous inputs.
Video Explanation

Characteristics:
-
Sequential Data Handling:
RNNs excel at learning from and making predictions based on sequential data, where the order and context of the input are crucial. -
Shared Weights:
Unlike traditional neural networks, RNNs share the same parameters (weights) across different time steps, which allows them to process variable-length sequences without increasing the number of parameters. -
Memory:
RNNs have internal memory due to their recurrent connections, which allows them to store information about previous inputs and use it to influence future predictions.
Components of RNN:
-
Hidden State:
RNNs maintain a hidden state that captures information from previous time steps. At each time step, the hidden state is updated based on the current input and the previous hidden state. -
Recurrent Connection:
The recurrent connection is the key feature of RNNs. It enables information to flow from one time step to the next, creating a loop in the network's structure. -
Activation Function:
The hidden state is passed through an activation function, typically tanh or ReLU, to introduce non-linearity into the network and allow it to model complex patterns in sequential data. -
Output Layer:
The output at each time step is computed based on the current hidden state and can be used for predictions, classification, or further processing.
RNN Architecture:
-
Input Layer:
Sequential data, such as a series of time steps (e.g., words in a sentence or stock prices over time), is provided as input to the RNN. -
Recurrent Hidden Layer(s):
The hidden layer(s) process the input data one time step at a time, updating the hidden state based on both the current input and the previous hidden state. -
Output Layer:
Depending on the task, RNNs can produce output at each time step (e.g., for translation or generation tasks) or at the end of the sequence (e.g., for sentiment analysis or time-series prediction).
Types of RNNs:
-
Vanilla RNN:
The simplest form of RNN, where the hidden state is updated using the same weights at each time step. However, vanilla RNNs struggle with learning long-term dependencies due to the vanishing gradient problem. -
Long Short-Term Memory (LSTM):
LSTMs are a more advanced form of RNN designed to overcome the vanishing gradient problem. They use gates (input, forget, output) to control the flow of information and can learn long-term dependencies. -
Gated Recurrent Unit (GRU):
GRUs are a simplified version of LSTMs that combine the input and forget gates into a single update gate. GRUs are computationally cheaper while still addressing the vanishing gradient problem. -
Bidirectional RNN (BiRNN):
In a bidirectional RNN, two RNNs are run in parallel: one processes the sequence from left to right, and the other processes it from right to left. This architecture is useful for tasks where future context is as important as past context.
Problem Statement:
Given a sequential dataset (e.g., a sentence for language modeling or a time-series for prediction), the goal of an RNN is to predict the next element in the sequence or classify the entire sequence based on its content.