Error using matlab.io.​datastore.​ImageDatas​tore/horzc​at 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 scalar

1 回表示 (過去 30 日間)
How to solve this error
clc; clear all; close all
digitDatasetPath = fullfile('Dataset Rahma')
imds = imageDatastore(digitDatasetPath, ...
'IncludeSubfolders',true, ...
'LabelSource','foldernames');
tbl = countEachLabel(imds);
minSetCount = min(tbl{:,2});
imds = splitEachLabel(imds, minSetCount, 'randomized')
countEachLabel(imds);
[trainingSet, testSet] = splitEachLabel(imds, 0.3,'randomize');
imageSize = [224 224 3];
% auimds = augmentedImageDatastore(ImageSize,imds);
augmentedTrainingSet= augmentedImageDatastore(imageSize,...
trainingSet, 'ColorPreprocessing','gray2rgb');
%To convert and resize any gray scale image to RGB
augmentedTestSet= augmentedImageDatastore(imageSize,...
testSet, 'ColorPreprocessing','gray2rgb');
encodingLayers = [ ...
convolution2dLayer(3,16,'Padding','same'), ...
reluLayer, ...
maxPooling2dLayer(2,'Padding','same','Stride',2), ...
convolution2dLayer(3,8,'Padding','same'), ...
reluLayer, ...
maxPooling2dLayer(2,'Padding','same','Stride',2), ...
convolution2dLayer(3,8,'Padding','same'), ...
reluLayer, ...
maxPooling2dLayer(2,'Padding','same','Stride',2)];
decodingLayers = [ ...
createUpsampleTransponseConvLayer(2,8), ...
reluLayer, ...
createUpsampleTransponseConvLayer(2,8), ...
reluLayer, ...
createUpsampleTransponseConvLayer(2,16), ...
reluLayer, ...
convolution2dLayer(3,1,'Padding','same'), ...
clippedReluLayer(1.0), ...
regressionLayer];
options = trainingOptions('adam', ...
'MaxEpochs',100, ...
'MiniBatchSize',imds.ReadSize, ...
'Plots','training-progress', ...
'Verbose',false);
layers = [imds,encodingLayers,decodingLayers,options];
net = trainNetwork(imds,layers,options);

回答 (1 件)

Swetha Polemoni
Swetha Polemoni 2021 年 4 月 20 日
Hi
You may find this Matlab answer helpful.

カテゴリ

Help Center および File ExchangeDescriptive Statistics についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by