Array formation and parentheses-style indexing with objects of class 'matlab.io​.datastore​.ImageData​store' is not allowed. Use objects of class 'matlab.io​.datastore​.ImageData​store' only as scalars or use a cell array. Error in Untitled9 (line 30)

12 ビュー (過去 30 日間)
Hi, I just started using Matlab. That's why I got the following error and I don't know what to do. I will be glad if you can help.
Array formation and parentheses-style indexing with objects of class
'matlab.io.datastore.ImageDatastore' is not allowed. Use objects of class
'matlab.io.datastore.ImageDatastore' only as scalars or use a cell array.
Error in Untitled9 (line 30)
test_data = data(test, 1 : data_c - 1);
code:
layers = [
imageInputLayer([115 115 3],"Name","imageinput")
convolution2dLayer([3 3],32,"Name","conv_1","Padding","same")
maxPooling2dLayer([5 5],"Name","maxpool_1","Padding","same")
reluLayer("Name","relu_1")
convolution2dLayer([3 3],32,"Name","conv_2","Padding","same")
maxPooling2dLayer([5 5],"Name","maxpool_2","Padding","same")
reluLayer("Name","relu_2")
fullyConnectedLayer(17,"Name","fc")
dropoutLayer(0.5,"Name","dropout")
softmaxLayer("Name","softmax")
classificationLayer("Name","classoutput")];
% Import Data
data=imageDatastore('Images','IncludeSubfolders',true,'LabelSource','foldernames');
%data = load('C:\Users\EMYO\Desktop\cnn matlab deneme\Images');
% [trainingImages,testImages]== size[data];
% [trainingImages,testImages]=splitEachLabel(data,0.8,'randomized');
[data_r, data_c] = size(data);
% randomly divides the data sample into 10 parts
indices = crossvalind('Kfold', data_r, 10);
for i = 1 : 10
% Get the index logical value of the i-th test data
test = (indices == i);
% inversion, get the index logical value of the i-th training data
train = ~test;
%1 test, 9 training
test_data = data(test, 1 : data_c - 1);
test_label = data(test, data_c);
train_data = data(train, 1 : data_c - 1);
train_label = data(train, data_c);
% code using data
options = trainingOptions('adam', ...
'MiniBatchSize',10, ...
'MaxEpochs',6, ...
'InitialLearnRate',1e-4, ...
'Plots','training-progress');%Burası ağın öğrenmesi ile ilgili
mynet = trainNetwork(data_r,layers,options);%Burda ağ eğitiliyor.
Pred = classify(mynet,data_c);% Burda ağı test ediyor
end
accuricy=mean(Pred==testImages.Labels)

採用された回答

Walter Roberson
Walter Roberson 2021 年 2 月 28 日
編集済み: Walter Roberson 2022 年 11 月 18 日
You are trying to index a datastore. Instead you need to create new datastore from indexing the file names.

その他の回答 (0 件)

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by