QuadraticLayer - Quadratic layer - MATLAB (original) (raw)
Main Content
Description
A quadratic layer calculates the pair-wise products of the elements of the input (the quadratic monomials).
Creation
Syntax
Description
`layer` = quadraticLayer
creates a quadratic layer.
`layer` = quadraticLayer(Name=[name](#mw%5Fb6d2f3b2-043a-414f-acd9-6ca4bb810dc6))
also sets the layer name. For example, Name="quad"
sets the layer name to "quad"
.
Input Arguments
Layer name, specified as a character vector or a string scalar. For Layer
array input, the trainnet anddlnetwork functions automatically assign names to unnamed layers.
This argument sets the Name property.
Data Types: char
| string
Properties
Layer name, specified as a character vector or a string scalar. For Layer
array input, the trainnet anddlnetwork functions automatically assign names to unnamed layers.
The QuadraticLayer
object stores this property as a character vector.
Data Types: char
| string
This property is read-only.
One-line description of the layer, stored as 'Quadratic'
. This description appears when you display a Layer
array and when you use theanalyzeNetwork function.
This property is read-only.
Type of the layer, stored as 'Quadratic'
. The type appears when you display a Layer
array and when you use the analyzeNetwork function.
This property is read-only.
Number of inputs to the layer, stored as 1
. This layer accepts a single input only.
Data Types: double
This property is read-only.
Input names, stored as {'in'}
. This layer accepts a single input only.
Data Types: cell
This property is read-only.
Number of outputs from the layer, stored as 1
. This layer has a single output only.
Data Types: double
This property is read-only.
Output names, stored as {'out'}
. This layer has a single output only.
Data Types: cell
Examples
Create a quadratic layer with the name "quad"
.
layer = quadraticLayer(Name="quad")
layer = QuadraticLayer with properties:
Name: 'quad'
Learnable Parameters No properties.
State Parameters No properties.
Show all properties
Include a quadratic layer in a layer array.
layers = [ featureInputLayer(3) quadraticLayer fullyConnectedLayer(1)];
Algorithms
A quadratic layer calculates the pair-wise products of the elements of the input (the quadratic monomials).
The output of the layer is
where
is the layer input.
Layers in a layer array or layer graph pass data to subsequent layers as formatted dlarray objects. The format of a dlarray
object is a string of characters in which each character describes the corresponding dimension of the data. The format consists of one or more of these characters:
"S"
— Spatial"C"
— Channel"B"
— Batch"T"
— Time"U"
— Unspecified
For example, you can describe 2-D image data that is represented as a 4-D array, where the first two dimensions correspond to the spatial dimensions of the images, the third dimension corresponds to the channels of the images, and the fourth dimension corresponds to the batch dimension, as having the format "SSCB"
(spatial, spatial, channel, batch).
QuadraticLayer
objects support data of any format with one or two dimensions only. The layer operates over the first dimension. The layer and does not add or remove any dimensions and outputs data with the same format the input data.
Version History
Introduced in R2019a
This layer now requires Deep Learning Toolbox™ only. In previous releases, this layer also required Reinforcement Learning Toolbox™.
There are some changes to the layer:
- The default value of the
Description
property is'Quadratic'
. In previous releases, the default value is'Quadratic layer'
. - Setting the
Description
using a name-value argument is not recommended. Use the default value instead. Code that sets theDescription
argument continues to work. - The default value of the
Type
property is'Quadratic'
. In previous releases, the default value is"QuadraticLayer"
. quadraticLayer
objects have different class names. If you have code that refers to the previous class names of these objects, then replace the references with the new class names. In most cases, your code will continue to run.
This table shows the change of outputs of theclass
function for this layers.layer class(layer) (Before R2025a) class(layer) (Starting in R2025a) quadraticLayer object 'rl.layer.QuadraticLayer' 'nnet.cnn.layer.QuadraticLayer The isa
function returns the same value as for previous releases. For example, in R2025a, bothisa(layer,"nnet.cnn.layer.QuadraticLayer")
andisa(layer,"rl.layer.QuadraticLayer")
return1
(true
) forquadraticLayer
objects.If you have code that uses the value returned by the class
function, then you must update your code to use the new class name. For example, replace instances ofif class(layer) == "rl.layer.QuadraticLayer" ... end with if isa(layer,"nnet.cnn.layer.QuadraticLayer") ... end