classification using CNN (trainNetwork)

2 次查看(过去 30 天)
Toqa Am
Toqa Am 2019-11-20
Why the validation accuracy of CNN using trainNetwork has been change in each rerun. It has been decreased from 89% to 39% in each re run the program.
Please could anyone answer me???
close all, clear all, clc;
output_folder=fullfile('datasets - Copy (2)','REMBRANDT') ; %creat file path
categories={'Grade_II - Copy','Grade_III - Copy','Grade_IV - Copy'};
imds=imageDatastore((fullfile(output_folder,categories)),'FileExtensions','.dcm','ReadFcn',@(x) dicomread(x),'LabelSource','foldernames');
[trainingset, testset]=splitEachLabel(imds, 0.8,0.2);
labelCount = countEachLabel(imds);
rng(1);
layers = [
imageInputLayer([128 128 1])
convolution2dLayer(3,8,'Padding','same')
batchNormalizationLayer
reluLayer
maxPooling2dLayer(1,'Stride',1)
convolution2dLayer(3,16,'Padding','same')
batchNormalizationLayer
reluLayer
maxPooling2dLayer(1,'Stride',1)
convolution2dLayer(3,32,'Padding','same')
batchNormalizationLayer
reluLayer
fullyConnectedLayer(3)
dropoutLayer
softmaxLayer
classificationLayer];
options = trainingOptions('sgdm', ...
'InitialLearnRate',0.01, ...
'MaxEpochs',40, ...
'Shuffle','every-epoch', ...
'ValidationData',testset, ...
'ValidationFrequency',60, ...
'Verbose',false, ...
'Plots','training-progress');
net = trainNetwork(trainingset,layers,options);

回答(0 个)

Community Treasure Hunt

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

Start Hunting!

Translated by