1. Overview
After we define the layers of our network, the next step is to set up the training options for the network. Use thetrainingOptions function to set up the global ntraining parameters.trainNetwork then uses these options to perform the training.trainingOptions returns these options as aTrainingOptionsSGDM object and we must provide it as an input argument to trainNetwork. For example,
opts = trainingOptions('sgdm');
convnet = trainNetwork(data,layers,opts);
2. Set up the Parameters
2.1 Specify Solver and Maximum Number of Epochs
trainNetwork uses the “Stochastic Gradient Descent with Momentum(带有动量的随机梯度下降算法)” (SGDM) as the optimization algorithm. We must specify 'sgdm' as the SolverName input argument of trainingOptions.SGDM updates the weights and biases (parameters) by taking small steps in the direction of the negative gradient of the loss function, in such a way to minimize the loss. It updates the parameters using a subset of the data every time. This subset is called a mini-batch. We can specify the size of the mini-batch using the 'MiniBatchSize' name-value pair argument of trainingOptions.
Each evaluation of the gradient using a mini-batch is called aniteration. A full pass through the whole data set is called an