Main Content


(To be removed) Create anchor box layer for object detection

Since R2020a

AnchorBoxLayer will be removed in a future release. Use the ssdObjectDetector function to specify the anchor boxes for training a SSD object detection network, instead.


An anchor box layer stores anchor boxes for a feature map used in object detection networks.



layer = anchorBoxLayer(anchorBoxes) creates an anchor box layer, specifying the size of the anchor boxes by using anchorBoxes. The anchorBoxes input sets the AnchorBoxes property.


layer = anchorBoxLayer(anchorBoxes,Name,Value) set properties of the anchor box layer by using one or more name-value pair arguments. Enclose each property name in quotes.

For example, anchorBoxLayer(anchorBoxes,'Name','anchorboxlayer') creates an anchor box layer with the name "anchorboxlayer" from anchor boxes specified by anchorBoxes.


expand all

Size of anchor boxes, specified as an M-by-2 matrix of M anchor boxes. Each row of the matrix is of the form [height width].

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

Data Types: char | string


collapse all

Specify the size of four anchor boxes.

anchorBoxes = [50 50; 100 100; 50 100; 100 50];

Create an anchor box layer named "anchorboxlayer" and display the results.

layer = anchorBoxLayer(anchorBoxes,'Name','anchorboxlayer')
layer = 
  AnchorBoxLayer with properties:

           Name: 'anchorboxlayer'

    AnchorBoxes: [4x2 double]

Extended Capabilities

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

Version History

Introduced in R2020a

expand all