Borrar filtros
Borrar filtros

Is it possible to use pretrained network like alexnet with a new dataset that has different category?

3 visualizaciones (últimos 30 días)
I used alexnet with a dataset which it is categores {1-50,51-100, 101- ...}. is this possible?
if yes, why I get this error?
Error using trainNetwork (line 150)
Training and validation data must have the same labels.
Error in AlexNet_ex_density (line 114)
netTransfer = trainNetwork(augimdsTrain,layers,options);
Caused by:
Error using trainNetwork>iAssertClassNamesAreTheSame (line 376)
Training and validation data must have the same labels.
I used
[imdsTrain,imdsValidation] = splitEachLabel(imds,0.7,'randomized');
% Create augmentedImageDatastore from training and test sets to resize
% images in imds to the size required by the network.
imageSize = net.Layers(1).InputSize;
augmentedTrainingSet = augmentedImageDatastore(imageSize, imdsTrain, 'ColorPreprocessing',...
augmentedTestSet = augmentedImageDatastore(imageSize, imdsTest, 'ColorPreprocessing', 'gray2rgb',...
augimdsValidation = augmentedImageDatastore(imageSize, imdsValidation, 'ColorPreprocessing',...
and in options of the network I used
'ValidationData',augimdsValidation, ...
'ValidationFrequency',3, ...
then I uesd
netTransfer = trainNetwork(augimdsTrain,layers,options);
I got the error in above sentince.

Respuestas (1)

Mahmoud Afifi
Mahmoud Afifi el 6 de En. de 2020
You need to change the last fully connected layer of Alexnet with a new one with the same number of expected output (either for regression or number of classes for classification).;jsessionid=82bda7d7b633139e3e0a8f6e685d


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

Community Treasure Hunt

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

Start Hunting!

Translated by