Borrar filtros
Borrar filtros

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

1 visualización (últimos 30 días)
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);

Respuestas (1)

Walter Roberson
Walter Roberson el 14 de Sept. de 2022
Notice 277 compared to 227.
I suggest that you use an augmentedDatastore to implement automatic resizing to 227
  3 comentarios
Walter Roberson
Walter Roberson el 14 de Sept. de 2022
An augmented store works like a filter on the image data store. You augment the image store.
Charlene Rabulan
Charlene Rabulan el 14 de Sept. de 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

Iniciar sesión para comentar.

Categorías

Más información sobre Image Data Workflows en Help Center y File Exchange.

Productos


Versión

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by