I am trying to use a different data for my Validation and it is saying that: Training and validation responses must have the same categories. To view the categories of the res
    11 ビュー (過去 30 日間)
  
       古いコメントを表示
    
myfolder = 'C:\Users\Myname\Downloads\fall dataset\rgb';
dataDir = fullfile(myfolder);
imdir = fullfile(dataDir);
myfolder2 = 'C:\Users\Myname\Downloads\Validation';
dataDir2 = fullfile(myfolder2);
imdir2 = fullfile(dataDir2);
imds = imageDatastore(imdir, "IncludeSubfolders",true ,"LabelSource","foldernames");
imds2 = imageDatastore(imdir2,"IncludeSubfolders",true,"LabelSource","foldernames");
numTrainfiles =5172;
numValidfiles = 6598;
[imdsTrain] = splitEachLabel(imds,numTrainfiles,'randomized');
[imdsValidation] = splitEachLabel(imds2,numValidfiles,'randomized');
%definingarchitecture
inputSize = [ 240 320 3];
numClasses = numel(categories(imdsTrain.Labels));
numClasses2 = numel(categories(imdsValidation.Labels));
layers = [
    imageInputLayer(inputSize)
    convolution2dLayer(5,20)
    batchNormalizationLayer
    reluLayer
    fullyConnectedLayer(numClasses)
    softmaxLayer
    classificationLayer];
%trainetwork
options = trainingOptions('sgdm', ...
    'MaxEpochs',4, ...
    'MiniBatchSize',64,...
    'ValidationData',imdsValidation, ...
    'ValidationFrequency',30, ...
    'Verbose',false, ...
    'Plots','training-progress');
net = trainNetwork(imdsTrain,layers,options);
YPred = classify(net,imdsValidation);
yvalidation = imdsValidation.Labels;
accuracy = mean(Ypred == yvalidation);
0 件のコメント
採用された回答
  Philip Brown
    
 2021 年 11 月 25 日
        It's likely that your training and validation folders contain different folder names, and those are being used as the class labels. For example, your training set has labels A, B, and C, but your validation set has labels A, B and D. This means your network never learns to classify into class D during training.
0 件のコメント
その他の回答 (0 件)
参考
カテゴリ
				Help Center および File Exchange で Deep Learning Toolbox についてさらに検索
			
	Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

