How can i fix this error?

4 views (last 30 days)
Hind Haboubi
Hind Haboubi on 18 Mar 2021
Answered: Srivardhan Gadila on 22 Mar 2021
Hello, i have a problem with the size of the training data. i've done the augmentedImageDatastore function to fix it but when i do the trainNetwork function they say that the size of the training images is not the same as the size that the input layer expects. How can i fix this error? Here is my code
Flowers ='C:\Users\hind';'deeplearning_course_files';'Flowers';
flowerds = imageDatastore(Flowers,"IncludeSubfolders",true,"LabelSource","foldernames");
[trainImgs,testImgs] = splitEachLabel(flowerds,0.6);
numClasses = numel(categories(flowerds.Labels));
net = googlenet;
lgraph = layerGraph(net);
newFc = fullyConnectedLayer(12,"Name","new_fc");
lgraph = replaceLayer(lgraph,"loss3-classifier",newFc);
newOut = classificationLayer("Name","new_out");
lgraph = replaceLayer(lgraph,"output",newOut);
options = trainingOptions("sgdm","InitialLearnRate", 0.001);
auds = augmentedImageDatastore([224 224],flowerds,"ColorPreprocessing","gray2rgb");
[flowernet,info] = trainNetwork(trainImgs, lgraph, options);
Hind Haboubi
Hind Haboubi on 19 Mar 2021
thank you, I'll try it

Sign in to comment.

Accepted Answer

Srivardhan Gadila
Srivardhan Gadila on 22 Mar 2021
Even though you are creating a "auds" augmentedImageDatastore object, you are not using it to train your network. Change the line
[flowernet,info] = trainNetwork(trainImgs, lgraph, options);
[flowernet,info] = trainNetwork(auds, lgraph, options);

More Answers (0)

Community Treasure Hunt

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

Start Hunting!