Main Content

dlhdl.layer.reshapeLayer

Layer that reshapes activation data

Since R2024b

Description

Use reshapeLayer objects to create a reshape layer. You can use reshape layers to change the shape of activation data.

Creation

Description

layer = dlhdl.layer.reshapeLayer(sizeVector) creates a reshape layer that reshapes activation data using the size vector specified by sizeVector.

layer = dlhdl.layer.reshapeLayer(sz1,sz2,sz3) creates a reshape layer that reshapes activation data into an sz1-by-sz2-by-sz3 array. To automatically calculate the size of the array elements set one of sz1, sz2, or sz3 to [].

layer = dlhdl.layer.reshapeLayer(___,Name=Value) sets the optional Name property by using name-value arguments.

example

Properties

expand all

Dimensions to use to reshape size of activation data, specified as a row vector of three elements. The three elements correspond to the "SSC" (spatial, spatial, channel) data format.

Example: [227 1 3]

Data Types: uint16

First spatial dimension, specified as a positive integer. To automatically calculate the appropriate size, set the value to []. The first dimension corresponds to the first "S" dimension of the "SSC" (spatial, spatial, channel) data format.

Example: 227

Data Types: uint16

Second spatial dimension, specified as a positive integer. To automatically calculate the appropriate size, set the value to []. The second dimension corresponds to the second "S" dimension of the "SSC" (spatial, spatial, channel) data format.

Example: 227

Data Types: uint16

Channel dimension, specified as a positive integer. To automatically calculate the appropriate size, set the value to []. The second dimension corresponds to the "C" dimension of the "SSC" (spatial, spatial, channel) data format.

Example: 3

Data Types: uint16

Layer

Layer name, specified as a character vector or string scalar. For Layer array input, the trainnet and dlnetwork functions automatically assign names to layers with the name "".

The reshapeLayer object stores this property as a character vector.

Data Types: char | string

This property is read-only.

Number of inputs to the layer, returned as 1. This layer accepts a single input only.

Data Types: double

This property is read-only.

Input names, returned as {'in'}. This layer accepts a single input only.

Data Types: cell

This property is read-only.

Number of outputs from the layer, returned as 1. This layer has a single output only.

Data Types: double

This property is read-only.

Output names, returned as {'out'}. This layer has a single output only.

Data Types: cell

Examples

collapse all

Create a reshape layer with the name reshape1.

layer = dlhdl.layer.reshapeLayer(10,5,3,Name="reshape1")
layer = 
  reshapeLayer with properties:

          Name: 'reshape1'
     InputSize: []
    OutputSize: [10 5 3]
   Learnable Parameters
    No properties.
   State Parameters
    No properties.
  Show all properties

Include the reshape layer in a Layer array.

 layers = [
                imageInputLayer([10,5,3],"Normalization","none","name","input");
                fullyConnectedLayer(150);
                layer
                ];
layers = 
  3×1 Layer array with layers:

     1   'input'      Image Input       10×5×3 images
     2   ''           Fully Connected   150 fully connected layer
     3   'reshape1'   Reshape Layer     reshapeLayer [10 5 3]

Version History

Introduced in R2024b