represents a layer that has no input and produces as output a constant array.
NetArrayLayer[opts]
includes options for the initial value of the array or output size.
NetArrayLayer
represents a layer that has no input and produces as output a constant array.
NetArrayLayer[opts]
includes options for the initial value of the array or output size.
Details and Options
- NetArrayLayer is typically used in a NetGraph and allows a learned array to be used as an ordinary input to other layers. Without NetArrayLayer, all layer inputs must ultimately be derived from inputs to the entire net.
- The array stored by NetArrayLayer will be learned during training.
- The constant array stored in NetArrayLayer has the same dimensions as the output of NetArrayLayer.
- NetArrayLayer["Array"->array] can be used to give an explicit value of the constant array.
- When the constant array is not explicitly specified or is given as Automatic, it is added automatically when NetInitialize or NetTrain is used.
- NetArrayLayer["Output"->{d1,d2,…}] can be used to fix the output size of the layer, which also fixes the size of the constant array.
- The following training parameter can also be included:
-
LearningRateMultipliers Automatic learning rate multipliers for the array - NetArrayLayer[…][] returns the constant array.
- The constant array can also be obtained from an initialized NetArrayLayer using NetExtract[layer,"Array"].
- Options[NetArrayLayer] gives the list of default options to construct the layer. Options[NetArrayLayer[…]] gives the list of default options to evaluate the layer on some data.
- Information[NetArrayLayer[…]] gives a report about the layer.
- Information[NetArrayLayer[…],prop] gives the value of the property prop of NetArrayLayer[…]. Possible properties are the same as for NetGraph.
Examples
open all close allBasic Examples (2)
Create a NetArrayLayer:
NetArrayLayer[]Create an initialized NetArrayLayer with output dimensions specified:
layer = NetInitialize@NetArrayLayer["Output" -> 3]Extract the initialized array:
NetExtract[layer, "Array"]Scope (7)
Arguments (4)
Create a NetArrayLayer with unspecified output size:
NetArrayLayer[]Create a NetArrayLayer with output dimensions specified:
NetArrayLayer[3]Define a higher-dimensional output:
NetArrayLayer[{3, 4}]Specify only some output sizes:
NetArrayLayer[{3, Automatic, Automatic, 4}]Ports (1)
Parameters (2)
"Array" (2)
Create a NetArrayLayer with a specific initial value for the array:
layer = NetArrayLayer["Array" -> {1, 2, 3}]Use the array in an elementwise operation in a NetGraph:
graph = NetGraph[{layer, ThreadingLayer[#1 ^ #2&]}, {{NetPort["Input"], 1} -> 2}]graph[{1, 2, 3}]Create a NetArrayLayer with fixed output array that is not changing during the training:
NetArrayLayer["Array" -> {2, 3, 4}, LearningRateMultipliers -> 0]Possible Issues (3)
NetArrayLayer does not accept symbolic arrays:
NetArrayLayer["Array" -> {z, 2}]Dimensions of "Array" specification should be consistent with dims specification:
NetArrayLayer[3, "Array" -> {.1, .2}]NetArrayLayer[3, "Array" -> {.1, .2, .3}]"Output" dimensions need to be fully specified in order to use NetInitialize:
NetInitialize@NetArrayLayer["Output" -> {3, Automatic}]NetInitialize@NetArrayLayer["Output" -> {3, 2}]Tech Notes
Related Guides
History
Text
Wolfram Research (2020), NetArrayLayer, Wolfram Language function, https://reference.wolfram.com/language/ref/NetArrayLayer.html.
CMS
Wolfram Language. 2020. "NetArrayLayer." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/NetArrayLayer.html.
APA
Wolfram Language. (2020). NetArrayLayer. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/NetArrayLayer.html
BibTeX
@misc{reference.wolfram_2026_netarraylayer, author="Wolfram Research", title="{NetArrayLayer}", year="2020", howpublished="\url{https://reference.wolfram.com/language/ref/NetArrayLayer.html}", note=[Accessed: 15-June-2026]}
BibLaTeX
@online{reference.wolfram_2026_netarraylayer, organization={Wolfram Research}, title={NetArrayLayer}, year={2020}, url={https://reference.wolfram.com/language/ref/NetArrayLayer.html}, note=[Accessed: 15-June-2026]}