Validation Accuracy on Neural network

29 ビュー (過去 30 日間)
Andrik Rampun
Andrik Rampun 2019 年 2 月 18 日
回答済み: Sevda Kemba 2022 年 6 月 6 日
Hello..I wonder if any of you who have used deep learning on matlab can help me to troubleshoot my problem. I don't understand why I got a sudden drop of my validation accuracy at the end of the graph? It's a simple network with one convolution layer to classify cases with low or high risk of having breast cancer. After the final iteration it displays a validation accuracy of above 80% but then suddenly it dropped to 73% without an iteration. I don't understand that.
matlab_per2.png
Here's my code
%set training dataset folder
digitDatasetPath = fullfile('C:\Users\UOS\Documents\Desiree Data\Run
2\dataBreast\training2');
%training set
imdsTrain = imageDatastore(digitDatasetPath, ...
'IncludeSubfolders',true,'LabelSource','foldernames');
%set validation dataset folder
validationPath = fullfile('C:\Users\UOS\Documents\Desiree Data\Run
2\dataBreast\validation2');
%testing set
imdsValidation = imageDatastore(validationPath, ...
'IncludeSubfolders',true,'LabelSource','foldernames');
%create a clipped ReLu layer
layer = clippedReluLayer(10,'Name','clip1');
% define network architecture
layers = [
imageInputLayer([256 256 1]);
% conv_1
convolution2dLayer(3,32,'Stride',1)
batchNormalizationLayer
clippedReluLayer(10);
maxPooling2dLayer(2,'Stride',2)
%fc
fullyConnectedLayer(100)
dropoutLayer(0.7,'Name','drop1');
%fc
fullyConnectedLayer(25)
dropoutLayer(0.8,'Name','drop2');
% fc layer
fullyConnectedLayer(2)
softmaxLayer
classificationLayer];
% specify training option
options = trainingOptions('adam', ...
'InitialLearnRate',0.001, ...
'MaxEpochs',15, ...
'Shuffle','every-epoch', ...
'ValidationData',imdsValidation, ...
'ValidationFrequency',30, ...
'Verbose',false, ...
'Plots','training-progress');
% train network using training data
net = trainNetwork(imdsTrain,layers,options);
% classify validation images and compute accuracy
YPred = classify(net,imdsValidation);
YValidation = imdsValidation.Labels;
%calculate accuracy
accuracy = sum(YPred == YValidation)/numel(YValidation);
  8 件のコメント
Sridharan K
Sridharan K 2021 年 3 月 10 日
i got 100% accuracy. thanks for this program.
Santhosh Surya Kiran
Santhosh Surya Kiran 2021 年 7 月 1 日
What u got is wrong..

サインインしてコメントする。

回答 (4 件)

Andrik Rampun
Andrik Rampun 2019 年 2 月 19 日
Some updates. I got similar results (sudden drop) at the end of the graph. I find this really strange.
% set training dataset folder
digitDatasetPath = fullfile('C:\Users\UOS\Documents\Desiree Data\Run 2\dataBreast\training2');
imdsTrain = imageDatastore(digitDatasetPath, ...
'IncludeSubfolders',true,'LabelSource','foldernames');
% set validation dataset folder
validationPath = fullfile('C:\Users\UOS\Documents\Desiree Data\Run 2\dataBreast\validation2');
imdsValidation = imageDatastore(validationPath, ...
'IncludeSubfolders',true,'LabelSource','foldernames');
% create a clipped ReLu layer
layer = clippedReluLayer(10,'Name','clip1');
% define network architecture
layers = [
imageInputLayer([256 256 1], 'Normalization', 'none')
% conv_1
convolution2dLayer(3,16,'Stride',1)
batchNormalizationLayer
clippedReluLayer(10);
maxPooling2dLayer(2,'Stride',2)
% conv_2
convolution2dLayer(3,16,'Stride',1)
batchNormalizationLayer
clippedReluLayer(10);
maxPooling2dLayer(2,'Stride',2)
% conv_3
convolution2dLayer(3,32,'Stride',1)
batchNormalizationLayer
clippedReluLayer(10);
maxPooling2dLayer(2,'Stride',2)
% conv_4
convolution2dLayer(3,64,'Stride',1)
batchNormalizationLayer
clippedReluLayer(10);
maxPooling2dLayer(2,'Stride',2)
% conv_5
convolution2dLayer(3,128,'Stride',1)
batchNormalizationLayer
clippedReluLayer(10);
maxPooling2dLayer(2,'Stride',2)
% conv_6
convolution2dLayer(3,256,'Stride',1)
batchNormalizationLayer
clippedReluLayer(10);
maxPooling2dLayer(2,'Stride',2)
% fc5
fullyConnectedLayer(500)
dropoutLayer(0.5,'Name','drop1');
% fc5
fullyConnectedLayer(250)
dropoutLayer(0.5,'Name','drop2');
% fc5
fullyConnectedLayer(50)
dropoutLayer(0.5,'Name','drop3');
% fc layer
fullyConnectedLayer(2)
softmaxLayer
classificationLayer];
% soecify training option
options = trainingOptions('adam', ...
'InitialLearnRate',0.001, ...
'MaxEpochs',30, ...
'Shuffle','every-epoch', ...
'ValidationData',imdsValidation, ...
'ValidationFrequency',30, ...
'Verbose',false, ...
'Plots','training-progress');
% train network using training data
net = trainNetwork(imdsTrain,layers,options);
% classify validation images and compute accuracy
YPred = classify(net,imdsValidation);
YValidation = imdsValidation.Labels;
accuracy = sum(YPred == YValidation)/numel(YValidation)
%YPred = predict(net,X);
analyzeNetwork(net)
matlab_per3.png
  18 件のコメント
Andrik Rampun
Andrik Rampun 2019 年 2 月 26 日
Hi Don,
When you said shirink batchsize do you mean my MinibatchSize?
Another question is I can even reduce my hidden units in my FC layer?
Thanks
Don Mathis
Don Mathis 2019 年 2 月 26 日
Yes, MiniBatchSize. And I meant the outputSize of your fullyConnectedLayers could be reduced to something smaller than 3136:
fullyConnectedLayer(3136)

サインインしてコメントする。


Saira
Saira 2020 年 6 月 15 日
Hi,
I have 5600 training images. I have extracted features using Principal Component Analysis (PCA). Then I am applying CNN on extracted features. My training accuracy is 30%. How to increase training accuracy?
Feature column vector size: 640*1
My training code:
% Convolutional neural network architecture
layers = [
imageInputLayer([1 640 1]);
reluLayer
fullyConnectedLayer(7);
softmaxLayer();
classificationLayer()];
options = trainingOptions('sgdm', 'Momentum',0.95, 'InitialLearnRate',0.0001, 'L2Regularization', 1e-4, 'MaxEpochs',5000, 'MiniBatchSize',8192, 'Verbose', true);

Sevda Kemba
Sevda Kemba 2022 年 6 月 6 日
@Andrik Rampun Hello. In Matlab, we load the data set with code and limit it in deep learning. But when we train, validation accuracy stays between 40-50%. What can we do to increase it to 90%? We would be very happy if you could help.

Sevda Kemba
Sevda Kemba 2022 年 6 月 6 日
@Saira Hello. In Matlab, we load the data set with code and limit it in deep learning. But when we train, validation accuracy stays between 40-50%. What can we do to increase it to 90%? We would be very happy if you could help.

カテゴリ

Help Center および File ExchangeImage Data Workflows についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by