添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接
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?

Community Treasure Hunt

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

Start Hunting!