First solution – convolutional neural networks using MXNet

We start off with a solution similar to the one we developed at the end of the previous chapter, with CNNs using MXNet.

Again, we first split the dataset into two subsets for training (75%) and testing (25%) using the caret package:

> if (!require("caret"))  
+     install.packages("caret") 
> library (caret) 
> set.seed(42) 
> train_perc = 0.75 
> train_index <- createDataPartition(data.y, p=train_perc, list=FALSE) 
> train_index <- train_index[sample(nrow(train_index)),] 
> data_train.x <- data.x[train_index,] 
> data_train.y <- data.y[train_index] 
> data_test.x <- data.x[-train_index,] 
> data_test.y <- data.y[-train_index] 

Don't forget to specify a particular random seed for reproducible work. ...

Get R Deep Learning Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.