ReplicateLayer

ReplicateLayer[n]

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,}.

ReplicateLayer[{n1,n2,,nm}]

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,}.

ReplicateLayer[dims,m]

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 all

Basic Examples  (2)

Create a ReplicateLayer that replicates its input 4 times:

Create a ReplicateLayer that replicates its input 3 times:

Apply the layer to data:

Scope  (6)

Arguments  (2)

Create a ReplicateLayer that replicates its input 3×4 times:

Apply the layer to a vector:

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

Apply the layer to an input:

The elements can be replicated into columns instead:

Ports  (4)

Create a ReplicateLayer that takes an input of specific size:

Apply the layer to an input:

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

This NetGraph is now valid for multiple input dimensions:

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

Apply the layer to a number:

The layer threads across a batch of inputs:

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

Possible Issues  (2)

ReplicateLayer cannot accept non-numeric inputs:

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

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).

CMS

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

BibTeX

@misc{reference.wolfram_2024_replicatelayer, author="Wolfram Research", title="{ReplicateLayer}", year="2017", howpublished="\url{https://reference.wolfram.com/language/ref/ReplicateLayer.html}", note=[Accessed: 22-November-2024 ]}

BibLaTeX

@online{reference.wolfram_2024_replicatelayer, organization={Wolfram Research}, title={ReplicateLayer}, year={2017}, url={https://reference.wolfram.com/language/ref/ReplicateLayer.html}, note=[Accessed: 22-November-2024 ]}