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?