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

4 views (last 30 days)
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;
layers = [imageInputLayer([64 128 3]);
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);
accuracyn{i} = sum(pred{i} == TTest)/numel(TTest)

Answers (0)

Community Treasure Hunt

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

Start Hunting!