ReshapeLayer

ReshapeLayer[dims]

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

Details and Options

  • ReshapeLayer[][input] explicitly computes the output from applying the layer to input.
  • ReshapeLayer[][{input1,input2,}] explicitly computes outputs for each of the inputi.
  • When given a NumericArray as input, the output will be a NumericArray.
  • ReshapeLayer exposes the following ports for use in NetGraph etc.:
  • "Input"an array of arbitrary rank
    "Output"an array of dimension dims
  • In ReshapeLayer[dims], the following elements are allowed in the list dims:
  • nexplicitly specify the size
    Inheritedcopy the size from the input
    Automaticinfer the size from the size of the other dimensions
  • The total number of elements in the input array is equal to the total number of elements in the output array.
  • Only one Automatic is allowed in the list of dimensions.
  • 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 all close all

Basic Examples  (3)

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 4-dimensional array:

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

Create a ReshapeLayer that reshapes a length-1 vector into a single number:

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

Apply the layer to an input:

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

Scope  (4)

Properties & Relations  (3)

Possible Issues  (2)

Interactive Examples  (1)

Neat Examples  (2)

Introduced in 2016
(11.0)
|
Updated in 2019
(12.0)