ReplicateLayer
✖
ReplicateLayer
represents a net layer that takes an input of dimensions {d1,d2,…} and replicates it n times to produce an output of dimensions {n,d1,d2,…}.
represents a net layer that takes an input of dimensions {d1,d2,…} and replicates it to produce an output of dimensions {n1,n2,…,nm,d1,d2,…}.
replicates so that dims appears at position m in the list of output dimensions.
Details and Options

- ReplicateLayer[n] is equivalent to ReplicateLayer[n,1].
- For ReplicateLayer[n], the rank of the output array is one larger than the rank of the input array.
- For ReplicateLayer[{n1,…,nm}], the rank of the output array is m larger than the rank of the input array.
- Any of the n or ni can have the value Automatic, leaving the exact output dimension to be inferred from its context in NetChain etc.
- ReplicateLayer[…][input] explicitly computes the output from applying the layer to input.
- ReplicateLayer[…][{input1,input2,…}] explicitly computes outputs for each of the inputi.
- When given a NumericArray as input, the output will be a NumericArray.
- ReplicateLayer exposes the following ports for use in NetGraph etc.:
-
"Input" an array of arbitrary rank "Output" an array of greater rank than the input - ReplicateLayer is typically used inside NetChain, NetGraph, etc.
- ReplicateLayer normally infers the dimensions of its input from its context in NetChain etc. To specify the dimensions explicitly as {n1,n2,…}, use ReplicateLayer["Input"->{n1,n2,…}].
- Options[ReplicateLayer] gives the list of default options to construct the layer. Options[ReplicateLayer[…]] gives the list of default options to evaluate the layer on some data.
- Information[ReplicateLayer[…]] gives a report about the layer.
- Information[ReplicateLayer[…],prop] gives the value of the property prop of ReplicateLayer[…]. Possible properties are the same as for NetGraph.
Examples
open allclose allBasic Examples (2)Summary of the most common use cases
Create a ReplicateLayer that replicates its input 4 times:

https://wolfram.com/xid/0bh1n2o11wfwrm-kq71xu

Create a ReplicateLayer that replicates its input 3 times:

https://wolfram.com/xid/0bh1n2o11wfwrm-zi5xha


https://wolfram.com/xid/0bh1n2o11wfwrm-7u8hba

Scope (6)Survey of the scope of standard use cases
Arguments (2)
Create a ReplicateLayer that replicates its input 3×4 times:

https://wolfram.com/xid/0bh1n2o11wfwrm-yb04cp


https://wolfram.com/xid/0bh1n2o11wfwrm-ix0v19

Create a ReplicateLayer that replicates the elements of a vector into rows of length 3:

https://wolfram.com/xid/0bh1n2o11wfwrm-lwd51p


https://wolfram.com/xid/0bh1n2o11wfwrm-6afzpp

The elements can be replicated into columns instead:

https://wolfram.com/xid/0bh1n2o11wfwrm-sgr2fa


https://wolfram.com/xid/0bh1n2o11wfwrm-vqfl0w

Ports (4)
Create a ReplicateLayer that takes an input of specific size:

https://wolfram.com/xid/0bh1n2o11wfwrm-06s1bp


https://wolfram.com/xid/0bh1n2o11wfwrm-eqiagw

Create a NetGraph containing a ReplicateLayer that automatically broadcasts a vector to a matrix of given size:

https://wolfram.com/xid/0bh1n2o11wfwrm-4meoer

This NetGraph is now valid for multiple input dimensions:

https://wolfram.com/xid/0bh1n2o11wfwrm-pwdh21


https://wolfram.com/xid/0bh1n2o11wfwrm-pjqe8s

Create a ReplicateLayer that replicates a single number to form a vector:

https://wolfram.com/xid/0bh1n2o11wfwrm-028rfm


https://wolfram.com/xid/0bh1n2o11wfwrm-1d476e

The layer threads across a batch of inputs:

https://wolfram.com/xid/0bh1n2o11wfwrm-kb56t7

Create a NetChain that makes four copies of an image by replicating and then flattening both spatial dimensions in turn:

https://wolfram.com/xid/0bh1n2o11wfwrm-m2efma


https://wolfram.com/xid/0bh1n2o11wfwrm-j58jfb

Possible Issues (2)Common pitfalls and unexpected behavior
ReplicateLayer cannot accept non-numeric inputs:

https://wolfram.com/xid/0bh1n2o11wfwrm-ggaxyd


https://wolfram.com/xid/0bh1n2o11wfwrm-56whoo


ReplicateLayer[dims,pos] will fail when pos is more than one greater than the rank of the input:

https://wolfram.com/xid/0bh1n2o11wfwrm-s85t60


Wolfram Research (2017), ReplicateLayer, Wolfram Language function, https://reference.wolfram.com/language/ref/ReplicateLayer.html (updated 2017).
Text
Wolfram Research (2017), ReplicateLayer, Wolfram Language function, https://reference.wolfram.com/language/ref/ReplicateLayer.html (updated 2017).
Wolfram Research (2017), ReplicateLayer, Wolfram Language function, https://reference.wolfram.com/language/ref/ReplicateLayer.html (updated 2017).
CMS
Wolfram Language. 2017. "ReplicateLayer." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2017. https://reference.wolfram.com/language/ref/ReplicateLayer.html.
Wolfram Language. 2017. "ReplicateLayer." Wolfram Language & System Documentation Center. Wolfram Research. Last Modified 2017. https://reference.wolfram.com/language/ref/ReplicateLayer.html.
APA
Wolfram Language. (2017). ReplicateLayer. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ReplicateLayer.html
Wolfram Language. (2017). ReplicateLayer. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/ReplicateLayer.html
BibTeX
@misc{reference.wolfram_2025_replicatelayer, author="Wolfram Research", title="{ReplicateLayer}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/ReplicateLayer.html}", note=[Accessed: 30-May-2025
]}
BibLaTeX
@online{reference.wolfram_2025_replicatelayer, organization={Wolfram Research}, title={ReplicateLayer}, year={2017}, url={https://reference.wolfram.com/language/ref/ReplicateLayer.html}, note=[Accessed: 30-May-2025
]}