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);

4 件のコメント

Jan
Jan 2021 年 3 月 18 日
"they say that the size of the training images is not the same as the size that the input layer expects" - please post a copy of the error message.
What do you expect this line to do:
Flowers ='C:\Users\hind';'deeplearning_course_files';'Flowers';
You create the char vectors 'deeplearning_course_files' and 'Flowers' and assign it to nothing.
Hind Haboubi
Hind Haboubi 2021 年 3 月 18 日
Thank you for your response.
Flowers ='C:\Users\hind';'deeplearning_course_files';'Flowers';
is for imagedatastore, I couldn't do it without this ligne.
Can you correct me please
Jan
Jan 2021 年 3 月 19 日
The line
Flowers ='C:\Users\hind';'deeplearning_course_files';'Flowers';
does exactly the same as:
Flowers ='C:\Users\hind';
Do you mean:
Flowers = 'C:\Users\hind\deeplearning_course_files\Flowers';
Hind Haboubi
Hind Haboubi 2021 年 3 月 19 日
thank you, I'll try it

サインインしてコメントする。

 採用された回答

Srivardhan Gadila
Srivardhan Gadila 2021 年 3 月 22 日

0 投票

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);
to
[flowernet,info] = trainNetwork(auds, lgraph, options);

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeDeep Learning Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by