I am getting 0 percent accuracy when using 3-fold cross validation
조회 수: 2 (최근 30일)
이전 댓글 표시
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
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Logical에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!