The value of 'ValidationData' is invalid. Validation data must be a table, a datastore, or a cell array with input data and responses.
20 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
sun rise
el 6 de En. de 2022
Comentada: 源
el 29 de Mzo. de 2023
clear;clc;close all
% Load the Image Dataset of Normal and Malignant WBC
imdsTrain = imageDatastore('D:\Project\DB1\train','IncludeSubfolders',true,'LabelSource','foldernames');
imdsTest = imageDatastore('D:\Project\DB1\test','IncludeSubfolders',true,'LabelSource','foldernames');
%Perform Cross-Validation using Hold-out method with a percentage split of 70% training and 30% testing
%[imdsTrain,imdsValidation] = splitEachLabel(imds,0.7,'randomized');
%%
%%
for i=1:numel(imdsTrain.Files)
a=[imdsTrain.Files(i)];
a = imread(char(a));
a = imresize(a,[299 299]);
end
a1=a;
for i=1:numel(imdsTest.Files)
a=[imdsTest.Files(i)];
a = imread(char(a));
a = imresize(a,[299 299]);
end
a2=a;
load('HW');
%%
%Select the Test images and save in Y_test
Y_test = imdsTest.Labels;
%%
% optimzation techniques selection and hyperparamter selection
options = trainingOptions('adam', ...
'MiniBatchSize',16, ...
'MaxEpochs',20, ...
'InitialLearnRate',1e-4, ...
'Shuffle','every-epoch', ...
'ValidationData',a2, ...
'ValidationFrequency',3, ...
'Verbose',false, ...
'Plots','training-progress');
%%
%CNN model training
netTransfer = trainNetwork(a1,HW,options);
%%
% for i=1:numel(imdsValidation.Files)
% a=[imdsValidation.Files(i)];
% a = imread(char(a));
% % featuresTest22 = activations(net,a,layer,'OutputAs','rows');
% YPred(i) = classify(netTransfer,a);
% imshow(a),title(char(YPred));
% i
% end
%%
% CNN Model validation
YPred = classify(netTransfer,a2);
%Performance evaluation of Deep Learning Trained Model
plotconfusion(Y_test,YPred)
Error using trainingOptions (line 269)
The value of 'ValidationData' is invalid. Validation data must be a table, a datastore, or a cell array
with input data and responses.
Error in cnn (line 32)
options = trainingOptions('adam', ...
>>
1 comentario
源
el 29 de Mzo. de 2023
Dear sun rise,
Would you solve this problem yet? If possible, could you tell me how to solve it.I have the same problem as you.
Thanks for your help
Respuesta aceptada
Walter Roberson
el 6 de En. de 2022
for i=1:numel(imdsTrain.Files)
a=[imdsTrain.Files(i)];
a = imread(char(a));
a = imresize(a,[299 299]);
end
a1=a;
for i=1:numel(imdsTest.Files)
a=[imdsTest.Files(i)];
a = imread(char(a));
a = imresize(a,[299 299]);
end
In those two loops, you process each of a number of files, but you throw away the result of the processing as soon as you start the next loop iteration.
You should consider either using a custom read function for your datastore, or else use a transform store; https://www.mathworks.com/help/matlab/ref/matlab.io.datastore.transform.html
'ValidationData',a2, ...
Your a2 is the result of transforming the very last of your test files only
Use a transform store.
2 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Image Data Workflows en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!