Now, we can create a model based on the LeNet architecture. This is a very simple model; we have two sets of convolutional and pooling layers and then a Flatten layer, and finally two dense layers. The code for this is in Chapter5/mnist.Rmd. First let's define the model:

data <- mx.symbol.Variable('data')# first convolution layerconvolution1 <- mx.symbol.Convolution(data=data, kernel=c(5,5), num_filter=64)activation1 <- mx.symbol.Activation(data=convolution1, act_type="tanh")pool1 <- mx.symbol.Pooling(data=activation1, pool_type="max",                           kernel=c(2,2), stride=c(2,2))# second convolution layerconvolution2 <- mx.symbol.Convolution(data=pool1, kernel=c(5,5), num_filter=32)activation2 <- mx.symbol.Activation(data=convolution2, act_type="relu") ...

Get R Deep Learning Essentials now with O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.