validation accuracy not increasing
显示 更早的评论
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 个评论
Cam Salzberger
2020-7-24
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
2020-7-24
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
2020-7-25
回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Deep Learning Toolbox 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!