Main Content

quadraticLayer

Quadratic layer for actor or critic network

Description

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 vectorU = [u1 u2 u3]. For this input, a quadratic layer gives the outputY = [u1*u1 u1*u2 u2*u2 u1*u3 u2*u3 u3*u3]. For an example that uses aQuadraticLayer, seeTrain DDPG Agent to Control Double Integrator System.

Note

TheQuadraticLayerlayer does not support inputs coming directly or indirectly from afeatureInputLayerorsequenceInputLayer.

The parameters of aQuadraticLayerobject are not learnable.

Creation

Description

example

qLayer= quadraticLayercreates a quadratic layer with default property values.

qLayer= quadraticLayer (Name,Value)setspropertiesusing name-value pairs. For example,quadraticLayer('Name','quadlayer')creates a quadratic layer and assigns the name'quadlayer'.

Properties

expand all

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 layer andNameis set to'', then the software automatically assigns a name to the layer at training time.

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.

Examples

collapse all

Create a quadratic layer that converts an input vectorUinto a vector of quadratic monomials constructed from binary combinations of the elements ofU.

qLayer = quadraticLayer
qLayer = QuadraticLayer属性:名称:“曲adratic' Learnable Parameters No properties. State Parameters No properties. Show all properties

Confirm that the layer produces the expected output. For instance, forU = [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×31 4 9

You can incorporateqLayerinto an actor network or critic network for reinforcement learning.

版大ry

Introduced in R2019a