DL Unit - III Notes1
DL Unit - III Notes1
UNIT-III
What is a Recurrent Neural Network (RNN)?
Definition: RNNs are designed for sequential data, where each neuron
connects to the next layer and to neurons within the same layer.
Recurrent neural networks (RNNs) are used by Apple’s Siri and Google’s
voice search. It is the first one that remembers its input, due to an internal
memory
Structure:
RNN were created because there were a few issues in the feed-
forward neural network:
1. ANN: Artificial neural networks that do not have looping nodes are
called feed forward neural networks.
RNN: In an RNN, the information cycles through a loop.
RNNs are a type of neural network that has hidden states and allows
past outputs to be used as inputs.
key components:
Input Layer: This layer receives the initial element of the sequence
data. For example, in a sentence, it might receive the first word as a
vector representation.
Hidden Layer: The heart of the RNN, the hidden layer contains a set
of interconnected neurons. Each neuron processes the current input
along with the information from the previous hidden layer’s state.
This “state” captures the network’s memory of past inputs, allowing
it to understand the current element in context.
Activation Function: This function introduces non-linearity into the
network, enabling it to learn complex patterns. It transforms the
combined input from the current input layer and the previous hidden
layer state before passing it on.
ht= f (ht-1,xt)
Where:
ht= f (ht-1,xt),
Where:
Wxh is the weight at input neuron,
Yt=Whyht.
Where,
Yt is the Output and,
Why is the weight at the output layer.
In the input layers, the initial input is sent with all having the same
weight and activation function.
Using the current input and the previous state output, the current
state is calculated.
Now the current state ht will become ht-1 for the second time step.
This keeps on repeating all the steps, and to solve any particular
problem, it can go on as many times to join the information from all
the previous steps.
The final step is then calculated by the current state of the final state
and all other previous steps.
Now an error is generated by calculating the difference between the
actual output and the output generated by our RNN model.
The final step is when the process of backpropagation occurs
wherein the error is backpropagated to update the weights.
Types of RNNs:
Different types of architectures are used in recurrent neural networks:
1. One to one
2. One to Many
3. Many to One
4. Many to Many
One to one:
One to One RNN is the most basic and traditional type of Neural
network giving a single output for a single input. It is also known as
Vanilla Neural Network. It is used to solve regular machine learning
problems. e.g. image classification takes an image and outputs a single
classification word.
One to many:
Many to One :
In recurrent neural networks (RNNs), a “many-to-one” architecture refers
to a specific type of RNN where the network processes a sequence of
inputs but produces a single output.
Many Inputs: The RNN takes in a sequence of data points over time.
This sequence could be words in a sentence, sensor readings over a
period, or financial data points for multiple days.
Single Output: After processing the entire sequence, the RNN generates
a single output value. This output could be a classification
(positive/negative sentiment), a prediction (next value in the time
series), or a summary of the information in the sequence.
Many to Many:
In recurrent neural networks (RNNs), a “many-to-many” architecture
describes a scenario where the network processes a sequence of
inputs and generates a corresponding sequence of outputs. This means
both the input and output have multiple elements processed over time
steps.
Advantages of RNN:
Disadvantages of RNN :
Google Gmail.
When you type a sentence, it will automatically complete it. Google has this
RNN embedded in it.
Autogenerate result.
2. Google Translate
Google Translate.
Translate sentence from one to another language
NER.
Given a statement, it will analyse the text to detect and classify entities.
4. Sentiment Analysis
Sentiment Analysis.
Advantages of RNN:
Ability To Handle Variable-Length Sequences: RNNs are designed to
handle input sequences of variable length, which makes them well-suited
for tasks such as speech recognition, natural language processing, and time
series analysis.
Memory of Past Inputs: RNNs have a memory of past inputs, which allows
them to capture information about the context of the input sequence. This
makes them useful for tasks such as language modeling, where the meaning
of a word depends on the context in which it appears.
Parameter Sharing: RNNs share the same set of parameters across all
time steps, which reduces the number of parameters that need to be
learned and can lead to better generalization.
Flexibility: RNNs can be adapted to a wide range of tasks and input types,
including text, speech, and image sequences.