CatenateLayer

CatenateLayer[]

represents a net layer that takes a list of input arrays and catenates them.

CatenateLayer[n]

represents a net layer that takes a list of input arrays and catenates them at level n.

Details and Options

  • CatenateLayer[] is equivalent to CatenateLayer[1].
  • CatenateLayer is typically used inside NetGraph.
  • CatenateLayer has an arbitrary number of input ports named 1, 2, etc.
  • Within a NetGraph, a CatenateLayer can be connected using a single edge of the form {src1,src2,}catlayer, where catlayer is the name or index of the CatenateLayer, or as multiple separate edges given in the corresponding order, as src1catlayer,src2catlayer,,srcncatlayer.
  • CatenateLayer[][{array1,array2,}] explicitly computes the output given a list of arrayi.
  • When given a NumericArray as input, the output will be a NumericArray.
  • CatenateLayer exposes the following ports for use in NetGraph etc.:
  • 1,2,arrays
    "Output"an array
  • For a list of input arrays {array1,array2,}, the arrayi must be of compatible dimensions. If necessary, the arrayi are replicated as appropriate in order to make them all the same rank.
  • If given, the level n is relative to the first dimension of the arrayi with smallest rank.
  • When it cannot be inferred from other layers in a larger net, the option "Inputs"{shape1,shape2,} can be used to fix the dimensions of the input arrays to CatenateLayer. Each shape shapei can be one of the following:
  • {n} orna vector of dimensions n
    {n1,n2,}an array of dimensions n1×n2×
    {"Varying",n2,n3,}an array whose first dimension is variable and whose remaining dimensions are n2×n3×
  • Options[CatenateLayer] gives the list of default options to construct the layer. Options[CatenateLayer[]] gives the list of default options to evaluate the layer on some data.
  • Information[CatenateLayer[]] gives a report about the layer.
  • Information[CatenateLayer[],prop] gives the value of the property prop of CatenateLayer[]. Possible properties are the same as for NetGraph.

Examples

open allclose all

Basic Examples  (3)

Create a CatenateLayer:

Create a CatenateLayer that takes two vectors as input and returns a vector:

Apply this layer to a list of vectors:

Construct a NetGraph with a CatenateLayer, specifying input sizes:

Apply the net to input data:

Scope  (4)

Create a CatenateLayer that catenates the rows of two matrices:

Apply the layer to two matrices:

Create a CatenateLayer that catenates a matrix and a vector by repeating the vector:

Apply the layer to an input matrix and vector:

Construct a NetGraph with a CatenateLayer that takes two matrices representing sequences of vectors as input and catenates the vectors:

Apply the net to two sequences to create a single sequence of vectors:

Construct a NetGraph with a CatenateLayer that takes two images and catenates them horizontally:

Apply the net to two images to create a single image:

Properties & Relations  (1)

When the inputs are all the same rank, CatenateLayer[1] computes:

Evaluate on some data:

Possible Issues  (4)

When catenating arrays of equal rank, the off-level dimensions must be equal:

When catenating arrays of different rank, the dimensions of lower-rank arrays should be suffixes of the dimensions of higher-rank arrays, except for the dimension in each array that corresponds to the level:

CatenateLayer cannot catenate on a dynamic dimension:

Catenate on the second dimension, which is not dynamic:

CatenateLayer cannot accept symbolic inputs:

Introduced in 2016
 (11.0)
 |
Updated in 2018
 (11.3)