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

    %% Create a network for multiclass R-CNN object detection
% Create an R-CNN object detector for two object classes: dogs and cats.
objectClasses = {'dogs','cats'};

%%
% The network must be able to classify both dogs, cats, and a "background"
% class in order to be trained using |trainRCNNObjectDetector|. In this
% example, a one is added to include the background.
numClassesPlusBackground = numel(objectClasses) + 1; 

%%
% The final fully connected layer of a network defines the number of
% classes that the network can classify. Set the final fully connected
% layer to have an output size equal to the number of classes plus a
% background class.
layers = [ ...
    imageInputLayer([28 28 1])
    convolution2dLayer(5,20)        
    fullyConnectedLayer(numClassesPlusBackground);
    softmaxLayer()
    classificationLayer()];

%%
% These network layers can now be used to train an R-CNN two-class object
% detector.