I am getting: Error using nnet.inter​nal.cnn.ut​il.Network​DataValida​tor/assert​CorrectRes​ponseSizeF​orOutputLa​yer (line 285) Invalid validation data. The output size (118) of the last layer doesn't match the number of classes (79).How to match??

unzip('Character-Dataset.zip'); characterds = imageDatastore('Character-Dataset','IncludeSubfolders',true,'LabelSource','foldernames'); [characterdsTrain,characterdsValidation] = splitEachLabel(characterds,0.7,'randomized'); numTrainImages = numel(characterdsTrain.Labels); idx = randperm(numTrainImages,16); figure for i = 1:16 subplot(4,4,i) I = readimage(characterdsTrain,idx(i)); imshow(I) end net = alexnet; layersTransfer = net.Layers(1:end-3); numClasses = numel(categories(characterdsTrain.Labels)) layers = [ layersTransfer fullyConnectedLayer(numClasses,'WeightLearnRateFactor',20,'BiasLearnRateFactor',20) softmaxLayer classificationLayer]; pixelRange = [-30 30]; imageAugmenter = imageDataAugmenter( ... 'RandXReflection',true, ... 'RandXTranslation',pixelRange, ... 'RandYTranslation',pixelRange); augimdsTrain = augmentedImageDatastore(inputSize(1:2),characterdsTrain, ... 'DataAugmentation',imageAugmenter); augimdsValidation = augmentedImageDatastore(inputSize(1:2),characterdsValidation); options = trainingOptions('sgdm', ... 'MiniBatchSize',10, ... 'MaxEpochs',6, ... 'InitialLearnRate',1e-4, ... 'ValidationData',augimdsValidation, ... 'ValidationFrequency',3, ... 'ValidationPatience',Inf, ... 'Verbose',false, ... 'Plots','training-progress'); netTransfer = trainNetwork(augimdsTrain,layers,options);

답변 (0개)

카테고리

도움말 센터File Exchange에서 Downloads에 대해 자세히 알아보기

제품

질문:

2018년 5월 18일

Community Treasure Hunt

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

Start Hunting!

Translated by