unrecognized method property or field Labels for class augmentdatastore?
Mostrar comentarios más antiguos
I am tring to train the model on .mat dataset. i have train the model sucessfully but when i tried to find the accuracy i got the error.
imds = imageDatastore('D:\yellow\img-data\iqmat\', 'FileExtensions', '.mat', 'IncludeSubfolders',true, ...
'LabelSource','foldernames',...
'ReadFcn',@matReader);
[imdsTrain,imdsValidation] = splitEachLabel(imds,0.7, 'randomized');
inputSize = lgraph_1.Layers(1).InputSize;
[learnableLayer,classLayer] = findLayersToReplace(lgraph_1);
numClasses = numel(categories(imdsTrain.Labels));
if isa(learnableLayer,'nnet.cnn.layer.FullyConnectedLayer')
newLearnableLayer = fullyConnectedLayer(numClasses, ...
'Name','new_fc', ...
'WeightLearnRateFactor',10, ...
'BiasLearnRateFactor',10);
elseif isa(learnableLayer,'nnet.cnn.layer.Convolution2DLayer')
newLearnableLayer = convolution2dLayer(1,numClasses, ...
'Name','new_conv', ...
'WeightLearnRateFactor',10, ...
'BiasLearnRateFactor',10);
end
lgraph_1 = replaceLayer(lgraph_1,learnableLayer.Name,newLearnableLayer);
newClassLayer = classificationLayer('Name','new_classoutput');
lgraph_1 = replaceLayer(lgraph_1,classLayer.Name,newClassLayer);
imdsTrain = augmentedImageDatastore([224,224],imdsTrain);
imdsValidation = augmentedImageDatastore([224,224],imdsValidation);
miniBatchSize =8;
valFrequency = floor(numel(imdsTrain.Files)/miniBatchSize);
checkpointPath = pwd;
options = trainingOptions('sgdm', ...
'MiniBatchSize',miniBatchSize, ...
'MaxEpochs',100, ...
'InitialLearnRate',1e-4, ...
'Shuffle','every-epoch', ...
'ValidationData',imdsValidation, ...
'ValidationFrequency',valFrequency, ...
'Verbose',false, ...
'Plots','training-progress', ...
'CheckpointPath',checkpointPath,...
'ExecutionEnvironment','gpu');
net = trainNetwork(imdsTrain,lgraph_1,options);
[YPred,probs] = classify(net,imdsValidation);
accuracy = mean(YPred == imdsValidation.Labels)
error:
unrecognized method property or field Labels for class augmentdatastore
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Parallel and Cloud en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!