Main Content

depthToSpace2dLayer

Depth to space layer

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.

example

layer = depthToSpace2dLayer(blockSize,Name,Value) uses name-value pairs to set the Mode and Name properties. You can specify multiple name-value pairs. Enclose each property name in quotes.

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

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 a string scalar. For Layer array input, the trainNetwork, assembleNetwork, layerGraph, and dlnetwork functions automatically assign names to layers with Name set to ''.

Data Types: char | string

This property is read-only.

Number of inputs of the layer. This layer accepts a single input only.

Data Types: double

This property is read-only.

Input names of the layer. This layer accepts a single input only.

Data Types: cell

This property is read-only.

Number of outputs of the layer. This layer has a single output only.

Data Types: double

This property is read-only.

Output names of the layer. 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.

  Show all properties

Extended Capabilities

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

See Also

| |

Topics

Introduced in R2021a