Book Image

Advanced Deep Learning with R

By : Bharatendra Rai
Book Image

Advanced Deep Learning with R

By: Bharatendra Rai

Overview of this book

Deep learning is a branch of machine learning based on a set of algorithms that attempt to model high-level abstractions in data. Advanced Deep Learning with R will help you understand popular deep learning architectures and their variants in R, along with providing real-life examples for them. This deep learning book starts by covering the essential deep learning techniques and concepts for prediction and classification. You will learn about neural networks, deep learning architectures, and the fundamentals for implementing deep learning with R. The book will also take you through using important deep learning libraries such as Keras-R and TensorFlow-R to implement deep learning algorithms within applications. You will get up to speed with artificial neural networks, recurrent neural networks, convolutional neural networks, long short-term memory networks, and more using advanced examples. Later, you'll discover how to apply generative adversarial networks (GANs) to generate new images; autoencoder neural networks for image dimension reduction, image de-noising and image correction and transfer learning to prepare, define, train, and model a deep neural network. By the end of this book, you will be ready to implement your knowledge and newly acquired skills for applying deep learning algorithms in R through real-world examples.
Table of Contents (20 chapters)
Free Chapter
1
Section 1: Revisiting Deep Learning Basics
3
Section 2: Deep Learning for Prediction and Classification
6
Section 3: Deep Learning for Computer Vision
12
Section 4: Deep Learning for Natural Language Processing
17
Section 5: The Road Ahead

Preparing text data for model building

We will continue to use IMDB movie review data that we used in the previous chapter on recurrent neural networks. This data is already available in a format where we can use it for developing deep network models with minimum need for data processing.

Let's take a look at the following code:

# IMDB data
library(keras)
imdb <- dataset_imdb(num_words = 500)
c(c(train_x, train_y), c(test_x, test_y)) %<-% imdb
train_x <- pad_sequences(train_x, maxlen = 200)
test_x <- pad_sequences(test_x, maxlen = 200)

The sequence of integers capturing train and test data is stored in train_x and test_x respectively. Similarly, train_y and test_y store labels capturing information about whether movie reviews are positive or negative. We have specified the number of most frequent words to be 500. For padding, we are using 200 as the maximum length...