I want to increase the validation accuracy
This is my matlab code :
clear all
clc
outputFolder=fullfile('train/resized');
rootFolder=fullfile(outputFolder,'');
categories={'Mild DR 1','Moderate DR 2','No DR 0','Proliferative DR 4','Severe DR 3'};
%
imds=imageDatastore(fullfile(rootFolder,categories),'LabelSource','foldernames');
image_size =[224 224 3]
augimds = augmentedImageDatastore(image_size,imds)
tb1=countEachLabel(imds);
minSetcount=min(tb1{:,2});
imds =splitEachLabel(imds,minSetcount,'randomize');
[XTrain,YTrain] = splitEachLabel(imds, .5);
test_labels = imds.Labels;
tbl = numel(test_labels)
idx = randperm(size(XTrain.Labels,1),tbl/2);
Xtrain = string(XTrain.Labels(idx));
Ytrain = string(YTrain.Labels(idx));
XValidation = imageDatastore(fullfile(rootFolder,Xtrain),'LabelSource','foldernames');
YValidation =imageDatastore(fullfile(rootFolder,Ytrain),'LabelSource','foldernames');
Xaugvalidation = augmentedImageDatastore(image_size,XValidation);
Yaugvalidation = augmentedImageDatastore(image_size,YValidation);
net = network;
layers=[
imageInputLayer([224 224 3])
convolution2dLayer(24,8,'stride',1)
batchNormalizationLayer
clippedReluLayer(10)
maxPooling2dLayer(2,'Stride',2)
convolution2dLayer(12,16,'stride',1)
batchNormalizationLayer
clippedReluLayer(10)
maxPooling2dLayer(2,'Stride',2)
convolution2dLayer(6,32,'stride',1)
batchNormalizationLayer
clippedReluLayer(10)
maxPooling2dLayer(2,'Stride',2)
convolution2dLayer(3,64,'stride',1)
batchNormalizationLayer
clippedReluLayer(10)
maxPooling2dLayer(2,'Stride',2)
fullyConnectedLayer(5)
softmaxLayer
classificationLayer ];
options = trainingOptions('adam',....
'Shuffle','every-epoch',...
'MaxEpochs',100, ...
'ValidationData',{Xaugvalidation,Yaugvalidation}, ...
'Verbose',true,'ExecutionEnvironment' ,'gpu' ,...
'Plots','training-progress',...
'InitialLearnRate',.003)
net = trainNetwork(augimds,layers,options);
analyzeNetwork(net)
YPred = classify(net,imds);
accuracy = sum(YPred == test_labels)/numel(test_labels)*100;
for i=1:3
[file,path] = uigetfile('*.*');
if isequal(file,0)
disp('User selected Cancel');
else
disp(['User selected ', fullfile(path,file)]);
end
newImage = fullfile(path,file);
nimds = imageDatastore(newImage);
augimage = augmentedImageDatastore(image_size,nimds);
predicted_image = classify(net,augimage);
h=waitbar(1,sprintf("The loaded image belongs to %s class ",predicted_image));
newImage = imread(newImage);
Hard_exucates(newImage);
bloodVessels=VesselExtract( newImage);
figure;
imshow(bloodVessels);title('Extracted Blood Vessels');
end

3 Kommentare

Cam Salzberger
Cam Salzberger am 24 Jul. 2020
I would suggest more details on what you are trying to do, what products you are using, and what the issue is. See here for good suggestions.
Image Analyst
Image Analyst am 24 Jul. 2020
Looks normal, as expected. At some point, now matter how long it tries to tweak the weights, it just won't get any better. You can probably quit after 2 or 3 hundred iterations.
utpal bhowmik
utpal bhowmik am 25 Jul. 2020
so i don't get more than 90% validation accuracy ???

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Deep Learning Toolbox finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2018a

Tags

Gefragt:

am 24 Jul. 2020

Kommentiert:

am 25 Jul. 2020

Community Treasure Hunt

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

Start Hunting!

Translated by