Book Image

Deep Learning with R for Beginners

By : Mark Hodnett, Joshua F. Wiley, Yuxi (Hayden) Liu, Pablo Maldonado
Book Image

Deep Learning with R for Beginners

By: Mark Hodnett, Joshua F. Wiley, Yuxi (Hayden) Liu, Pablo Maldonado

Overview of this book

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.
Table of Contents (23 chapters)
Title Page
Copyright and Credits
About Packt
Contributors
Preface
Index

Preface

Deep learning finds practical applications in several domains and R is a preferred language to design and deploy deep learning models.This Learning Path introduces you to the basics of deep learning and teaches you to build a neural network model from scratch. As you make your way through the concepts, you’ll explore deep learning libraries and create deep learning models for a variety of problems, such as anomaly detection and recommendation systems. You’ll cover advanced topics, such as generative adversarial networks (GANs), transfer learning, and large-scale deep learning in the cloud. Before it ends, this Learning Path teaches you advanced topics, such as model optimization, overfitting, and data augmentation. Through real-world projects, you’ll learn how to train convolutional neural networks, recurrent neural networks, and LSTMs in R.By the end of this Learning Path, you’ll have a better understanding of deep learning concepts and will be able to implement deep learning concepts in your research work or projects.

This Learning Path includes content from the following Packt products:

  • R Deep Learning Essentials - Second Edition by Joshua F. Wiley and Mark Hodnett
  • R Deep Learning Projects by Yuxi (Hayden) Liu and Pablo Maldonado

Who this book is for

This Learning Path is ideal 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. Fundamental understanding of the R language and familiarity with basic concepts of deep learning are necessary to get the most out of this Learning Path.

 

What this book covers

Chapter 1, Getting Started with Deep Learning, gives an introduction to deep learning and neural networks. It also gives a brief introduction on how to set up your R environment.

Chapter 2, Training a Prediction Model, begins with building neural network models using the existing packages in R. This chapter also discusses overfitting, which is an issue in most deep learning models

Chapter 3, Deep Learning Fundamentals, teaches how to build a neural network in R from scratch. We then show how our code relates to MXNet, a deep learning library.

Chapter 4, Training Deep Prediction Models, looks at activations and introduces the MXNet library. We then build a deep learning prediction model for a real-life example. We will take a raw dataset of transactional data and develop a data pipeline to create a model that predicts which customers will return in the next 14 days.

Chapter 5, Image Classification Using Convolutional Neural Networks, looks at image classification tasks. First, we will introduce some of the core concepts, such as convolutional and pooling layers, and then we will show how to use these layers to classify images

Chapter 6, Tuning and Optimizing Models, discusses how to tune and optimize deep learning models. We look at tuning hyperparameters and using data augmentation.

Chapter 7, Natural Language Processing Using Deep Learning, shows how to use deep learning for Natural Language Processing (NLP) tasks. We show how deep learning algorithms outperform traditional NLP techniques, while also being much easier to develop

Chapter 8, Deep Learning Models Using TensorFlow in R, looks at using the TensorFlow API in R. We also look at some additional packages available within TensorFlow that make developing TensorFlow models simpler and help in hyperparameter selection.

Chapter 9, Anomaly Detection and Recommendation Systems, shows how we can use deep learning models to create embeddings that are lower order representations of data. We then show how to use embeddings for anomaly detection and to create a recommendation system.

Chapter 10, Running Deep Learning Models in the Cloud, covers how to use AWS, Azure, and Google Cloud services to train deep learning models. This chapter shows how to train your models at low-cost in the cloud.

Chapter 11, The Next Level in Deep Learning, introduces an end-to-end solution for image classification. We take a set of image files, train a model, reuse that model for transfer learning and then show how to deploy that model to production. We also briefly discuss Generative Adversarial Networks (GANs) and reinforcement learning.

Chapter 12, Handwritten Digit Recognition Using Convolutional Neural Networks, we begin with a recap of logistic regression and multilayer perceptron. We'll solve the problem with these two algorithms. We will then move on to the biologically inspired variants of multilayer perceptron—convolutional neural networks (CNNs).

Chapter 13, Traffic Sign Recognition for Intelligent Vehicles, explains how to use CNNs for another application—traffic sign detection. We will also cover several important concepts of deep learning in this chapter and get readers familiar with other popular frameworks and libraries, such as Keras and TensorFlow. We will also introduce the dropout technique as a regularization approach and utilize data augmentation techniques to deal with a lack of training data.

