Quadratic layer for actor or critic network
A quadratic layer takes an input vector and outputs a vector of quadratic monomials constructed from the input elements. This layer is useful when you need a layer whose output is a quadratic function of its inputs. For example, to recreate the structure of quadratic value functions such as those used in LQR controller design.
For example, consider an input vector
U = [u1 u2 u3]. For this input, a
quadratic layer gives the output
Y = [u1*u1 u1*u2 u2*u2 u1*u3 u2*u3 u3*u3].
For an example that uses a
QuadraticLayer, see Compare DDPG Agent to LQR Controller.
The parameters of a
QuadraticLayer object are not learnable.
Name — Name of layer
'quadratic' (default) | character vector
Name of layer, specified as a character vector. To include a layer in a layer graph,
you must specify a nonempty unique layer name. If you train a series network with this
Name is set to
'', then the software
automatically assigns a name to the layer at training time.
Description — Description of layer
'quadratic layer' (default) | character vector
This property is read-only.
Description of layer, specified as a character vector. When you create the quadratic layer, you can use this property to give it a description that helps you identify its purpose.
Create Quadratic Layer
Create a quadratic layer that converts an input vector
U into a vector of quadratic monomials constructed from binary combinations of the elements of
qLayer = quadraticLayer
qLayer = QuadraticLayer with properties: Name: 'quadratic' Learnable Parameters No properties. State Parameters No properties. Use properties method to see a list of all properties.
Confirm that the layer produces the expected output. For instance, for
U = [u1 u2 u3], the expected output is
[u1*u1 u1*u2 u2*u2 u1*u3 u2*u3 u3*u3].
predict(qLayer,[1 2 3])
ans = 1×3
1 4 9
You can incorporate
qLayer into an actor network or critic network for reinforcement learning.
Introduced in R2019a