No appropriate method, property, or field 'Lables' for class 'matlab.io​.datastore​.ImageData​store'.

6 views (last 30 days)
I am trying to classify two class of images with resnet-50 in deep learning and getting an error 'No appropriate method, property, or field 'Lables' for class 'matlab.io.datastore.ImageDatastore'..
Can anyone help. This is my code
clc
%%Image Folder%%
outputFolder = fullfile('input folder');
rootFolder = fullfile(outputFolder, 'CNN_Class');
categories = {'a','b'};
%%Datastore for storing the images%%
imds = imageDatastore(fullfile(rootFolder, categories),'LabelSource', 'foldernames');
tbl=countEachLabel(imds);
minSetcount=min(tbl{:,2});
imds=splitEachLabel(imds,minSetcount,'randomize');
countEachLabel(imds);
net=resnet50();
set(gca,'YLim',[150 170]);
net.Layers(1);
net.Layers(end);
numel(net.Layers(end).ClassNames);
%%Split into Training and Testing set%%
[trainingSet,testSet] = splitEachLabel(imds,0.8,'randomized');
imageSize=(net.Layers(1).InputSize);
augmentedTrainingset=augmentedImageDatastore(imageSize,trainingSet);
augmentedTestset=augmentedImageDatastore(imageSize,testSet);
w1=net.Layers(2).Weights;
w1=mat2gray(w1);
% figure
%montage(w1)
title('First Convolution Layer Weight')
featureLayer='fc1000';
trainingFeatures=activations(net,augmentedTrainingset,...
featureLayer,'MiniBatchSize',32,'OutputAs','Columns');
trainingLabels=trainingSet.Labels;
Classifier=fitcecoc(trainingFeatures,trainingLabels,...
'Learner','Linear','Coding','onevsall','ObservationsIn','Columns');
testFeatures=activations(net,augmentedTestset,...
featureLayer,'MiniBatchSize',32,'OutputAs','Columns');
predictLabels=predict(Classifier,testFeatures,'ObservationsIn','Columns');
testLables=testSet.Lables;
confMat=confusionmat(testLables,predictLables);
confMat=bsxfun(@rdivide,confMat,sum(confMat,2));
mean(diag(confMat))

Accepted Answer

dpb
dpb on 22 Dec 2019
It's spelled "labels", not "lables"
testLabeles=testSet.Lables;
should be
testLabels=testSet.Labels;
Of course, let the auto-correct feature fix the other places it can and manually correct the other places as well. Judicious use of the text substitution can help typing here.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!