Manually Plotting the graph from R-CNN training parameters

12 次查看(过去 30 天)
Hi Guys
I have a problem when i want to make a graph for the training phase like between Epoch & Mini-batch Loss
Herein the code
load('gTruth.mat')
smokedetection = selectLabels(gTruth,'car');
if isfolder(fullfile('TrainingData'))
cd TrainingData
else
mkdir TrainingData
end
addpath('TrainingData');
options = trainingOptions('sgdm', ...
'MiniBatchSize', 32, ...
'InitialLearnRate', 1e-6, ...
'MaxEpochs', 10);
layers = [
imageInputLayer([32 32 3],"Name","imageinput")
convolution2dLayer([5 5],32,"Name","conv","BiasLearnRateFactor",2,"Padding",[2 2 2 2],"WeightsInitializer","narrow-normal")
maxPooling2dLayer([3 3],"Name","maxpool","Stride",[2 2])
reluLayer("Name","relu")
averagePooling2dLayer([3 3],"Name","avgpool","Stride",[2 2])
fullyConnectedLayer(2,"Name","fc_rcnn","BiasL2Factor",1,"BiasLearnRateFactor",10,"WeightLearnRateFactor",20,"WeightsInitializer","narrow-normal")
softmaxLayer("Name","softmax")
classificationLayer("Name","classoutput")];
trainingData = objectDetectorTrainingData(smokedetection,'SamplingFactor',1,...
'WriteLocation','TrainingData');
detector = trainRCNNObjectDetector(trainingData, layers, options, ...
'NegativeOverlapRange', [0 0.3]);
save('Detector.mat','detector');
[detector,info] = trainRCNNObjectDetector('Epoch','Mini-batch Loss','Training Accuracy','Base Learning Rate','Mini-batch Accuracy');
x = ('Epoch');
y = ('Mini-batch Loss');
figure
plot(x,y)
title('Training Phase')
xlabel('Number of Epochs')
ylabel('Training Loss')
Error
Error using trainRCNNObjectDetector
Expected input number 1, trainingData, to be one of these types:
table
Error in vision.internal.cnn.validation.checkGroundTruth (line 2)
validateattributes(gt, {'table'},{'nonempty'}, name, 'trainingData',1);
Error in trainRCNNObjectDetector>parseInputs (line 311)
vision.internal.cnn.validation.checkGroundTruth(trainingData, fname);
Error in trainRCNNObjectDetector (line 248)
[network, params] = parseInputs(trainingData, network, options, mfilename, varargin{:});
Error in TrainingSmokeDetectionwithRCNN (line 29)
[detector,info] = trainRCNNObjectDetector('Epoch','Mini-batch Loss','Training Accuracy','Base
Learning Rate','Mini-batch Accuracy');

采纳的回答

Raunak Gupta
Raunak Gupta 2019-12-2
Hi,
The trainingOptions for trainRCNNObjectDetector does not support plotting the train-progress while the training is going on, but the training parameters are returned at the end of training if trainRCNNObjectDetector is used with following arguments.
[detector,info] = trainRCNNObjectDetector(___)
In the script from the question following command looks incorrect,
[detector,info] = trainRCNNObjectDetector('Epoch','Mini-batch Loss','Training Accuracy','Base Learning Rate','Mini-batch Accuracy');
instead the above can be replaced by
[detector,info] = trainRCNNObjectDetector(trainingData, layers, options, 'NegativeOverlapRange', [0 0.3]);
Here info will be returned as a structure which contains the ‘Training Accuracy’, ‘Training Loss’ and ‘Base Learning Rate’ for each iteration. These can be then plotted as per required. The error was there because correct input arguments weren’t passed.
  7 个评论
Abdussalam Elhanashi
reference to this issue i already plot many graphs even for the example using the RCNN for stop sign by Matlab but i got fluactuation AS SHOWN IN IMAGE is it possible to improve it for the given code?
Training Loss.jpg
Raunak Gupta
Raunak Gupta 2019-12-5
Hi,
The loss is calculated for each mini batch that is why the fluctuation is there. You may use smooth to remove too many fluctuations.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Deep Learning Toolbox 的更多信息

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by