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 tensor is one larger than the rank of the input tensor.
  • For ReplicateLayer[{n1,,nm}], the rank of the output tensor is m larger than the rank of the input tensor.
  • 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.
  • ReplicateLayer exposes the following ports for use in NetGraph etc.:
  • "Input"a tensor of arbitrary rank
    "Output"a tensor 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,}].

Examples

open allclose all

Basic Examples  (2)

Create a ReplicateLayer that replicates its input 4 times:

In[1]:=
Click for copyable input
Out[1]=

Create a ReplicateLayer that replicates its input 3 times:

In[1]:=
Click for copyable input
Out[1]=

Apply the layer to data:

In[2]:=
Click for copyable input
Out[2]=

Scope  (6)

Possible Issues  (2)

See Also

FlattenLayer  ReshapeLayer  TransposeLayer  PartLayer  NetChain  NetGraph

Introduced in 2017
(11.1)
| Updated in 2017
(11.2)