My network is returning both 100 percent training and validation. What seems to be the issue?

조회 수: 1 (최근 30일)
myfolder = 'C:\Users\MigueLegaspi\Downloads\fall dataset\rgb';
dataDir = fullfile(myfolder);
imdir = fullfile(dataDir);
myfolder2 = 'C:\Users\MigueLegaspi\Downloads\Validation\rgb';
dataDir2 = fullfile(myfolder2);
imdir2 = fullfile(dataDir2);
imds = imageDatastore(imdir, "IncludeSubfolders",true ,"LabelSource","foldernames");
imds2 = imageDatastore(imdir2,"IncludeSubfolders",true,"LabelSource","foldernames");
numTrainfiles =6963;
numValidfiles = 6598;
[imdsTrain] = splitEachLabel(imds,numTrainfiles,'randomized');
[imdsValidation] = splitEachLabel(imds2,numValidfiles,'randomized');
%definingarchitecture
numClasses = numel(categories(imdsTrain.Labels));
numClasses2 = numel(categories(imdsValidation.Labels));
layers = [
imageInputLayer([240 320 3])
convolution2dLayer(3,16,'Padding',1)
batchNormalizationLayer
reluLayer
maxPooling2dLayer(2,"Stride",2)
convolution2dLayer(3,32,'Padding',1)
batchNormalizationLayer
reluLayer
fullyConnectedLayer(numClasses)
softmaxLayer
classificationLayer];
%trainetwork
options = trainingOptions('sgdm', ...
'MaxEpochs',4, ...
'MiniBatchSize',64,...
'ValidationData',imdsValidation, ...
'ValidationFrequency',30, ...
'Verbose',false, ...
'Plots','training-progress');
net = trainNetwork(imdsTrain,layers,options);
YPred = classify(net,imdsValidation);
yvalidation = imdsValidation.Labels;
accuracy = mean(Ypred == yvalidation);

답변 (1개)

Prateek Rai
Prateek Rai 2022년 3월 2일
To my understanding, you are trying to train the network and the network is returning both 100 percent training and validation.
One possible reason for this could be that your datastore is not created properly. Your folder might contain only one subfolder and hence creating only one class in imds which might be leading to 100 percent training and validation accuracy.
Try checking the dataset once. You can refer to the imageDatastore MathWorks Documentation page to learn more about creating a datastore for image data.

카테고리

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