FCN not being able to resume

조회 수: 2 (최근 30일)
filipendo125
filipendo125 2018년 1월 27일
답변: Suvidha Tripathi 2018년 8월 23일
So I have performed some training on my data, and wanted to test my solution half-way through running training of FCN network for semantic segmentation. However, I got this error:
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.
What I have done is just loaded that checkpoint and tried to run training on it again, but that failed. Below is a short piece of my code with else statement not working:
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

답변 (1개)

Suvidha Tripathi
Suvidha Tripathi 2018년 8월 23일
When you are resuming training from a checkpoint in case of layer graph object, then just do this modification
newlgraph=layerGraph(net);
new_net = trainNetwork(pximds,newlgraph,options)
where net is your last checkpoint network.

카테고리

Help CenterFile Exchange에서 Image Data Workflows에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by