Chapter 14, Fraud Detection with Autoencoders, introduces a type of deep learning model that can be used for anomaly detection. Outliers can be found within a collection of images, a text corpus, or transactional data. We will dive into applications of autoencoders and how they can be used for outlier detection in this domain.

Chapter 15, Text Generation Using Recurrent Neural Networks, introduces different models of neural networks that try to capture the elusive properties of memory and abstraction to produce powerful models. We will apply different methods to tackle the text generation problem and suggest directions of further exploration.

Chapter 16, Sentiment Analysis with Word Embeddings, shows how to use the popular GloVe algorithm for sentiment analysis, as well as other, less abstract tools. Although this algorithm is, strictly speaking, not a deep learning application, it belongs to the modern toolkit of the data scientist, and it can be combined with other deep learning techniques.

 

To get the most out of this book

You should be comfortable with R and RStudio and have some knowledge of college-level mathematics (calculus and linear algebra). Working knowledge of basic machine learning algorithms for classification, regression problems, and clustering might be helpful, but it is not strictly required

You would need access to a high-end machine or even a machine with a GPU. To get the most out of this book, I recommend that you execute all the code examples. Experiment with them, change the parameters, and try to beat the metrics in the book.

Download the example code files

You can download the example code files for this book from your account at www.packt.com. If you purchased this book elsewhere, you can visit www.packt.com/support and register to have the files emailed directly to you.

You can download the code files by following these steps:

  1. Log in or register at www.packt.com.
  2. Select the SUPPORT tab.
  3. Click on Code Downloads & Errata.
  4. Enter the name of the book in the Search box and follow the onscreen instructions.

Once the file is downloaded, please make sure that you unzip or extract the folder using the latest version of:

  • WinRAR/7-Zip for Windows
  • Zipeg/iZip/UnRarX for Mac
  • 7-Zip/PeaZip for Linux

The code bundle for the book is also hosted on GitHub at  https://github.com/TrainingByPackt/Deep-Learning-with-R-for-Beginners .In case there's an update to the code, it will be updated on the existing GitHub repository.

We also have other code bundles from our rich catalogue of books and videos available at https://github.com/PacktPublishing/. Check them out!

Download the color images of this book

We also provide you with a PDF file that has color images of the screenshots/diagrams used in this book. The color images will help you better understand the changes in the output. You can download this file from https://www.packtpub.com/sites/default/files/downloads/9781838642709_ColorImages.pdf

Conventions used

There are a number of text conventions used throughout this book.

CodeInText: Indicates code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles. Here is an example: "The input() method is used to get an input from the user."

A block of code is set as follows:

> for (i in 1:16) {
+ outputData <- as.array
(executor$ref.outputs$activation15_output)[,,i,1]
+ image(outputData, xaxt='n', yaxt='n',
col=grey.colors(255)
+ )
+ }

Any command-line input or output is written as follows:

$ tensorboard --logdir /tensorflow_logs

Bold: Indicates a new term, an important word, or words that you see onscreen. For example, words in menus or dialog boxes appear in the text like this. Here is an example: "If you need something different, click on the DOWNLOADS link in the header for all possible downloads:"

Note

Warnings or important notes appear like this.

Note

Tips and tricks appear like this.

 

 

Get in touch

Feedback from our readers is always welcome.

General feedback: If you have questions about any aspect of this book, mention the book title in the subject of your message and email us at [email protected].

Errata: Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you have found a mistake in this book, we would be grateful if you would report this to us. Please visit www.packt.com/submit-errata, selecting your book, clicking on the Errata Submission Form link, and entering the details.

Piracy: If you come across any illegal copies of our works in any form on the Internet, we would be grateful if you would provide us with the location address or website name. Please contact us at [email protected] with a link to the material.

If you are interested in becoming an author: If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, please visit authors.packtpub.com.

Reviews

Please leave a review. Once you have read and used this book, why not leave a review on the site that you purchased it from? Potential readers can then see and use your unbiased opinion to make purchase decisions, we at Packt can understand what you think about our products, and our authors can see your feedback on their book. Thank you!

For more information about Packt, please visit packt.com.