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

7 次查看(过去 30 天)
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)

采纳的回答

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

更多回答(1 个)

abdulkader helwan
abdulkader helwan 2017-12-25
Hello.. i am having the same problem here. could u please tell me how u solved it if u did so. thanks
  4 个评论
nima aalizade
nima aalizade 2018-2-16
编辑:nima aalizade 2018-2-16
hello
for using SegNet, you most have pixel labeled data with image labeler. you can use this and this example to understand better.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Convert Image Type 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by