ReshapeLayer

ReshapeLayer[dims]

represents a net layer that reinterprets the input to be an array of dimensions dims.

Details and Options

  • The total number of elements in the input array must equal the total number of elements in the output array.
  • ReshapeLayer[][input] explicitly computes the output from applying the layer to input.
  • ReshapeLayer[][{input1,input2,}] explicitly computes outputs for each of the inputi.
  • ReshapeLayer exposes the following ports for use in NetGraph etc.:
  • "Input"a tensor of arbitrary rank
    "Output"a tensor of dimension dims
  • ReshapeLayer is typically used inside NetChain, NetGraph, etc.
  • ReshapeLayer normally infers the dimensions of its input from its context in NetChain etc. To specify the dimensions explicitly as {n1,n2,}, use ReshapeLayer["Input"->{n1,n2,}].

Examples

open allclose all

Basic Examples  (2)

Create a ReshapeLayer that reshapes any input into a 2×3 matrix:

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

Create a ReshapeLayer that reshapes any input into a 2×3 matrix:

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

Apply the layer to a vector:

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

Apply the layer to a rank-4 tensor:

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

Scope  (4)

Properties & Relations  (2)

Possible Issues  (1)

Interactive Examples  (1)

Neat Examples  (2)

See Also

FlattenLayer  ReplicateLayer  ResizeLayer  TransposeLayer  PartLayer  ArrayReshape  NetChain  NetGraph

Introduced in 2016
(11.0)