主要内容

depthToSpace2dLayer

R2026b

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.

layer = depthToSpace2dLayer(blockSize,Name=Value) creates a 2-D depth to space layer and sets the properties by using one or more name-value arguments.

example

Input Arguments

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.

This argument sets the BlockSize property.

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

Name-Value Arguments

expand all

Specify optional pairs of arguments as Name1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

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

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.

This argument sets the Mode property.

Data Types: char | string

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

This argument sets the Name property.

Data Types: char | string

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. For Layer array input, the trainnet (Deep Learning Toolbox) and dlnetwork (Deep Learning Toolbox) functions automatically assign names to unnamed layers.

Data Types: char

This property is read-only.

Number of inputs to the layer, represented as 1. This layer has a single input only.

Data Types: double

This property is read-only.

Input name, represented as {'in'}. This layer has a single input only.

This property is read-only.

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

Data Types: double

This property is read-only.

Output name, represented as {'out'}. This layer has a single output only.

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

expand all

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