フィルターのクリア

How do I add CNN Bounding Box Regression Layer to a network that is not R-CNN?

1 回表示 (過去 30 日間)
Eric Louchard
Eric Louchard 2023 年 3 月 8 日
回答済み: Divyank 2023 年 3 月 16 日
Is there a generic bounding box regression layer that can be added to a network? There is the layer call, rcnnBoxRegressionLayer, but that is only for R-CNN. I want to add a bounding box layer to a non-R-CNN network.
Something like this simple character recognition network, adding a bounding box regression to it. This is just an example to show what I mean.
There are ways to do this in Python with Keras and tensorflow but is there a way to do this in Matlab?

回答 (1 件)

Divyank
Divyank 2023 年 3 月 16 日
Hello @Eric Louchard, in MATLAB, you can add a bounding box regression layer to a non-R-CNN network using the 'regressionLayer' function. The 'regressionLayer' function can be used to create a custom bounding box regression layer in MATLAB.
Here's an example of how to add a bounding box regression layer to the simple character recognition network in MATLAB:
% Load the example data
[XTrain, YTrain] = digitTrain4DArrayData;
% Define the network layers
layers = [
imageInputLayer([28 28 1])
convolution2dLayer(5, 20)
reluLayer
maxPooling2dLayer(2, 'Stride', 2)
fullyConnectedLayer(10)
softmaxLayer
classificationLayer
regressionLayer % Add the regression layer after the classification layer
];
% Define the training options
options = trainingOptions('sgdm', ...
'MaxEpochs', 20, ...
'MiniBatchSize', 128, ...
'Plots', 'training-progress');
% Train the network with the regression layer
net = trainNetwork(XTrain, YTrain, layers, options);
In this example, the 'regressionLayer' function is added after the 'classificationLayer' to create a custom bounding box regression layer. You can then train the network with the new layer using the 'trainNetwork' function.
Note that the 'regressionLayer' function in MATLAB assumes that the input to the layer is a 4-D array of size [height, width, channels, batchsize]. Therefore, you'll need to reshape your data accordingly before using the 'regressionLayer' function.

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by