spaceToDepthLayer

Space to depth layer

Description

A space to depth layer permutes the spatial blocks of the input into the depth dimension. Use this layer when you need to combine feature maps of different size without discarding any feature data.

Given an input feature map of size [M N P], the output feature map size is [floor(M/height) floor(N/width) P*height*width], where height and width are the specified block size.

Creation

Description

layer = spaceToDepthLayer(blockSize) creates a space to depth layer, specifying the block size to reorder the input activation. The blockSize input sets the BlockSize property.

example

layer = spaceToDepthLayer(blockSize,'Name',Name) creates a space to depth layer and sets the optional Name property.

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.

Layer name, specified as a character vector or a string scalar. To include a layer in a layer graph, you must specify a nonempty unique layer name. If you train a series network with the layer and Name is set to '', then the software automatically assigns a name to the layer at training time.

Data Types: char | string

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

Data Types: double

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

Data Types: cell

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

Data Types: double

Output names of the layer. This layer has a single output only.

Data Types: cell

Examples

collapse all

Specify the block size to reorder input activations.

blockSize = [2 2];

Create a space to depth layer named 'spacetodepth'.

layer = spaceToDepthLayer(blockSize,'Name','spacetodepth')
layer = 
  SpaceToDepthLayer with properties:

         Name: 'spacetodepth'

   Hyperparameters
    BlockSize: [2 2]

Extended Capabilities

Introduced in R2020b