Main Content

rpnClassificationLayer

(Not recommended) Classification layer for region proposal networks (RPNs)

RPNClassificationLayer is not recommended. Instead, use a different type of object detector, such as a yoloxObjectDetector or yolov4ObjectDetector detector. For more information, see Version History.

Description

A region proposal network (RPN) classification layer classifies image regions as either object or background by using a cross entropy loss function. Use this layer to create a Faster R-CNN object detection network.

Creation

Description

layer = rpnClassificationLayer creates a two-class classification layer for a Faster R-CNN object detection network.

layer = rpnClassificationLayer('Name',Name) creates a two-class classification layer and sets the optional Name property.

example

Properties

expand all

Layer name, specified as a character vector or a string scalar. For Layer array input, the trainnet (Deep Learning Toolbox) and dlnetwork (Deep Learning Toolbox) functions automatically assign names to unnamed layers.

The RPNClassificationLayer object stores this property as a character vector.

Data Types: char | string

This property is read-only.

Number of inputs to the layer, stored as 1. This layer accepts a single input only.

Data Types: double

This property is read-only.

Input names, stored as {'in'}. This layer accepts a single input only.

Data Types: cell

Examples

collapse all

Create an RPN softmax layer with the name 'rpn_softmax'.

rpnSoftmax = rpnSoftmaxLayer('Name','rpn_softmax')
rpnSoftmax = 
  RPNSoftmaxLayer with properties:

    Name: 'rpn_softmax'

Create an RPN classification layer with the name 'rpn_cls'.

rpnClassification = rpnClassificationLayer('Name','rpn_cls')
rpnClassification = 
  RPNClassificationLayer with properties:

    Name: 'rpn_cls'

Add the RPN softmax and RPN classification layers to a Layer array, to form the classification branch of an RPN.

numAnchors = 3;
rpnClassLayers = [
    convolution2dLayer(1,numAnchors*2,'Name','conv1x1_box_cls')
    rpnSoftmax
    rpnClassification
    ]
rpnClassLayers = 
  3×1 Layer array with layers:

     1   'conv1x1_box_cls'   2-D Convolution             6 1×1 convolutions with stride [1  1] and padding [0  0  0  0]
     2   'rpn_softmax'       RPN Softmax                 rpn softmax
     3   'rpn_cls'           RPN Classification Output   cross-entropy loss with 'object' and 'background' classes

Extended Capabilities

expand all

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.

Version History

Introduced in R2018b

collapse all