({{, (RefLink[ConstantArrayLayer, paclet:ref/ConstantArrayLayer])[] 
represents a layer that has no input and produces as output a constant array.}, {, (RefLink[ConstantArrayLayer, paclet:ref/ConstantArrayLayer])[opts]
includes options for initial value of the array or output size.}})

OpenersNotesSection(Spacer1)Details and Options

(RefLink[ConstantArrayLayer, paclet:ref/ConstantArrayLayer]) is typically used in a (RefLink[NetGraph, paclet:ref/NetGraph]) and allows a learned array to be used as an ordinary input to other layers. Without (RefLink[ConstantArrayLayer, paclet:ref/ConstantArrayLayer]), all layer inputs must ultimately be derived from inputs to the entire net.

The array stored by (RefLink[ConstantArrayLayer, paclet:ref/ConstantArrayLayer]) will be learned during training.

The constant array stored in (RefLink[ConstantArrayLayer, paclet:ref/ConstantArrayLayer]) has the same dimensions as the output of (RefLink[ConstantArrayLayer, paclet:ref/ConstantArrayLayer]).

(RefLink[ConstantArrayLayer, paclet:ref/ConstantArrayLayer])["Array"->array] can be used to give an explicit value of the constant array.

(RefLink[ConstantArrayLayer, paclet:ref/ConstantArrayLayer])["Output"->{(Subscript[d, 1]),(Subscript[d, 2]),…}] can be used to fix the output size of the layer, which also fixes the size of the constant array.

When the constant array is not explicitly specified or is given as (RefLink[Automatic, paclet:ref/Automatic]), it is added automatically when (RefLink[NetInitialize, paclet:ref/NetInitialize]) or (RefLink[NetTrain, paclet:ref/NetTrain]) is used.

(RefLink[ConstantArrayLayer, paclet:ref/ConstantArrayLayer])[…][] returns the constant array.

The constant array can also be obtained from an initialized (RefLink[ConstantArrayLayer, paclet:ref/ConstantArrayLayer]) using (RefLink[NetExtract, paclet:ref/NetExtract])[layer,"Array"].

OpenersPrimaryExamplesSection(Spacer1)Examples  (4)

OpenersExampleSection0(Spacer1)Basic Examples  (2)

Create a (RefLink[ConstantArrayLayer, paclet:ref/ConstantArrayLayer]):

layer=ConstantArrayLayer[]

Create an initialized (RefLink[ConstantArrayLayer, paclet:ref/ConstantArrayLayer]) with output dimensions specified:

layer=NetInitialize@ConstantArrayLayer["Output"->3]

Extract the initialized array:

NetExtract[layer,"Array"]

OpenersExampleSection1(Spacer1)Scope  (1)

Create a (RefLink[ConstantArrayLayer, paclet:ref/ConstantArrayLayer]) with a specific initial value for the array:

layer=ConstantArrayLayer["Array"->{1,2,3}]

Embed the layer in a graph that raises the input to a power of the array elementwise:

graph=NetGraph[{layer,ThreadingLayer[#1^#2&]},{{NetPort["Input"],1}->2}]

graph[{1,2,3}]

OpenersExampleSection2(Spacer1)Possible Issues  (1)

(RefLink[ConstantArrayLayer, paclet:ref/ConstantArrayLayer]) cannot accept symbolic arrays:

ConstantArrayLayer["Array"-> {z,2}]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[ConstantTimesLayer, paclet:ref/ConstantTimesLayer])  ▪  (RefLink[ConstantPlusLayer, paclet:ref/ConstantPlusLayer])  ▪  (RefLink[ThreadingLayer, paclet:ref/ThreadingLayer])  ▪  (RefLink[NetChain, paclet:ref/NetChain])  ▪  (RefLink[NetGraph, paclet:ref/NetGraph])  ▪  (RefLink[NetInitialize, paclet:ref/NetInitialize])  ▪  (RefLink[NetTrain, paclet:ref/NetTrain])  ▪  (RefLink[NetExtract, paclet:ref/NetExtract])}})}})

({{DocumentationFooterIconsRelatedTutorial.png, ({{Tutorials}, {▪(RefLinkPlain[Neural Networks in the Wolfram Language, paclet:tutorial/NeuralNetworksOverview])}})}})

({{DocumentationFooterIconsRelatedGuide.png, ({{Related Guides}, {▪(RefLinkPlain[Neural Networks, paclet:guide/NeuralNetworks])}})}})