Main Content

监视深度学习培训进度

当您培训网络以进行深度学习时,监视培训进度通常很有用。通过在培训期间绘制各种指标,您可以了解培训的进展方式。例如,您可以确定网络准确性是否在提高以及网络是否开始过度拟合培训数据。

指定时“训练过程”作为“绘图”value intrainingOptionsand start network training,火车网创建一个人物并在每次迭代中显示培训指标。每次迭代都是对网络参数的梯度和更新的估计。如果您在trainingOptions,然后该图每次显示验证指标火车网验证网络。该图绘制了以下内容:

  • 培训准确性-Classification accuracy on each individual mini-batch.

  • 平滑的训练准确性- 通过将平滑算法应用于训练准确性获得的平滑训练精度。它比不平滑的精度吵闹,使发现趋势更容易。

  • Validation accuracy-Classification accuracy on the entire validation set (specified usingtrainingOptions)。

  • 培训损失,,,,smoothed training loss,,,,and验证损失-每个迷你批次的损失,其平滑版本和验证集的损失。如果网络的最后一层是分类器,那么损耗函数是交叉熵损失。有关分类和回归问题损失功能的更多信息,请参见输出层

对于回归网络,该图绘制了均方根误差(RMSE)而不是精度。

图标记每个训练时代使用阴影背景。一个时期是整个数据集的完整通行证。

在培训期间,您可以通过单击右上角的停止按钮来停止训练并返回网络的当前状态。例如,当网络的准确性达到高原时,您可能需要停止训练,并且很明显,准确性不再有所提高。单击“停止”按钮后,培训可能需要一段时间才能完成。培训完成后,火车网返回训练有素的网络。

训练完成时,查看Resultsshowing the finalized validation accuracy and the reason that training finished. If the“ outputnetwork'培训选项设置为“最后近期”(默认值),最终确定的指标对应于最后的训练迭代。如果是“ outputnetwork'培训选项设置为'best-validation-loss',,,,the finalized metrics correspond to the iteration with the lowest validation loss. The iteration from which the final validation metrics are calculated is labeledFinal在图中。

If your network contains batch normalization layers, then the final validation metrics can be different to the validation metrics evaluated during training. This is because the mean and variance statistics used for batch normalization can be different after training completes. For example, if the“批次正规化阶段”training option is'人口',然后训练后,软件使结束batch normalization statistics by passing through the training data once more and uses the resulting mean and variance. If the“批次正规化阶段”training option is'移动'然后,该软件使用运行估算值近似培训期间的统计信息,并使用统计信息的最新值。

On the right, view information about the training time and settings. To learn more about training options, see设置参数和火车卷积神经网络

Plot Training Progress During Training

培训网络并在培训过程中绘制培训进度。

Load the training data, which contains 5000 images of digits. Set aside 1000 of the images for network validation.

[Xtrain,Ytrain] = DigitTrain4DarrayData;idx = randperm(size(xtrain,4),1000);xvalidation = xtrain(:,::,:,idx);Xtrain(:,:,:,:,IDX)= [];yvalidation = ytrain(idx);ytrain(idx)= [];

Construct a network to classify the digit image data.

layers = [ imageInputLayer([28 28 1]) convolution2dLayer(3,8,'填充',,,,'same') batchNormalizationLayer reluLayer maxPooling2dLayer(2,“大步”,,,,2) convolution2dLayer(3,16,'填充',,,,'same') batchNormalizationLayer reluLayer maxPooling2dLayer(2,“大步”,2)卷积2Dlayer(3,32,,'填充',,,,'same') batchNormalizationLayer reluLayer fullyConnectedLayer(10) softmaxLayer classificationLayer];

指定网络培训的选项。要在培训期间定期验证网络,请指定验证数据。选择'ValidationFrequency'value so that the network is validated about once per epoch. To plot training progress during training, specify“训练过程”作为“绘图”价值。

options = trainingOptions('sgdm',,,,...“ maxepochs”,8,...'ValidationData',,,,{XValidation,YValidation},...'ValidationFrequency',,,,30,...“冗长”,,,,false,...“绘图”,,,,“训练过程”);

训练网络。

net = trainNetwork(XTrain,YTrain,layers,options);

Figure Training Progress (01-Sep-2021 08:34:02) contains 2 axes objects and another object of type uigridlayout. Axes object 1 contains 15 objects of type patch, text, line. Axes object 2 contains 15 objects of type patch, text, line.

也可以看看

|

Related Topics