ディープラーニングでの評価

23 visualizzazioni (ultimi 30 giorni)
大空
大空 il 28 Giu 2022
Commentato: 大空 il 29 Giu 2022
エラーの意味が分からなくまたなぜエラーが出ているのかわかりりません
クラス 'augmentedImageDatastore' のメソッド、プロパティまたはフィール
ド 'Labels' が認識されません。
このようなエラーがでました。
%% 画像読み込み
imds = imageDatastore('catdog','IncludeSubfolders',true,'LabelSource','foldernames');
labelCount = countEachLabel(imds)
%% データで振り分ける
rateTrainFiles = 0.6;
[imdsTrain,imdsValidation] = splitEachLabel(imds,rateTrainFiles,'randomize');
s_image = [256,256,3];
imdsTrain = augmentedImageDatastore(s_image,imdsTrain);
imdsValidation = augmentedImageDatastore(s_image,imdsValidation);
%%DNN
layers = [
imageInputLayer(s_image)
%% 特徴抽出
convolution2dLayer(3,8,'Padding','same')
batchNormalizationLayer
reluLayer
maxPooling2dLayer(2,'Stride',2)
convolution2dLayer(3,16,'Padding','same')
batchNormalizationLayer
reluLayer
maxPooling2dLayer(2,'Stride',2)
convolution2dLayer(3,32,'Padding','same')
batchNormalizationLayer
reluLayer
fullyConnectedLayer(2)%クラスの数
softmaxLayer
classificationLayer];
options = trainingOptions('sgdm', ...
'InitialLearnRate',0.01,...
'MaxEpochs',4,...
'Shuffle','every-epoch',...
'ValidationData',imdsValidation,...
'VerboseFrequency',30,...
'Verbose',false, ...
'Plots','training-progress');
net = trainNetwork(imdsTrain,layers,options);
YPred = classify(net,imdsValidation);
クラス 'augmentedImageDatastore' のメソッド、プロパティまたはフィール
ド 'Labels' が認識されません。
YValidation = imdsValidation.Labels;
accuracy = sum(YPred == YValidation)/numel(YValidation)

Risposta accettata

Shunichi Kusano
Shunichi Kusano il 28 Giu 2022
9行目で imdsValidationaugmentedImageDatastore に上書きされていますが、augmentedImageDatastore にはimageDatastore とは違って Labels というフィールドがありません。なのでエラーとなっています。されたいことは上書き前のimdsValidation.Labels の中身を見たいということだと思いますので、9行目の
imdsValidation = augmentedImageDatastore(s_image,imdsValidation);
audsValidation = augmentedImageDatastore(s_image,imdsValidation);
等としてimdsValidationは残しておき、最後の3行を
YPred = classify(net,audsValidation);
YValidation = imdsValidation.Labels;
accuracy = sum(YPred == YValidation)/numel(YValidation)
でおそらく期待通りに動くかと思います。
  2 Commenti
大空
大空 il 29 Giu 2022
実行してみたのですがそれですと net = trainNetwork(imdsTrain,layers,options); でイメージエラーを起こしてしまいました
大空
大空 il 29 Giu 2022
出来ましたありがとうございます

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su イメージを使用した深層学習 in Help Center e File Exchange

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!