Create anchor box layer for object detection


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. 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


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

Introduced in R2020a