简体   繁体   中英

How to monitor deep learning training

I want to monitor the training when its happening, how should I change my code for that? I found some explanation her https://se.mathworks.com/help/deeplearning/ug/monitor-deep-learning-training-progress.html but I couldn't apply it, can someone please help?


[trainingSet,testSet] = splitEachLabel(imds,0.3,'randomize');
imageSize = net.Layers(1).InputSize; 
augmentedTrainingSet = augmentedImageDatastore(imageSize,...
    trainingSet,'ColorPreprocessing','gray2rgb'); 
augmentedTestSet = augmentedImageDatastore(imageSize,...
    testSet,'ColorPreprocessing','gray2rgb');
w1 = net.Layers(2).Weights;
w1 = mat2gray(w1); 
featureLayer = 'fc1000'; 
trainingFeatures = activations(net,augmentedTrainingSet,...
    featureLayer,'MiniBatchSize',32,'OutputAs','columns');
trainingLables = trainingSet.Labels;
classifier=fitcecoc(trainingFeatures,...
    trainingLables,'Learner','Linear','Coding','onevsall','ObservationsIn','columns');
testFeature = activations(net,augmentedTestSet,...
    featureLayer,'MiniBatchSize',32,'OutputAs','columns');
predictLabels = predict(classifier, testFeature,'ObservationsIn','columns');
testLables = testSet.Labels; 
confMat = confusionmat(testLables , predictLabels);
confMat = bsxfun(@rdivide , confMat , sum(confMat,2));
mean(diag(confMat));

I think this is only possible using the trainNetwork function ( net = trainNetwork(XTrain,YTrain,layers,options) ) and unfortunately this option is not provided in fitcecoc. So you can instead send your training data and network layers as well as the options to trainNetwork to plot the training progress for you. Notice that in order to plot the progress you should also specify 'training-progress' as the 'Plots' value in options as the last line in the following code shows, for instance:

options = trainingOptions('sgdm', ...
    'MaxEpochs',8, ...
    'ValidationData',{XValidation,YValidation}, ...
    'ValidationFrequency',30, ...
    'Verbose',false, ...
    'Plots','training-progress');

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM