Main Content

ssdMergeLayer

Create SSD merge layer for object detection

Since R2020a

Description

An SSD merge layer merges the outputs of feature maps for subsequent regression and classification loss computation. Use the merged feature maps to compute focal loss for classification and smooth L1 loss for regression.

Creation

Description

layer = ssdMergeLayer(NumChannels,NumInputs) creates an SSD merge layer, specifying the NumChannels and NumInputs properties as the number of feature map channels and number of inputs to merge, respectively.

layer = ssdMergeLayer(NumChannels,NumInputs,'Name',Name) creates an SSD merge layer and sets the optional Name property using a name-value pair. Enclose the property name in single quotes.

For example, ssdMergeLayer(4,6,'Name','sm1') creates an SSD merge layer with the name 'sm1' that merges four dimensions and six feature maps.

example

Properties

expand all

Number of feature map channels per anchor box, specified as a positive integer. For regression problems, NumChannels is 4 (for x, y, w, and h). For classification problems, NumChannels equals the number of classes that are being detected plus one for the background class.

Number of inputs to merge, specified as a positive integer.

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

The SSDMergeLayer object stores this property as a character vector.

Data Types: char | string

Examples

collapse all

Specify the number of feature map channels per anchor box. Regression merges four channels.

numChannels = 4;

Specify the number of inputs to merge.

numInputs = 6;

Create an SSD merge layer named regressionMergeLayer.

layer = ssdMergeLayer(numChannels,numInputs,'Name','regressionMergeLayer')
layer = 
  SSDMergeLayer with properties:

           Name: 'regressionMergeLayer'
    NumChannels: 4
      NumInputs: 6

Specify the number of classes, e.g. person and vehicle.

numClasses = 2
numClasses = 
2

Specify the number of inputs.

numInputs = 6
numInputs = 
6

Create an SSD merge layer for classification. The number of channels equals the number of classes + 1 for the background class.

numChannels = numClasses + 1;
clsMergeLayer = ssdMergeLayer(numChannels, numInputs,'Name','clsMergeLayer')
clsMergeLayer = 
  SSDMergeLayer with properties:

           Name: 'clsMergeLayer'
    NumChannels: 3
      NumInputs: 6

Extended Capabilities

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

Version History

Introduced in R2020a