Invalid training data. The output size (2) of the last layer does not match the number of classes (6).
18 次查看(过去 30 天)
显示 更早的评论
% TRAIN THE IMAGE
layers =[imageInputLayer([90 120 1])
%CONVOLUTION FILTER
convolution2dLayer(5,20)
reluLayer
%GET MAXIMUM VALUE FROM LAYER
maxPooling2dLayer(2,'stride',2)
%CONVOLUTION FILTER
convolution2dLayer(5,20)
reluLayer
%GET MAXIMUM VALUE FROM LAYER
maxPooling2dLayer(2,'stride',2)
fullyConnectedLayer(2)
softmaxLayer
classificationLayer()]
%% CLASSIFICATION
im = imresize(im,[90,120]);
options=trainingOptions('sgdm','MaxEpochs',15,'initialLearnRate',0.0001);
convnet=trainNetwork(Data,layers,options);
output=classify(convnet,im);
tf1=[];
for ii=1:2
st=int2str(ii);
tf=ismember(output,st);
tf1=[tf1 tf];
end
output=find(tf1==1);
0 个评论
回答(1 个)
Athul Prakash
2020-10-20
Hi Aswin,
The number of outputs from your network would be determined by the last fullyConnectedLayer you have used. Since it has 2 neurons, the final output from the classificationLayer would also have 2.
If you want to classify into 6 categories, you may use fullyConnectedLayer(6) instead.
Hope it helps!
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!