Deep Learning for Natural Language Processing 1st Edition Palash Goyal pdf download
Deep Learning for Natural Language Processing 1st Edition Palash Goyal pdf download
https://ebookmeta.com/product/deep-learning-for-natural-language-
processing-1st-edition-palash-goyal/
https://ebookmeta.com/product/deep-learning-for-natural-language-
processing-develop-deep-learning-models-for-your-natural-
language-problems-jason-brownlee/
https://ebookmeta.com/product/getting-started-with-deep-learning-
for-natural-language-processing-learn-how-to-build-nlp-
applications-with-deep-learning-1st-edition-sunil-patel/
https://ebookmeta.com/product/transfer-learning-for-natural-
language-processing-1st-edition-paul-azunre/
https://ebookmeta.com/product/how-to-write-and-publish-a-
scientific-paper-9th-edition-barbara-gastel-and-robert-a-day/
British and Irish Moths Third Edition A Photographic
Guide Chris Manley
https://ebookmeta.com/product/british-and-irish-moths-third-
edition-a-photographic-guide-chris-manley-2/
https://ebookmeta.com/product/sergei-rachmaninoff-a-lifetime-in-
music-1st-edition-sergei-bertensson-jay-leyda/
https://ebookmeta.com/product/understanding-norman-mailer-1st-
edition-maggie-mckinley/
https://ebookmeta.com/product/detransition-1st-edition-max-
robinson/
https://ebookmeta.com/product/teach-your-kids-math-column-
addition-1st-edition-sunil-tanna/
The Angel Roofs of East Anglia Unseen Masterpieces of
the Middle Ages 1st Edition Michael Rimmer
https://ebookmeta.com/product/the-angel-roofs-of-east-anglia-
unseen-masterpieces-of-the-middle-ages-1st-edition-michael-
rimmer/
Deep Learning for
Natural Language
Processing
Creating Neural Networks with Python
—
Palash Goyal
Sumit Pandey
Karan Jain
www.allitebooks.com
Deep Learning for
Natural Language
Processing
Creating Neural Networks
with Python
Palash Goyal
Sumit Pandey
Karan Jain
www.allitebooks.com
Deep Learning for Natural Language Processing: Creating Neural Networks
with Python
Palash Goyal Sumit Pandey
Bangalore, Karnataka, India Bangalore, Karnataka, India
Karan Jain
Bangalore, Karnataka, India
www.allitebooks.com
To our parents, sisters, brothers, and friends
without whom this book would have been
completed one year earlier :)
www.allitebooks.com
Table of Contents
About the Authors��������������������������������������������������������������������������������xi
About the Technical Reviewer�����������������������������������������������������������xiii
Acknowledgments������������������������������������������������������������������������������xv
Introduction��������������������������������������������������������������������������������������xvii
www.allitebooks.com
Table of Contents
Pattern�����������������������������������������������������������������������������������������������������������29
Stanford CoreNLP������������������������������������������������������������������������������������������29
Getting Started with NLP�������������������������������������������������������������������������������������29
Text Search Using Regular Expressions��������������������������������������������������������30
Text to List�����������������������������������������������������������������������������������������������������30
Preprocessing the Text����������������������������������������������������������������������������������31
Accessing Text from the Web������������������������������������������������������������������������32
Removal of Stopwords�����������������������������������������������������������������������������������32
Counter Vectorization������������������������������������������������������������������������������������33
TF-IDF Score��������������������������������������������������������������������������������������������������33
Text Classifier������������������������������������������������������������������������������������������������35
Introduction to Deep Learning����������������������������������������������������������������������������35
How Deep Is “Deep”?������������������������������������������������������������������������������������37
What Are Neural Networks?��������������������������������������������������������������������������������38
Basic Structure of Neural Networks��������������������������������������������������������������������40
Types of Neural Networks�����������������������������������������������������������������������������������45
Feedforward Neural Networks����������������������������������������������������������������������46
Convolutional Neural Networks���������������������������������������������������������������������46
Recurrent Neural Networks���������������������������������������������������������������������������47
Encoder-Decoder Networks���������������������������������������������������������������������������49
Recursive Neural Networks���������������������������������������������������������������������������49
Multilayer Perceptrons����������������������������������������������������������������������������������������50
Stochastic Gradient Descent�������������������������������������������������������������������������������54
Backpropagation�������������������������������������������������������������������������������������������������57
Deep Learning Libraries��������������������������������������������������������������������������������������60
Theano�����������������������������������������������������������������������������������������������������������60
Theano Installation����������������������������������������������������������������������������������������61
vi
Table of Contents
Theano Examples������������������������������������������������������������������������������������������63
TensorFlow����������������������������������������������������������������������������������������������������64
Data Flow Graphs������������������������������������������������������������������������������������������65
TensorFlow Installation����������������������������������������������������������������������������������66
TensorFlow Examples������������������������������������������������������������������������������������67
Keras�������������������������������������������������������������������������������������������������������������69
Next Steps�����������������������������������������������������������������������������������������������������������74
vii
Table of Contents
viii
Table of Contents
Index�������������������������������������������������������������������������������������������������269
ix
About the Authors
Palash Goyal is a senior data scientist and
currently works with the applications of
data science and deep learning in the online
marketing domain. He studied Mathematics
and Computing at the Indian Institute of
Technology (IIT) Guwahati and proceeded to
work in a fast-paced upscale environment.
He has wide experience in E-commerce
and travel, insurance, and banking industries.
Passionate about mathematics and finance,
Palash manages his portfolio of multiple
cryptocurrencies and the latest Initial Coin
Offerings (ICOs) in his spare time, using deep learning and reinforcement
learning techniques for price prediction and portfolio management. He
keeps in touch with the latest trends in the data science field and shares
these on his personal blog, http://madoverdata.com, and mines articles
related to smart farming in free time.
xi
About the Authors
xii
About the Technical Reviewer
Santanu Pattanayak currently works at GE
Digital as a staff data scientist and is the author
of the deep learning–related book Pro Deep
Learning with TensorFlow—A Mathematical
Approach to Advanced Artificial Intelligence
in Python. He has about 12 years of overall
work experience, 8 in the data analytics/
data science field, and has a background in
development and database technologies.
Prior to joining GE, Santanu worked in
such companies as RBS, Capgemini, and IBM. He graduated with a degree
in electrical engineering from Jadavpur University, Kolkata, and is an avid
math enthusiast. Santanu is currently pursuing a master’s degree in data
science from IIT Hyderabad. He also devotes his time to data science
hackathons and Kaggle competitions, in which he ranks within the top 500
across the globe. Santanu was born and brought up in West Bengal, India,
and currently resides in Bangalore, India, with his wife.
xiii
Acknowledgments
This work would not have been possible without those who saw us through
this book, to all those who believed in us, talked things over, read, wrote,
and offered their valuable time throughout the process, and allowed us to
use the knowledge that we gained together, be it for proofreading or overall
design.
We are especially indebted to Aditee Mirashi, coordinating editor,
Apress, Springer Science+Business, who has been a constant support and
motivator to complete the task and who worked actively to provide us with
valuable suggestions to pursue our goals on time.
We are grateful to Santanu Pattanayak, who went through all the
chapters and provided valuable input, giving final shape to the book.
Nobody has been more important to us in the pursuit of this project
than our family members. We would like to thank our parents, whose love
and guidance are with us in whatever we pursue. Their being our ultimate
role models has provided us unending inspiration to start and finish the
difficult task of writing and giving shape to our knowledge.
xv
Introduction
This book attempts to simplify and present the concepts of deep learning
in a very comprehensive manner, with suitable, full-fledged examples of
neural network architectures, such as Recurrent Neural Networks (RNNs)
and Sequence to Sequence (seq2seq), for Natural Language Processing
(NLP) tasks. The book tries to bridge the gap between the theoretical and
the applicable.
It proceeds from the theoretical to the practical in a progressive
manner, first by presenting the fundamentals, followed by the underlying
mathematics, and, finally, the implementation of relevant examples.
The first three chapters cover the basics of NLP, starting with the most
frequently used Python libraries, word vector representation, and then
advanced algorithms like neural networks for textual data.
The last two chapters focus entirely on implementation, dealing with
sophisticated architectures like RNN, Long Short-Term Memory (LSTM)
Networks, Seq2seq, etc., using the widely used Python tools TensorFlow
and Keras. We have tried our best to follow a progressive approach,
combining all the knowledge gathered to move on to building a question-
and-answer system.
The book offers a good starting point for people who want to get
started in deep learning, with a focus on NLP.
All the code presented in the book is available on GitHub, in the form
of IPython notebooks and scripts, which allows readers to try out these
examples and extend them in interesting, personal ways.
xvii
CHAPTER 1
Introduction
to Natural Language
Processing and Deep
Learning
Natural language processing (NPL) is an extremely difficult task in
computer science. Languages present a wide variety of problems that
vary from language to language. Structuring or extracting meaningful
information from free text represents a great solution, if done in the
right manner. Previously, computer scientists broke a language into its
grammatical forms, such as parts of speech, phrases, etc., using complex
algorithms. Today, deep learning is a key to performing the same exercises.
This first chapter of Deep Learning for Natural Language Processing
offers readers the basics of the Python language, NLP, and Deep Learning.
First, we cover the beginner-level codes in the Pandas, NumPy, and SciPy
libraries. We assume that the user has the initial Python environment
(2.x or 3.x) already set up, with these libraries installed. We will also briefly
discuss commonly used libraries in NLP, with some basic examples.
Language: French
LA
FABRIQUE DE MARIAGES.
COLLECTION HETZEL.
LA
FABRIQUE DE MARIAGES
PAR
PAUL FÉVAL.
V
Édition autorisée pour la Belgique et l’Étranger,
interdite pour la France.
LEIPZIG,
ALPH. DURR, LIBRAIRE-ÉDITEUR.
—
1858
BRUXELLES.—TYP. DE J. VANBUGGENHOUDT,
Rue de Schaerbeek, 12.
DEUXIÈME PARTIE.
——
L’HOTEL DE MERSANZ
(SUITE).
XX
— La huitième contredanse. —