www.gusucode.com > vision 源码程序 matlab案例代码 > vision/ResumeTrainingRCNNExample.m

    %% Resume Training an R-CNN Object Detector
% Resume training an R-CNN object detector using additional data. To
% illustrate this procedure, half the ground truth data will be used to
% initially train the detector. Then, training is resumed using all the
% data.

%%
% Load training data and initialize training options.
load('rcnnStopSigns.mat', 'stopSigns', 'layers')

stopSigns.imageFilename = fullfile(toolboxdir('vision'),'visiondata', ...
    stopSigns.imageFilename);

options = trainingOptions('sgdm', ...
    'MiniBatchSize', 32, ...
    'InitialLearnRate', 1e-6, ...
    'MaxEpochs', 10, ...
    'Verbose', false);

%%
% Train the R-CNN detector with a portion of the ground truth.
rcnn = trainRCNNObjectDetector(stopSigns(1:10,:), layers, options, 'NegativeOverlapRange', [0 0.3]);
    
%%
% Get the trained network layers from the detector. When you pass in an
% array of network layers to |trainRCNNObjectDetector|, they are used as-is
% to continue training.
network = rcnn.Network;
layers = network.Layers;

%%
% Resume training using all the training data.
rcnnFinal = trainRCNNObjectDetector(stopSigns, layers, options);