Advanced Deep Learning with R

Book description

Discover best practices for choosing, building, training, and improving deep learning models using Keras-R, and TensorFlow-R libraries

Key Features

  • Implement deep learning algorithms to build AI models with the help of tips and tricks
  • Understand how deep learning models operate using expert techniques
  • Apply reinforcement learning, computer vision, GANs, and NLP using a range of datasets

Book Description

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.

What you will learn

  • Learn how to create binary and multi-class deep neural network models
  • Implement GANs for generating new images
  • Create autoencoder neural networks for image dimension reduction, image de-noising and image correction
  • Implement deep neural networks for performing efficient text classification
  • Learn to define a recurrent convolutional network model for classification in Keras
  • Explore best practices and tips for performance optimization of various deep learning models

Who this book is for

This book is for data scientists, machine learning practitioners, deep learning researchers and AI enthusiasts who want to develop their skills and knowledge to implement deep learning techniques and algorithms using the power of R. A solid understanding of machine learning and working knowledge of the R programming language are required.

Table of contents

  1. Title Page
  2. Copyright and Credits
    1. Advanced Deep Learning with R
  3. About Packt
    1. Why subscribe?
  4. Contributors
    1. About the author
    2. About the reviewer
    3. 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
      3. Conventions used
    4. Get in touch
      1. Reviews
  6. Section 1: Revisiting Deep Learning Basics
  7. Revisiting Deep Learning Architecture and Techniques
    1. Deep learning with R
      1. Deep learning trend
      2. Versions of key R packages used
    2. Process of developing a deep network model
      1. Preparing the data for a deep network model
      2. Developing a deep learning model architecture
      3. Compiling the model
      4. Fitting the model
      5. Assessing the model performance
    3. Deep learning techniques with R and RStudio
      1. Multi-class classification
      2. Regression problems
      3. Image classification
      4. Convolutional neural networks
      5. Autoencoders
      6. Transfer learning
      7. Generative adversarial networks
      8. Deep network for text classification
      9. Recurrent neural networks
      10. Long short-term memory network
      11. Convolutional recurrent networks
      12. Tips, tricks, and best practices
    4. Summary
  8. Section 2: Deep Learning for Prediction and Classification
  9. Deep Neural Networks for Multi-Class Classification
    1. Cardiotocogram dataset
      1. Dataset (medical)
    2. Preparing the data for model building
      1. Normalizing numeric variables
      2. Partitioning the data
      3. One-hot encoding
    3. Creating and fitting a deep neural network model
      1. Developing model architecture
      2. Compiling the model
      3. Fitting the model
    4. Model evaluation and predictions
      1. Loss and accuracy calculation
      2. Confusion matrix
    5. Performance optimization tips and best practices
      1. Experimenting with an additional hidden layer
      2. Experimenting with a higher number of units in the hidden layer
      3. Experimenting using a deeper network with more units in the hidden layer
      4. Experimenting by addressing the class imbalance problem
      5. Saving and reloading a model
    6. Summary
  10. Deep Neural Networks for Regression
    1. Understanding the Boston Housing dataset
    2. Preparing the data
      1. Visualizing the neural network
      2. Data partitioning
      3. Normalization
    3. Creating and fitting a deep neural network model for regression
      1. Calculating the total number of parameters
      2. Compiling the model
      3. Fitting the model
    4. Model evaluation and prediction
      1. Evaluation
      2. Prediction
      3. Improvements
        1. Deeper network architecture
        2. Results
    5. Performance optimization tips and best practices
      1. Log transformation on the output variable
      2. Model performance
    6. Summary
  11. Section 3: Deep Learning for Computer Vision
  12. Image Classification and Recognition
    1. Handling image data
    2. Data preparation
      1. Resizing and reshaping
      2. Training, validation, and test data
      3. One-hot encoding
    3. Creating and fitting the model
      1. Developing the model architecture
      2. Compiling the model
      3. Fitting the model
    4. Model evaluation and prediction
      1. Loss, accuracy, and confusion matrices for training data
      2. Prediction probabilities for training data
      3. Loss, accuracy, and confusion matrices for test data
      4. Prediction probabilities for test data
    5. Performance optimization tips and best practices
      1. Deeper networks
      2. Results
    6. Summary
  13. Image Classification Using Convolutional Neural Networks
    1. Data preparation
      1. Fashion-MNIST data
      2. Train and test data
      3. Reshaping and resizing
      4. One-hot encoding
    2. Layers in the convolutional neural networks
      1. Model architecture and related calculations
      2. Compiling the model
    3. Fitting the model
      1. Accuracy and loss
    4. Model evaluation and prediction
      1. Training data
      2. Test data
      3. 20 fashion items from the internet
    5. Performance optimization tips and best practices
      1. Image modification
      2. Changes to the architecture
    6. Summary
  14. Applying Autoencoder Neural Networks Using Keras
    1. Types of autoencoders
    2. Dimension reduction autoencoders
      1. MNIST fashion data
      2. Encoder model
      3. Decoder model
      4. Autoencoder model
      5. Compiling and fitting the model
      6. Reconstructed images
    3. Denoising autoencoders
      1. MNIST data
      2. Data preparation
      3. Adding noise
      4. Encoder model
      5. Decoder model
      6. Autoencoder model
      7. Fitting the model
      8. Image reconstruction
    4. Image correction
      1. Images that need correction
      2. Clean images
      3. Encoder model
      4. Decoder model
      5. Compiling and fitting the model
      6. Reconstructing images from training data
      7. Reconstructing images from new data
    5. Summary
  15. Image Classification for Small Data Using Transfer Learning
    1. Using a pretrained model to identify an image
      1. Reading an image
      2. Preprocessing the input
      3. Top five categories
    2. Working with the CIFAR10 dataset
      1. Sample images
      2. Preprocessing and prediction
    3. Image classification with CNN
      1. Data preparation
      2. CNN model
      3. Model performance
        1. Performance assessment with training data
        2. Performance assessment with test data
    4. Classifying images using the pretrained RESNET50 model
      1. Model architecture
      2. Freezing pretrained network weights
      3. Fitting the model
    5. Model evaluation and prediction
      1. Loss, accuracy, and confusion matrix with the training data
      2. Loss, accuracy, and confusion matrix with the test data
    6. Performance optimization tips and best practices
      1. Experimenting with the adam optimizer
      2. Hyperparameter tuning
      3. Experimenting with VGG16 as a pretrained network
    7. Summary
  16. Creating New Images Using Generative Adversarial Networks
    1. Generative adversarial network overview
    2. Processing MNIST image data
      1. Digit five from the training data
      2. Data processing
    3. Developing the generator network
      1. Network architecture
      2. Summary of the generator network
    4. Developing the discriminator network
      1. Architecture
      2. Summary of the discriminator network
    5. Training the network
      1. Initial setup for saving fake images and loss values
      2. Training process
    6. Reviewing results
      1. Discriminator and GAN losses
      2. Fake images
    7. Performance optimization tips and best practices
      1. Changes in the generator and discriminator network
      2. Impact of these changes on the results
      3. Generating a handwritten image of digit eight
    8. Summary
  17. Section 4: Deep Learning for Natural Language Processing
  18. Deep Networks for Text Classification
    1. Text datasets
      1. The UCI machine learning repository
      2. Text data within Keras
    2. Preparing the data for model building
      1. Tokenization
      2. Converting text into sequences of integers
      3. Padding and truncation
      4. Developing a tweet sentiment classification model
    3. Developing deep neural networks
      1. Obtaining IMDb movie review data
      2. Building a classification model
      3. Compiling the model
      4. Fitting the model
    4. Model evaluation and prediction
      1. Evaluation using training data
      2. Evaluation using test data
    5. Performance optimization tips and best practices
      1. Experimenting with the maximum sequence length and the optimizer
    6. Summary
  19. Text Classification Using Recurrent Neural Networks
    1. Preparing data for model building
      1. Padding sequences
    2. Developing a recurrent neural network model
      1. Calculation of parameters
      2. Compiling the model
    3. Fitting the model
      1. Accuracy and loss
    4. Model evaluation and prediction
      1. Training the data
      2. Testing the data
    5. Performance optimization tips and best practices
      1. Number of units in the simple RNN layer
      2. Using different activation functions in the simple RNN layer
      3. Adding more recurrent layers
      4. The maximum length for padding sequences
    6. Summary
  20. Text classification Using Long Short-Term Memory Network
    1. Why do we use LSTM networks?
    2. Preparing text data for model building
    3. Creating a long short-term memory network model
      1. LSTM network architecture
      2. Compiling the LSTM network model
    4. Fitting the LSTM model
      1. Loss and accuracy plot
    5. Evaluating model performance
      1. Model evaluation with train data
      2. Model evaluation with test data
    6. Performance optimization tips and best practices
      1. Experimenting with the Adam optimizer
      2. Experimenting with the LSTM network having an additional layer
      3. Experimenting with a bidirectional LSTM layer
    7. Summary
  21. Text Classification Using Convolutional Recurrent Neural Networks
    1. Working with the reuter_50_50 dataset
      1. Reading the training data
      2. Reading the test data
    2. Preparing the data for model building
      1. Tokenization and converting text into a sequence of integers
      2. Changing labels into integers
      3. Padding and truncation of sequences
      4. Data partitioning
      5. One-hot encoding the labels
    3. Developing the model architecture
    4. Compiling and fitting the model
      1. Compiling the model
      2. Fitting the model
    5. Evaluating the model and predicting classes
      1. Model evaluation with training data
      2. Model evaluation with test data
    6. Performance optimization tips and best practices
      1. Experimenting with reduced batch size
      2. Experimenting with batch size, kernel size, and filters in CNNs
    7. Summary
  22. Section 5: The Road Ahead
  23. Tips, Tricks, and the Road Ahead
    1. TensorBoard for training performance visualization
    2. Visualizing deep network models with LIME
    3. Visualizing model training with tfruns
    4. Early stopping of network training
    5. Summary
  24. Other Books You May Enjoy
    1. Leave a review - let other readers know what you think

Product information

  • Title: Advanced Deep Learning with R
  • Author(s): Bharatendra Rai
  • Release date: December 2019
  • Publisher(s): Packt Publishing
  • ISBN: 9781789538779