Book Image

Hands-On Deep Learning with Apache Spark

By : Guglielmo Iozzia
Book Image

Hands-On Deep Learning with Apache Spark

By: Guglielmo Iozzia

Overview of this book

Deep learning is a subset of machine learning where datasets with several layers of complexity can be processed. Hands-On Deep Learning with Apache Spark addresses the sheer complexity of technical and analytical parts and the speed at which deep learning solutions can be implemented on Apache Spark. The book starts with the fundamentals of Apache Spark and deep learning. You will set up Spark for deep learning, learn principles of distributed modeling, and understand different types of neural nets. You will then implement deep learning models, such as convolutional neural networks (CNNs), recurrent neural networks (RNNs), and long short-term memory (LSTM) on Spark. As you progress through the book, you will gain hands-on experience of what it takes to understand the complex datasets you are dealing with. During the course of this book, you will use popular deep learning frameworks, such as TensorFlow, Deeplearning4j, and Keras to train your distributed models. By the end of this book, you'll have gained experience with the implementation of your models on a variety of use cases.
Table of Contents (19 chapters)
Appendix A: Functional Programming in Scala
Appendix B: Image Data Preparation for Spark

Hand-on NLP with Keras and a TensorFlow backend

As mentioned in Chapter 10, Deploying on a Distributed System, in the Importing Python Models in the JVM with DL4J section, when doing DL in Python, an alternative to TensorFlow is Keras. It can be used as a high-level API on top of a TensorFlow backed. In this section, we are going to learn how to do sentiment analysis in Keras, and finally we will make a comparison between this implementation and the previous one in TensorFlow.

We are going to use the exact same IMDB dataset (25,000 samples for training and 25,000 for test) as for the previous implementations through DL4J and TensorFlow. The prerequisites for this example are the same as for the TensorFlow example (Python 2.7.x, the PIP package manager, and Tensorflow), plus of course Keras. The Keras code module has that dataset built in:

from keras.datasets import imdb

So, we...