Current learning AlexNet Deep Learning, I am pretty sure my image size are correct but it seems that it doesn't acknowledge it.

1 visualizzazione (ultimi 30 giorni)
The code:
alex = alexnet;
layers = alex.Layers;
layers(23) = fullyConnectedLayer(3);
layers(25) = classificationLayer;
allImages = imageDatastore('common weed images','IncludeSubfolders',true,'LabelSource','foldernames');
[trainingImages, testImages] = splitEachLabel(allImages,0.8,'randomized');
opts = trainingOptions("sgdm",'InitialLearnRate', 0.001 ,'MaxEpochs', 30,'MiniBatchSize', 64);
myNet = trainNetwork(trainingImages, layers, opts);
The ERROR:
Error using trainNetwork
The training images are of size 277×277×3 but the input layer expects images of size 227×227×3.
Error in transferLearning (line 18)
myNet = trainNetwork(trainingImages, layers, opts);
Tried using with augmentedimagedatastore:
alex = alexnet;
layers = alex.Layers;
layers(23) = fullyConnectedLayer(3);
layers(25) = classificationLayer;
allImages = imageDatastore('common weed images','IncludeSubfolders',true,'LabelSource','foldernames');
[trainingImages, testImages] = splitEachLabel(allImages,0.8,'randomized');
trainingImages = augmentedImageDatastore([277 277],trainingImages)
testImages = augmentedImageDatastore([277 277],testImages)
opts = trainingOptions('sgdm', 'InitialLearnRate', 0.001,...
'MaxEpochs', 1, 'MiniBatchSize', 1);
myNet = trainNetwork(trainingImages, layers, opts);
Still has the same ERROR:
Error using trainNetwork
The training images are of size 277×277×3 but the input layer expects images of size 227×227×3.
Error in transferLearning (line 18)
myNet = trainNetwork(trainingImages, layers, opts);

Risposte (1)

Walter Roberson
Walter Roberson il 14 Set 2022
Notice 277 compared to 227.
I suggest that you use an augmentedDatastore to implement automatic resizing to 227
  3 Commenti
Charlene Rabulan
Charlene Rabulan il 14 Set 2022
I currently edited my code above. Is it alright if you check that I did it correctly?
It is still showing the same error though if I ever did it correctly

Accedi per commentare.

Categorie

Scopri di più su Image Data Workflows in Help Center e File Exchange

Prodotti


Release

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by