I am getting 0 percent accuracy when using 3-fold cross validation

조회 수: 2 (최근 30일)
user06
user06 2019년 2월 27일
편집: user06 2019년 2월 27일
I want to train a CNN that will be k-fold cross-validated. for that, I have divided my signature data set in three equal part. using the two parts training is happening and from the remaining part, testing will be performed. this process will be done three times as k=3. I am using 3-fold cross validation in Matlab. but when I test the network it is giving 0% accuracy how it can be possible. can someone please help me what is the mistake I am making?
k = 3; % number of folds
datastore = imageDatastore(fullfile('/media/titan/ACER DATA/GPDS300'), 'IncludeSubfolders', true, 'LabelSource', 'foldernames');
partStores{k} = [];
for i = 1:k
temp = partition(datastore, k, i);
partStores{i} = temp.Files;
end
layers = [imageInputLayer([64 128 3]);
convolution2dLayer(7,40);
reluLayer();
fullyConnectedLayer(200);
softmaxLayer();
classificationLayer()];
options = trainingOptions('sgdm','MaxEpochs',150,'minibatchsize',32,'InitialLearnRate',0.001);
for i = 1:k
test_idx = (idx == i);
train_idx = ~test_idx;
test_Store = imageDatastore(partStores{test_idx}, 'IncludeSubfolders', true,
'LabelSource', 'foldernames');
train_Store = imageDatastore(cat(1, partStores{train_idx}),
'IncludeSubfolders', true, 'LabelSource', 'foldernames');
net{i} = trainNetwork(train_Store, layers, options);
pred{i} = classify(net{i}, test_Store);
TTest=test_Store.Labels;
accuracyn{i} = sum(pred{i} == TTest)/numel(TTest)
end

답변 (0개)

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by