Spliting ground truth data into 70% for training, 30% for Validation
1 view (last 30 days)
Show older comments
Abdussalam Elhanashi
on 26 Nov 2020
Answered: Swetha Polemoni
on 18 Dec 2020
Hi
i want to know how to split Data ( training, validation) from ground truth file generated by ground truth labeler application i need for example 70% for training 30% for validation
This is in order to implement validationData in training option to get validation loose curve
in my code , i was able only to do TrainingData, but i cant make Validation to be avaliable for ValidationData in training option
Herein the code
load('gTruth.mat')
socialdistencedetection = selectLabels(gTruth,'cars');
if isfolder(fullfile('TrainingData'))
cd TrainingData
else
mkdir TrainingData
end
addpath('TrainingData');
inputLayer = imageInputLayer([224 224 3],'Name','input','Normalization','none');
filterSize = [3 3];
middleLayers = [
convolution2dLayer(filterSize, 16, 'Padding', 1,'Name','conv_1',...
'WeightsInitializer','narrow-normal')
batchNormalizationLayer('Name','BN1')
reluLayer('Name','relu_1')
maxPooling2dLayer(2, 'Stride',2,'Name','maxpool1')
convolution2dLayer(filterSize, 32, 'Padding', 1,'Name', 'conv_2',...
'WeightsInitializer','narrow-normal')
batchNormalizationLayer('Name','BN2')
reluLayer('Name','relu_2')
maxPooling2dLayer(2, 'Stride',2,'Name','maxpool2')
convolution2dLayer(filterSize, 64, 'Padding', 1,'Name','conv_3',...
'WeightsInitializer','narrow-normal')
batchNormalizationLayer('Name','BN3')
reluLayer('Name','relu_3')
maxPooling2dLayer(2, 'Stride',2,'Name','maxpool3')
convolution2dLayer(filterSize, 128, 'Padding', 1,'Name','conv_4',...
'WeightsInitializer','narrow-normal')
batchNormalizationLayer('Name','BN4')
reluLayer('Name','relu_4')
maxPooling2dLayer(2, 'Stride',2,'Name','maxpoo4')
convolution2dLayer(filterSize, 256, 'Padding', 1,'Name','conv_5',...
'WeightsInitializer','narrow-normal')
batchNormalizationLayer('Name','BN5')
reluLayer('Name','relu_5')
];
lgraph = layerGraph([inputLayer; middleLayers]);
imageSize = [224 224 3];
Anchors = [
102 15
170 29
191 41
122 29
45 11
96 21
137 21
];
options = trainingOptions('sgdm', ...
'InitialLearnRate',0.01, ...
'Verbose',true,'MiniBatchSize',16,'L2Regularization',0.06,'MaxEpochs',80,...
'Shuffle','every-epoch','VerboseFrequency',50, ...
'DispatchInBackground',true,...
'ExecutionEnvironment','auto','ValidationData',Validation);
trainingData = objectDetectorTrainingData(socialdistencedetection,'SamplingFactor',1,...
'WriteLocation','TrainingData');
numClasses = size(trainingData,2)-1;
lgraph = yolov2Layers([224 224 3],numClasses,Anchors,lgraph,'relu_5');
analyzeNetwork(lgraph);
[detectorYolo2, info] = trainYOLOv2ObjectDetector(trainingData,lgraph,options);
save('detectorYolo2.mat','detectorYolo2');
% For Training Loss
x = 1:size(info.TrainingLoss,2);
y = info.TrainingLoss;
figure
plot(x,y)
title('Training Phase')
xlabel('Iteration')
ylabel('Mini Batch Training Loss')
0 Comments
Accepted Answer
Swetha Polemoni
on 18 Dec 2020
Hi Abdussalam Elhanashi
It is my understand that you want to create a dataset from existing data for validation purpose. You may find the documentation Save and Load Parts of Variables in MAT-Files useful in creating new mat file which is a part of existing one.
0 Comments
More Answers (0)
See Also
Categories
Find more on Motor Drives in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!