Error using matlab.io.datastore.ImageDatastore/horzcat 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 scalar
Show older comments
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);
Answers (1)
Swetha Polemoni
on 20 Apr 2021
0 votes
Hi
Categories
Find more on Image Category Classification in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!