Is it possible to use pretrained network like alexnet with a new dataset that has different category?
조회 수: 1 (최근 30일)
이전 댓글 표시
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',...
'gray2rgb','DataAugmentation',imageAugmenter);
augmentedTestSet = augmentedImageDatastore(imageSize, imdsTest, 'ColorPreprocessing', 'gray2rgb',...
'DataAugmentation',imageAugmenter);
augimdsValidation = augmentedImageDatastore(imageSize, imdsValidation, 'ColorPreprocessing',...
'gray2rgb','DataAugmentation',imageAugmenter);
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.
댓글 수: 0
답변 (1개)
Mahmoud Afifi
2020년 1월 6일
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).
https://www.mathworks.com/help/deeplearning/examples/transfer-learning-using-alexnet.html;jsessionid=82bda7d7b633139e3e0a8f6e685d
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Image Data Workflows에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!