我想训练一个经过k倍交叉验证的CNN。为此,我将签名数据集分为三个相等的部分。使用这两个部分进行培训,其余部分将进行测试。该过程将在k = 3的情况下执行三遍。 我在Matlab中使用3倍交叉验证。但是当我测试网络时,它给出了0%的准确度。有人可以帮我做错什么吗?
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