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
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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);
0 Kommentare
Antworten (1)
Siehe auch
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!