Deep Learning with R for Beginners

Book description

Explore the world of neural networks by building powerful deep learning models using the R ecosystem

Key Features

  • Get to grips with the fundamentals of deep learning and neural networks
  • Use R 3.5 and its libraries and APIs to build deep learning models for computer vision and text processing
  • Implement effective deep learning systems in R with the help of end-to-end projects

Book Description

Deep learning has a range of practical applications in several domains, while R is the preferred language for designing and deploying deep learning models.

This Learning Path introduces you to the basics of deep learning and even teaches you to build a neural network model from scratch. As you make your way through the chapters, you’ll explore deep learning libraries and understand how to create deep learning models for a variety of challenges, right from anomaly detection to recommendation systems. The Learning Path will then help you cover advanced topics, such as generative adversarial networks (GANs), transfer learning, and large-scale deep learning in the cloud, in addition to model optimization, overfitting, and data augmentation. Through real-world projects, you’ll also get up to speed with training convolutional neural networks (CNNs), recurrent neural networks (RNNs), and long short-term memory networks (LSTMs) in R.

By the end of this Learning Path, you’ll be well-versed with deep learning and have the skills you need to implement a number of deep learning concepts in your research work or projects.

What you will learn

  • Implement credit card fraud detection with autoencoders
  • Train neural networks to perform handwritten digit recognition using MXNet
  • Reconstruct images using variational autoencoders
  • Explore the applications of autoencoder neural networks in clustering and dimensionality reduction
  • Create natural language processing (NLP) models using Keras and TensorFlow in R
  • Prevent models from overfitting the data to improve generalizability
  • Build shallow neural network prediction models

Who this book is for

