O'Reilly logo

Apache Spark Deep Learning Cookbook by Amrith Ravindra, Ahmed Sherif

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

How to do it...

Before beginning, it always helps to take a look at the data and analyze it. After looking at the data, we can see that there are a lot of punctuation marks, blank spaces, quotes, and uppercase as well as lowercase letters. We need to prepare the data first before performing any kind of analysis on it or feeding it into the LSTM network. We require a number of libraries that will make handling data easier :

  1. Import the necessary libraries by issuing the following commands:
from keras.preprocessing.text import Tokenizerfrom keras.utils import to_categoricalfrom keras.models import Sequentialfrom keras.layers import Dense, lSTM, Dropout, Embeddingimport numpy as npfrom pickle import dumpimport string
  1. The output to the preceding ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required