What is the difference between a RNN and LSTM Explain with an example?
MACHINE LEARNING RECIPES DATA CLEANING PYTHON DATA MUNGING PANDAS CHEATSHEET     ALL TAGS

What is the difference between a RNN and LSTM Explain with an example?

What is the difference between a RNN and LSTM Explain with an example?

This recipe explains what is the difference between a RNN and LSTM Explain with an example

0

Recipe Objective

Difference between a RNN and LSTM? Explain with an example

RNN stands for *Recurrent Neural Networks* these are the first kind of neural network algorithm that can memorize or remember the previous inputs in memory.

It difficult to train RNN that requires long-term memorization meanwhile LSTM performs better in these kinds of datasets it has more additional special units that can hold information longer. LSTM includes a 'memory cell' that can maintain information in memory for long periods of time.

Step 1- Importing Libraries

import keras from keras.models import Sequential from keras.layers import RNN, LSTM import numpy as np

Step 2- Creating the model.

We will create the sequential model with defining all the parameters

# define model where GRU is also output layer model_1 = Sequential() model_1.add(LSTM(1, input_shape=(20,1))) model_1.compile(optimizer='adam', loss='mse')

Step 3- Defining the sample array.

We will define the sample array to run through the model.

# input time steps y = np.array([[1, 2, 3, 4, 5, 6, 7, 8, 9, 10], [9, 8, 7, 6, 5, 4, 3, 2, 1, 0], [11, 12, 13, 14, 15, 16, 17, 18, 19, 20], [21, 22, 23, 24, 25, 26, 27, 28, 29, 30], [31, 32, 33, 34, 35, 36, 37, 38, 39, 40]]).reshape((5,10,1)) # make and show prediction print(model_1.predict(y))
[[0.7465496 ]
 [0.38062745]
 [0.7608172 ]
 [0.76155245]
 [0.761592  ]]

Relevant Projects

PySpark Tutorial - Learn to use Apache Spark with Python
PySpark Project-Get a handle on using Python with Spark through this hands-on data processing spark python tutorial.

Human Activity Recognition Using Multiclass Classification in Python
In this human activity recognition project, we use multiclass classification machine learning techniques to analyse fitness dataset from a smartphone tracker.

Natural language processing Chatbot application using NLTK for text classification
In this NLP AI application, we build the core conversational engine for a chatbot. We use the popular NLTK text classification library to achieve this.

Walmart Sales Forecasting Data Science Project
Data Science Project in R-Predict the sales for each department using historical markdown data from the Walmart dataset containing data of 45 Walmart stores.

German Credit Dataset Analysis to Classify Loan Applications
In this data science project, you will work with German credit dataset using classification techniques like Decision Tree, Neural Networks etc to classify loan applications using R.

Identifying Product Bundles from Sales Data Using R Language
In this data science project in R, we are going to talk about subjective segmentation which is a clustering technique to find out product bundles in sales data.

Choosing the right Time Series Forecasting Methods
There are different time series forecasting methods to forecast stock price, demand etc. In this machine learning project, you will learn to determine which forecasting method to be used when and how to apply with time series forecasting example.

Data Science Project-TalkingData AdTracking Fraud Detection
Machine Learning Project in R-Detect fraudulent click traffic for mobile app ads using R data science programming language.

Deep Learning with Keras in R to Predict Customer Churn
In this deep learning project, we will predict customer churn using Artificial Neural Networks and learn how to model an ANN in R with the keras deep learning package.

Topic modelling using Kmeans clustering to group customer reviews
In this Kmeans clustering machine learning project, you will perform topic modelling in order to group customer reviews based on recurring patterns.