Error using classreg.learning.FullClassificationRegressionModel.prepareDataCR (line 192) X must be a numeric matrix.
20 views (last 30 days)
Show older comments
I am working on a deep learning Matlab simulation, this is my code:
********************************************
clear all
clc
% Load Alexnet for CNN convnet = alexnet;
% Setup training data
rootFolder = 'photo';
categories ={'BigSmile','Smile','Neutral'};
imds = imageDatastore(fullfile(rootFolder, categories), 'LabelSource', 'foldernames');
[imdsTrain, imdsTest] = splitEachLabel(imds, 0.8, 'randomize');
imageSize = [277 277 3]; augimdsTrain = augmentedImageDatastore(imageSize(1:2), imdsTrain, 'ColorPreprocessing', 'gray2rgb');
augimdsTest = augmentedImageDatastore(imageSize(1:2),imdsTest, 'ColorPreprocessing', 'gray2rgb');
% Extract features from the training images layer = 'fc7';
featuresTrain = activations(convnet,augimdsTrain,layer, 'OutputAs', 'channels');
featuresTest = activations(convnet,augimdsTest,layer, 'OutputAs', 'channels');
YTrain = imdsTrain.Labels;
YTest = imdsTest.Labels;
% Train the SVM classifier classifier = fitcecoc(featuresTrain,YTrain);
YPred = predict(classifier,featuresTest);
accuracy = mean(YPred == YTest);
**********************************************
I got an error: Error using classreg.learning.FullClassificationRegressionModel.prepareDataCR (line 192) X must be a numeric matrix. Error in example2 (line 44) classifier = fitcecoc(featuresTrain,YTrain);
why do I get this error and how should I fix it?
0 Comments
Answers (1)
See Also
Categories
Find more on Image Data Workflows in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!