Error using trainNetwork (line 140)
The last layer must be an output layer.
Error in neural2 (line 93)
[sp, info] = trainNetwork(datasource,war.Layers,options);
Caused by:
Error using nnet.internal.cnn.layer.util.inferParameters (line 7)
The last layer must be an output layer.
imageSize = [227 227];
numClasses = numel(classes);
lgraph = fcnLayers(imageSize,numClasses,'type','16s');
st = fullfile('imade','checkPoint');
datasource = pixelLabelImageSource(imdsTrain,pxdsTrain);
doTraining = true;
if doTraining
options = trainingOptions('sgdm',...
'Plots','training-progress',...
'MiniBatchSize',1,...
'CheckpointPath', st,...
'Momentum',0.99,...
'InitialLearnRate', 1e-12,...
'L2Regularization',0.0005);
[net, info] = trainNetwork(datasource,lgraph,options);
else
options = trainingOptions('sgdm',...
'Plots','training-progress',...
'MaxEpochs',19, ...
'MiniBatchSize',1,...
'CheckpointPath', st,...
'Momentum',0.99,...
'InitialLearnRate', 1e-12,...
'L2Regularization',0.0005);
data = load (strcat(st,filesep,'convnet_checkpoint__4607__2018_01_27__21_25_03.mat'));
war = data.net;
[sp, info] = trainNetwork(datasource,war.Layers,options);
end