Professional Documents
Culture Documents
RNN:
This type of neural networks saves the output of a particular layer and this is
fed back to the input in order to predict the output of the layer.
Feed forward neural network can be converted to Recurrent Neural Network.
RNN:
The nodes in the different layers of neural networks are compressed to form a
A,B and C are the input parameters which are used to improve the output of
the model.
At any given time instance ‘t’ , the current input is the combination of input at
output.
Fully Connected RNN:
Reasons To Use RNN:
RNNs were created in order to overcome the issues in feed forward neural networks.
It can handle sequential data , accept the current input data and previously received inputs.
The middle layer contains its own activation function , weights and biases.
In case of a normal neural network , the different parameters of the hidden layer are not
Network(RNN).
RNN - Working
RNNs will standardize the different activation functions , weights and biases
Instead of creating multiple hidden layers , it will create one and loop over it
direction.
It goes from the input nodes , through the hidden layers and to the output
nodes.
There are no cycles or loops in the network.
FNNs - RNNs
In a feed – forward neural network , the decisions are based on the current
input.
It doesn’t memorize the past data and there is no future scope.
activities present.
This type of neural networks can be applied to any time – series prediction.
Text mining and sentiment analysis can be carried out using RNN for Natural
language processing(NLP).
Machine Translation:
If the input is given in one language , RNNs can be used to translate the into
One to Many
Many to One
Many to Many
Types Of RNNs
One To One RNN:
This type of neural network models is used to solve any ML problems which
This type of neural network has a single input and multiple outputs.
Types Of RNNs
Many To One RNN:
They are used in solving problems like stock market prediction , machine translation and text
generation.
They are harder to train because of the gradient problem.
When the gradient becomes too small , the parameter updates become insignificant.
When we train a neural network , if the slope grows exponentially instead of decaying ,
They result in very large updates to the neural network model weights during the
training process.
It requires a long training time , performance and accuracy is not good when dealing
(i.e),LSTMs.
Suppose , we want to predict the last word in the text: “ The clouds are in the
_________”.
We don’t require any further context to predict the last word in the sentence.
Gradient Problem Solutions
Consider this:”I have been staying in France for last 10 years.I can speak fluent _________”.
The word we predict will depend on the previous words in the context.
Here , we need the context of France in order to predict the last word and the most suitable
answer is “French”.
The gap between the relevant information and the point where it’s needed may have become
very large.
LSTMs are used to solve this problem.
BackPropagation Through Time
This algorithm can be applied to RNN that has time series data as the input.
In a RNN , one input is fed into the network at a time and one output is obtained.
In Backpropagation , we use the current as well as the previous inputs as the input.
It is called as a timestep and one timestep will consist of many time series data points entering the
RNN simultaneously.
Once the neural network has been trained on a timeset and given an output , the output is used to
errors in mind.
LSTM:
It is a kind of recurrent neural network .
In RNN , the output from the previous step is fed as input to the current step.
It cannot predict the word stored in the long term memory but can give more
LSTM can retain the information for a very long period of time.
It is used for processing , predicting and classifying on the basis of time series
data.
Structure Of LSTM:
It has a chain structure that contains four neural networks and different memory blocks called cells.
Structure Of LSTM:
Information is retained by the cells and memory manipulations are done by the gates.
Forget Gate: The information that are no longer useful in the cell state is removed with the forget gate.
Forget Gate:
Two inputs x_t(input at particular time instant) and h_t-1(previous cell output) are fed to the gate and
For a particular cell state , if the output is 0, then that piece of information is lost and if the output is 1,
Then , filter the values to be remembered using filter gates using inputs h_t-1 and x_t.
Then , a vector is created using tanh function that gives the output from -1 to +1.
Finally , the values of the vector and regulated values are multiplied to obtain the useful information.
Output Gate:
Useful information can be extracted from the current cell state and presented at the output with the help
of output gate.
Output Gate:
First , a vector is generated by applying tanh function on the cell.
Then , the information is regulated using the Sigmoid function and filter the values to be remembered
Machine Translation.
Image Captioning.
Handwriting Generation.
We are going to write a simple long short term memory(LSTM) based RNN in
instance of time.
Consider an example of reading a sentence.
When we understand the word in the correct order , we can understand the
Sequence analysis is used in NLP to find the sentiment analysis of the given
text.
Time series prediction
Let us create a LSTM model to analyze the IMDB movie reviews and find its
positive/negative sentiment.
Model description:
First layer, Dense consists of 128 units with normal dropout and recurrent
Use adam as Optimizer.
Use accuracy as metrics.
Use 15 as epochs.
its reviews.
num_words represent the maximum number of words in the review.
Step 3 – Process The Data
Let us change the dataset according to our model, so that it can be fed into our
We have used Embedding layer as input layer and then added the LSTM
Let us compile the model using selected loss function, optimizer and metrics.