RegressionOutputLayer
Regression output layer
Description
A regression layer computes the half-mean-squared-error loss for regression tasks.
Creation
Create a regression output layer using regressionLayer
.
Properties
Regression Output
ResponseNames
— Names of responses
{}
(default) | cell array of character vectors | string array
Names of the responses, specified a cell array of character vectors or a string array. At training time, the software automatically sets the response names according to the training data. The default is {}
.
Data Types: cell
LossFunction
— Loss function for training
'mean-squared-error'
Loss function the software uses for training, specified as
'mean-squared-error'
.
Layer
Name
— Layer name
''
(default) | character vector | string scalar
Layer name, specified as a character vector or a string scalar.
For Layer
array input, the trainNetwork
, assembleNetwork
, layerGraph
, and
dlnetwork
functions automatically assign
names to layers with the name ''
.
Data Types: char
| string
NumInputs
— Number of inputs
1
(default)
This property is read-only.
Number of inputs of the layer. This layer accepts a single input only.
Data Types: double
InputNames
— Input names
{"in"}
(default)
This property is read-only.
Input names of the layer. This layer accepts a single input only.
Data Types: cell
NumOutputs
— Number of outputs
0 (default)
Number of outputs of the layer. The layer has no outputs.
Data Types: double
OutputNames
— Output names
{}
(default)
Output names of the layer. The layer has no outputs.
Data Types: cell
Examples
Create Regression Output Layer
Create a regression output layer with the name 'routput'
.
layer = regressionLayer('Name','routput')
layer = RegressionOutputLayer with properties: Name: 'routput' ResponseNames: {} Hyperparameters LossFunction: 'mean-squared-error'
The default loss function for regression is mean-squared-error.
Include a regression output layer in a Layer array.
layers = [ ...
imageInputLayer([28 28 1])
convolution2dLayer(12,25)
reluLayer
fullyConnectedLayer(1)
regressionLayer]
layers = 5x1 Layer array with layers: 1 '' Image Input 28x28x1 images with 'zerocenter' normalization 2 '' 2-D Convolution 25 12x12 convolutions with stride [1 1] and padding [0 0 0 0] 3 '' ReLU ReLU 4 '' Fully Connected 1 fully connected layer 5 '' Regression Output mean-squared-error
More About
Regression Output Layer
A regression layer computes the half-mean-squared-error loss for regression tasks. For typical regression problems, a regression layer must follow the final fully connected layer.
For a single observation, the mean-squared-error is given by:
where R is the number of responses, ti is the target output, and yi is the network’s prediction for response i.
For image and sequence-to-one regression networks, the loss function of the regression layer is the half-mean-squared-error of the predicted responses, not normalized by R:
For image-to-image regression networks, the loss function of the regression layer is the half-mean-squared-error of the predicted responses for each pixel, not normalized by R:
where H, W, and C denote the height, width, and number of channels of the output respectively, and p indexes into each element (pixel) of t and y linearly.
For sequence-to-sequence regression networks, the loss function of the regression layer is the half-mean-squared-error of the predicted responses for each time step, not normalized by R:
where S is the sequence length.
When training, the software calculates the mean loss over the observations in the mini-batch.
Version History
Introduced in R2017a
Beispiel öffnen
Sie haben eine geänderte Version dieses Beispiels. Möchten Sie dieses Beispiel mit Ihren Änderungen öffnen?
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)