This Learning Path is for aspiring data scientists, data analysts, machine learning developers, and deep learning enthusiasts who are well versed in machine learning concepts and are looking to explore the deep learning paradigm using R. A fundamental understanding of R programming and familiarity with the basic concepts of deep learning are necessary to get the most out of this Learning Path.

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Deep Learning with R for Beginners
  3. About Packt
    1. Why subscribe?
    2. Packt.com
  4. Contributors
    1. About the authors
    2. Packt is searching for authors like you
  5. Preface
    1. Who this book is for
    2. What this book covers
    3. To get the most out of this book
      1. Download the example code files
      2. Download the color images of this book
      3. Conventions used
    4. Get in touch
      1. Reviews
  6. Getting Started with Deep Learning
    1. What is deep learning?
    2. A conceptual overview of neural networks
      1. Neural networks as an extension of linear regression
      2. Neural networks as a network of memory cells
    3. Deep neural networks
    4. Some common myths about deep learning
    5. Setting up your R environment
      1. Deep learning frameworks for R
        1. MXNet
        2. Keras
      2. Do I need a GPU (and what is it, anyway)?
      3. Setting up reproducible results
    6. Summary
  7. Training a Prediction Model
    1. Neural networks in R
      1. Building neural network models
      2. Generating predictions from a neural network
    2. The problem of overfitting data – the consequences explained
    3. Use case – building and applying a neural network
    4. Summary
  8. Deep Learning Fundamentals
    1. Building neural networks from scratch in R
      1. Neural network web application
      2. Neural network code
      3. Back to deep learning
        1. The symbol, X, y, and ctx parameters
        2. The num.round and begin.round parameters
        3. The optimizer parameter
        4. The initializer parameter
        5. The eval.metric and eval.data parameters
        6. The epoch.end.callback parameter
        7. The array.batch.size parameter
    2. Using regularization to overcome overfitting
      1. L1 penalty
        1. L1 penalty in action
      2. L2 penalty
        1. L2 penalty in action
        2. Weight decay (L2 penalty in neural networks)
      3. Ensembles and model-averaging
    3. Use case – improving out-of-sample model performance using dropout
    4. Summary
  9. Training Deep Prediction Models
    1. Getting started with deep feedforward neural networks
    2. Activation functions
    3. Introduction to the MXNet deep learning library
      1. Deep learning layers
      2. Building a deep learning model
    4. Use case – using MXNet for classification and regression
      1. Data download and exploration
      2. Preparing the data for our models
      3. The binary classification model
      4. The regression model
      5. Improving the binary classification model
      6. The unreasonable effectiveness of data
    5. Summary
  10. Image Classification Using Convolutional Neural Networks
    1. CNNs
    2. Convolutional layers
      1. Pooling layers
      2. Dropout
      3. Flatten layers, dense layers, and softmax
    3. Image classification using the MXNet library
      1. Base model (no convolutional layers)
      2. LeNet
      3. Classification using the fashion MNIST dataset
    4. References/further reading
    5. Summary
  11. Tuning and Optimizing Models
    1. Evaluation metrics and evaluating performance
      1. Types of evaluation metric
      2. Evaluating performance
    2. Data preparation
      1. Different data distributions
      2. Data partition between training, test, and validation sets
      3. Standardization
      4. Data leakage
    3. Data augmentation
      1. Using data augmentation to increase the training data
        1. Test time augmentation
      2. Using data augmentation in deep learning libraries
    4. Tuning hyperparameters
      1. Grid search
      2. Random search
    5. Use case—using LIME for interpretability
      1. Model interpretability with LIME
    6. Summary
  12. Natural Language Processing Using Deep Learning
    1. Document classification
      1. The Reuters dataset
      2. Traditional text classification
      3. Deep learning text classification
      4. Word vectors
      5. Comparing traditional text classification and deep learning
    2. Advanced deep learning text classification
      1. 1D convolutional neural network model
      2. Recurrent neural network model
      3. Long short term memory model
      4. Gated Recurrent Units model
      5. Bidirectional LSTM model
      6. Stacked bidirectional model
      7. Bidirectional with 1D convolutional neural network model
      8. Comparing the deep learning NLP architectures
    3. Summary
  13. Deep Learning Models Using TensorFlow in R
    1. Introduction to the TensorFlow library
      1. Using TensorBoard to visualize deep learning networks
    2. TensorFlow models
      1. Linear regression using TensorFlow
      2. Convolutional neural networks using TensorFlow
    3. TensorFlow estimators and TensorFlow runs packages
      1. TensorFlow estimators
      2. TensorFlow runs package
    4. Summary
  14. Anomaly Detection and Recommendation Systems
    1. What is unsupervised learning?
    2. How do auto-encoders work?
      1. Regularized auto-encoders
        1. Penalized auto-encoders
        2. Denoising auto-encoders
    3. Training an auto-encoder in R
      1. Accessing the features of the auto-encoder model
    4. Using auto-encoders for anomaly detection
    5. Use case – collaborative filtering
      1. Preparing the data
      2. Building a collaborative filtering model
      3. Building a deep learning collaborative filtering model
      4. Applying the deep learning model to a business problem
    6. Summary
  15. Running Deep Learning Models in the Cloud
    1. Setting up a local computer for deep learning
      1. How do I know if my model is training on a GPU?
    2. Using AWS for deep learning
      1. A brief introduction to AWS
      2. Creating a deep learning GPU instance in AWS
      3. Creating a deep learning AMI in AWS
    3. Using Azure for deep learning
    4. Using Google Cloud for deep learning
    5. Using Paperspace for deep learning
    6. Summary
  16. The Next Level in Deep Learning
    1. Image classification models
      1. Building a complete image classification solution
        1. Creating the image data
        2. Building the deep learning model
        3. Using the saved deep learning model
      2. The ImageNet dataset
      3. Loading an existing model
      4. Transfer learning
    2. Deploying TensorFlow models
    3. Other deep learning topics
      1. Generative adversarial networks
      2. Reinforcement learning
    4. Summary
  17. Handwritten Digit Recognition using Convolutional Neural Networks
    1. What is deep learning and why do we need it?
      1. What makes deep learning special?
      2. What are the applications of deep learning?
    2. Handwritten digit recognition using CNNs
      1. Get started with exploring MNIST
      2. First attempt – logistic regression
      3. Going from logistic regression to single-layer neural networks
      4. Adding more hidden layers to the networks
      5. Extracting richer representation with CNNs
    3. Summary
  18. Traffic Signs Recognition for Intelligent Vehicles
    1. How is deep learning applied in self-driving cars?
      1. How does deep learning become a state-of-the-art solution?
    2. Traffic sign recognition using CNN
      1. Getting started with exploring GTSRB
      2. First solution – convolutional neural networks using MXNet
      3. Trying something new – CNNs using Keras with TensorFlow
      4. Reducing overfitting with dropout
    3. Dealing with a small training set – data augmentation
    4. Reviewing methods to prevent overfitting in CNNs
    5. Summary
  19. Fraud Detection with Autoencoders
    1. Getting ready
      1. Installing Keras and TensorFlow for R
      2. Installing H2O
    2. Our first examples
      1. A simple 2D example
      2. Autoencoders and MNIST
      3. Outlier detection in MNIST
    3. Credit card fraud detection with autoencoders
      1. Exploratory data analysis
      2. The autoencoder approach – Keras
      3. Fraud detection with H2O
      4. Exercises
    4. Variational Autoencoders
      1. Image reconstruction using VAEs
      2. Outlier detection in MNIST
    5. Text fraud detection
      1. From unstructured text data to a matrix
      2. From text to matrix representation — the Enron dataset
      3. Autoencoder on the matrix representation
      4. Exercises
    6. Summary
  20. Text Generation using Recurrent Neural Networks
    1. What is so exciting about recurrent neural networks?
      1. But what is a recurrent neural network, really?
      2. LSTM and GRU networks
        1. LSTM
        2. GRU
    2. RNNs from scratch in R
      1. Classes in R with R6
        1. Perceptron as an R6 class
        2. Logistic regression
        3. Multi-layer perceptron
      2. Implementing a RNN
        1. Implementation as an R6 class
        2. Implementation without R6
        3. RNN without derivatives — the cross-entropy method
    3. RNN using Keras
      1. A simple benchmark implementation
      2. Generating new text from old
      3. Exercises
    4. Summary
  21. Sentiment Analysis with Word Embedding
    1. Warm-up – data exploration
      1. Working with tidy text
      2. The more, the merrier – calculating n-grams instead of single words
    2. Bag of words benchmark
      1. Preparing the data
      2. Implementing a benchmark – logistic regression 
      3. Exercises
    3. Word embeddings
      1. word2vec
      2. GloVe
    4. Sentiment analysis from movie reviews
      1. Data preprocessing
      2. From words to vectors
      3. Sentiment extraction
      4. The importance of data cleansing
      5. Vector embeddings and neural networks
      6. Bi-directional LSTM networks
      7. Other LSTM architectures
      8. Exercises
    5. Mining sentiment from Twitter
      1. Connecting to the Twitter API
      2. Building our model
        1. Exploratory data analysis
        2. Using a trained model
    6. Summary
  22. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Deep Learning with R for Beginners
  • Author(s): Mark Hodnett, Joshua F. Wiley, Yuxi Liu, Pablo Maldonado
  • Release date: May 2019
  • Publisher(s): Packt Publishing
  • ISBN: 9781838642709