Main Content

forward

Compute YOLO v3 deep learning network output for training

Since R2021a

    Description

    features = forward(detector,dlX) computes the output features of the network during training given the input data dlX.

    [features,activations] = forward(detector,dlX) also computes the activations of the network that you can use for modelling the gradient loss.

    example

    [features,activations,state] = forward(detector,dlX) also returns the updated network state.

    Note

    To run this function, you will require the Deep Learning Toolbox™.

    example

    Examples

    collapse all

    Load a pretrained YOLO v3 object detector.

    detector = yolov3ObjectDetector('tiny-yolov3-coco');

    Read an image to use for training.

    I = imread('highway.png');

    Preprocess the training data and convert the preprocessed training data to a formatted dlarray object.

    [Ip,info] = preprocess(detector,I);
    Ip = im2single(Ip);
    dlX = dlarray(Ip,'SSCB');

    Compute the network outputs obtained during training. The forward function returns the activations from the output layers of the YOLO v3 deep learning network. The first column contains the confidence scores. Columns 2 to 5 contain the bounding box locations computed relative to the grid cell coordinates. The sixth column contains the class probabilities for each class used during training. The seventh and the eighth column contains the prior width and prior height of bounding boxes as computed by the network, respectively. The output features computed during the forward pass are used to model the gradient losses for the network.

    [output,activations,state] = forward(detector,dlX)
    output=2×8 cell array
        {13x13x3 single}    {13x13x3 single}    {13x13x3 single}    {13x13x3 single}    {13x13x3 single}    {13x13x240 single}    {13x13x3 single}    {13x13x3 single}
        {26x26x3 single}    {26x26x3 single}    {26x26x3 single}    {26x26x3 single}    {26x26x3 single}    {26x26x240 single}    {26x26x3 single}    {26x26x3 single}
    
    
    activations=2×8 cell array
        {13x13x3x1 dlarray}    {13x13x3x1 dlarray}    {13x13x3x1 dlarray}    {13x13x3x1 dlarray}    {13x13x3x1 dlarray}    {13x13x240x1 dlarray}    {13x13x3x1 dlarray}    {13x13x3x1 dlarray}
        {26x26x3x1 dlarray}    {26x26x3x1 dlarray}    {26x26x3x1 dlarray}    {26x26x3x1 dlarray}    {26x26x3x1 dlarray}    {26x26x240x1 dlarray}    {26x26x3x1 dlarray}    {26x26x3x1 dlarray}
    
    
    state=22×3 table
            Layer             Parameter              Value       
        ______________    _________________    __________________
    
        "batch_norm_1"    "TrainedMean"        {1x1x16   dlarray}
        "batch_norm_1"    "TrainedVariance"    {1x1x16   dlarray}
        "batch_norm_2"    "TrainedMean"        {1x1x32   dlarray}
        "batch_norm_2"    "TrainedVariance"    {1x1x32   dlarray}
        "batch_norm_3"    "TrainedMean"        {1x1x64   dlarray}
        "batch_norm_3"    "TrainedVariance"    {1x1x64   dlarray}
        "batch_norm_4"    "TrainedMean"        {1x1x128  dlarray}
        "batch_norm_4"    "TrainedVariance"    {1x1x128  dlarray}
        "batch_norm_5"    "TrainedMean"        {1x1x256  dlarray}
        "batch_norm_5"    "TrainedVariance"    {1x1x256  dlarray}
        "batch_norm_6"    "TrainedMean"        {1x1x512  dlarray}
        "batch_norm_6"    "TrainedVariance"    {1x1x512  dlarray}
        "batch_norm_7"    "TrainedMean"        {1x1x1024 dlarray}
        "batch_norm_7"    "TrainedVariance"    {1x1x1024 dlarray}
        "batch_norm_8"    "TrainedMean"        {1x1x256  dlarray}
        "batch_norm_8"    "TrainedVariance"    {1x1x256  dlarray}
          ⋮
    
    

    Input Arguments

    collapse all

    YOLO v3 object detector, specified as a yolov3ObjectDetector object.

    Training data, specified as a formatted dlarray (Deep Learning Toolbox) object.

    Output Arguments

    collapse all

    Output features in box coordinates, returned as an N-by-8 cell array. N is the number of output layers in the YOLO v3 deep learning network.

    Activations of the network, returned as an N-by-8 cell array of formatted dlarray (Deep Learning Toolbox) objects. N is the number of output layers in the YOLO v3 deep learning network.

    Each row in the cell array is of form [conf bx by bw bh prob tw th]. The function returns each activation as a formatted dlarray (Deep Learning Toolbox) value.

    ActivationsDescription
    confEstimated confidence scores for each bounding box.
    bxEstimated X-coordinate value for the center of the bounding box relative to the location of the grid cell.
    byEstimated Y-coordinate value for the center of the bounding box relative to the location of the grid cell.
    bwEstimated width of the bounding box relative to the location of the grid cell.
    bhEstimated height of the bounding box relative to the location of the grid cell.
    probClass probabilities estimated for each feature in the output feature map.
    twPrior width of the bounding box as estimated by the network.
    thPrior height of the bounding box as estimated by the network.

    Updated network state, returned as a table. The network state is a table with three columns:

    • Layer – Layer name, returned as a string scalar.

    • Parameter – Parameter name, returned as a string scalar.

    • Value – Value of parameter, returned as a numeric array object.

    The network state contains information remembered by the network between iterations.

    Version History

    Introduced in R2021a