Main Content

depthToSpace2dLayer

Depth to space layer

Since R2021a

Description

A 2-D depth to space layer permutes data from the depth dimension into blocks of 2-D spatial data.

Given an input feature map of size [H W C*height*width] and blocks of size [height width], the output feature map size is [H*height W*width C].

This object requires Deep Learning Toolbox™.

Creation

Description

layer = depthToSpace2dLayer(blockSize) creates a 2-D depth to space layer, specifying the block size to rearrange the input activation. The blockSize input sets the BlockSize property.

layer = depthToSpace2dLayer(blockSize,Name=Value) uses one or more name-value arguments to set the Mode and Name properties.

Example: depthToSpace2dLayer(blockSize,Mode="crd") creates a 2-D depth to space layer that orders data by column, row, and then depth.

example

Properties

expand all

Block size to reorder the input activation, specified as a vector of two positive integers [h w], where h is the height and w is the width. When creating the layer, you can specify BlockSize as a scalar to use the same value for both dimensions.

Example: [2 1] specifies blocks of height 2 and width 1.

Order of rearranged dimensions from the input data, specified as "dcr" or "crd". When you specify "dcr", the layer orders data by depth, column, and then row. When you specify "crd", the layer orders data by column, row, and then depth.

Data Types: char | string

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

The DepthToSpace2DLayer 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

Specify the block size for reordering input activations.

blockSize = [2 2];

Create a 2-D depth to space layer that orders data by column, row, and then depth.

layer = depthToSpace2dLayer(blockSize,"Mode","crd","Name","depthToSpaceLayer")
layer = 
  DepthToSpace2DLayer with properties:

         Name: 'depthToSpaceLayer'
    BlockSize: [2 2]
         Mode: "crd"

   Learnable Parameters
    No properties.

   State Parameters
    No properties.

Use properties method to see a list of all properties.

Extended Capabilities

C/C++ Code Generation
Generate C and C++ code using MATLAB® Coder™.

GPU Arrays
Accelerate code by running on a graphics processing unit (GPU) using Parallel Computing Toolbox™.

Version History

Introduced in R2021a

See Also

| |

Topics