forward
Syntax
Description
[
also computes the activations of the network that you can use for modelling the gradient
loss.features
,activations
] = forward(detector
,dlX
)
Examples
Compute YOLO v3 Network Output During Forward Pass
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
detector
— YOLO v3 object detector
yolov3ObjectDetector
object
YOLO v3 object detector, specified as a yolov3ObjectDetector
object.
dlX
— Training data
formatted dlarray
Training data, specified as a formatted dlarray
(Deep Learning Toolbox)
object.
Output Arguments
features
— Output features in box coordinates
N-by-8 cell array
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
— Activations of network
N-by-8 cell array of formatted
dlarray
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.
Activations | Description |
conf | Estimated confidence scores for each bounding box. |
bx | Estimated X-coordinate value for the center of the bounding box relative to the location of the grid cell. |
by | Estimated Y-coordinate value for the center of the bounding box relative to the location of the grid cell. |
bw | Estimated width of the bounding box relative to the location of the grid cell. |
bh | Estimated height of the bounding box relative to the location of the grid cell. |
prob | Class probabilities estimated for each feature in the output feature map. |
tw | Prior width of the bounding box as estimated by the network. |
th | Prior height of the bounding box as estimated by the network. |
state
— Updated network state
table
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
MATLAB-Befehl
Sie haben auf einen Link geklickt, der diesem MATLAB-Befehl entspricht:
Führen Sie den Befehl durch Eingabe in das MATLAB-Befehlsfenster aus. Webbrowser unterstützen keine MATLAB-Befehle.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)