필터 지우기
필터 지우기

Invalid training data. X must be a 4-D array of images, an ImageDatastore, or a table.

조회 수: 2 (최근 30일)
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));
a1 = imresize(a,[299 299]);
end
for i=1:numel(imdsTest.Files)
a=[imdsTest.Files(i)];
a = imread(char(a));
a2 = imresize(a,[299 299]);
end
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,Y_test}, ...
'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 trainNetwork (line 165)
Invalid training data. X must be a 4-D array of images, an ImageDatastore, or a table.
Error in cnn (line 41)
netTransfer = trainNetwork(a1,HW,options);
  댓글 수: 3

댓글을 달려면 로그인하십시오.

답변 (0개)

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by