Error using classreg.l​earning.Fu​llClassifi​cationRegr​essionMode​l.prepareD​ataCR (line 192) X must be a numeric matrix.

15 Ansichten (letzte 30 Tage)
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?

Antworten (1)

Khadije El Zein
Khadije El Zein am 27 Jun. 2018
change 'OutputAs', 'channels' to 'OutputAs', 'rows'. worked for me.

Kategorien

Mehr zu Deep Learning Toolbox finden Sie in Help Center und File Exchange

Produkte


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by