({{, (RefLink[NetNestOperator, paclet:ref/NetNestOperator])[net,n] 
represents a net in which net is applied n times to the input.}})

OpenersNotesSection(Spacer1)Details and Options

NetNestOperator[net,n] accepts a single input array (Subscript[s, 0]) and produces an output array (Subscript[s, n]), computed by applying net repeatedly to (Subscript[s, i-1]) to compute (Subscript[s, i ]).

In (RefLink[NetNestOperator, paclet:ref/NetNestOperator])[net,n], net should take exactly one input and produce exactly one output. The input and output must be of the same dimensions.

(RefLink[NetNestOperator, paclet:ref/NetNestOperator]) exposes the following ports for use in (RefLink[NetGraph, paclet:ref/NetGraph]) etc.:

If net contains trainable parameters, the same parameters are used for every application of net to the input.

If net has no trainable parameters, (RefLink[NetNestOperator, paclet:ref/NetNestOperator])[net,n] is equivalent to a (RefLink[NetChain, paclet:ref/NetChain]) containing n copies of net.

OpenersPrimaryExamplesSection(Spacer1)Examples  (2)

OpenersExampleSection0(Spacer1)Basic Examples  (1)

Create a net that applies a (RefLink[LinearLayer, paclet:ref/LinearLayer]) 10 times:

nest=NetNestOperator[LinearLayer[3],10]

Randomly initialize the net and apply it to an input:

nest=NetInitialize[nest];
nest[{1,2,3}]

OpenersExampleSection2(Spacer1)Neat Examples  (1)

Distort an image by nesting convolutions and poolings. First, create a chain that applies a convolution, pooling and a nonlinearity:

conv=NetChain[{
ConvolutionLayer[3,3,"PaddingSize"->2],
PoolingLayer[3],Tanh
}]

Create a net the applies the chain 30 times:

nest=NetNestOperator[conv,30,"Input"->"Image","Output"->"Image"]

Randomly initialize the net and apply it to a test image:

img=;

init=NetInitialize[nest,RandomSeeding->Automatic];
init[img]//ImageAdjust

Create a gallery of the results from different random initializations:

Multicolumn[Table[NetInitialize[nest, RandomSeeding->Automatic][img]//ImageAdjust,{16}]]

({{DocumentationFooterIconsRelatedFunction.png, ({{See Also}, {(RefLink[Nest, paclet:ref/Nest])  ▪  (RefLink[NetFoldOperator, paclet:ref/NetFoldOperator])  ▪  (RefLink[NetMapOperator, paclet:ref/NetMapOperator])  ▪  (RefLink[NetMapThreadOperator, paclet:ref/NetMapThreadOperator])  ▪  (RefLink[NetChain, paclet:ref/NetChain])  ▪  (RefLink[NetGraph, paclet:ref/NetGraph])}})}})

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

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