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

16 visualizzazioni (ultimi 30 giorni)
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?

Risposte (1)

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

Categorie

Scopri di più su Deep Learning Toolbox in Help Center e File Exchange

Prodotti


Release

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by