Book Image

R Deep Learning Projects

Book Image

R Deep Learning Projects

Overview of this book

R is a popular programming language used by statisticians and mathematicians for statistical analysis, and is popularly used for deep learning. Deep Learning, as we all know, is one of the trending topics today, and is finding practical applications in a lot of domains. This book demonstrates end-to-end implementations of five real-world projects on popular topics in deep learning such as handwritten digit recognition, traffic light detection, fraud detection, text generation, and sentiment analysis. You'll learn how to train effective neural networks in R—including convolutional neural networks, recurrent neural networks, and LSTMs—and apply them in practical scenarios. The book also highlights how neural networks can be trained using GPU capabilities. You will use popular R libraries and packages—such as MXNetR, H2O, deepnet, and more—to implement the projects. By the end of this book, you will have a better understanding of deep learning concepts and techniques and how to use them in a practical setting.
Table of Contents (11 chapters)

Dealing with a small training set – data augmentation


We have been very fortunate so far to possess a large-enough training dataset with 75% of 39,209 samples. This is one of the reasons why we are able to achieve a 99.3% to 99.4% classification accuracy. However, in reality, obtaining a large training set is not easy in most supervised learning cases, where manual work is necessary or the cost of data collection and labeling is high. In our traffic signs classification project, can we still achieve the same performance if we are given a lot less training samples to begin with? Let's give it a shot.

We simulate a small training set with only 10% of the 39,209 samples and a testing set with the rest 90%:

> train_perc_1 = 0.1 
> train_index_1 <- createDataPartition(data.y, p=train_perc_1, list=FALSE) 
> train_index_1 <- train_index_1[sample(nrow(train_index_1)),] 
> data_train_1.x <- data.x[train_index_1,] 
> data_train_1.y <- data.y[train_index_1] 
> data_test_1...