Step 4:
Begin bulding the network by defining its layers. You will be creating a layer of layers (or an array of layers).
clear all;
close all;
clc;
[XTrain,YTrain] = digitTrain4DArrayData;
size(XTrain) %images
size(YTrain) %correct answer labels
XTrain=1-XTrain; % Reverse the black and white colors. Save and run the program to see the difference.
perm = randperm(size(XTrain,4),20); % Randomize the order of images in XTrain
for i = 1:20
subplot(4,5,i);
imshow(XTrain(:,:,:,perm(i)));
end
layers = [
imageInputLayer([28 28 1]) %The input layer should be able to take a 28x28x1 image (grayscale).
In
the next step, add a convolution layer. You have to define two
hyperparameters for this next layer (a hyperparameter is just a network
parameter whose value does not change during training, for example the number of nodes or layers in a network). Set up a
convolutoin layer with 8 filters (each filter should be a 3x3).
These values are arbitrary, but they work well here. Try
setting up this layer without first looking at step 5. How would
you set this up? It's one line, and relatively easy.