MATLAB Answers

Invalid training data. The output size (5) of the last layer doesn't match the number of classes (5). How to match output size??

58 views (last 30 days)
net=vgg16();
imds = imageDatastore(fullfile('E:\','data','labels'),...
'IncludeSubfolders',true,'FileExtensions','.dcm','LabelSource','foldernames');
labelCount = countEachLabel(imds);
trainingNumFiles = 105;
rng(1) % For reproducibility
[trainData,testData] = splitEachLabel(imds,...
trainingNumFiles,'randomize');
imageSize = [512 512 1];
numClasses = 5;
encoderDepth = 9;
lgraph = segnetLayers(imageSize,numClasses,encoderDepth);
plot(lgraph)
options = trainingOptions('sgdm','InitialLearnRate',1e-3, ...
'MaxEpochs',50,'VerboseFrequency',10);
seg = trainNetwork(imds,lgraph,options)

  0 Comments

Sign in to comment.

Accepted Answer

nima aalizade
nima aalizade on 16 Feb 2018
Edited: nima aalizade on 16 Feb 2018
hello,
for using SegNet, you most have pixel labeled data with image labeler. you can use this and this example to understand better.

  0 Comments

Sign in to comment.

More Answers (1)

abdulkader helwan
abdulkader helwan on 25 Dec 2017
Hello.. i am having the same problem here. could u please tell me how u solved it if u did so. thanks

  4 Comments

Show 1 older comment
nima aalizade
nima aalizade on 16 Feb 2018
hello
for using SegNet, you most have pixel labeled data with image labeler. you can use this and this example to understand better.

Sign in to comment.