Main Content

ssdMergeLayer

Create SSD merge layer for object detection

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.

example

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.

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 a string scalar. To include a layer in a layer graph, you must specify a nonempty unique layer name. If you train a series network with the layer and Name is set to '', then the software automatically assigns a name to the layer at training time.

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

Introduced in R2020a