Main Content

spaceToDepthLayer

Space to depth layer

Since R2020b

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 [H W C] and blocks of size [height width], the output feature map size is [floor(H/height) floor(W/width) C*height*width].

This object requires Deep Learning Toolbox™.

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.

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

Before R2021a, use the equivalent syntax layer = spaceToDepthLayer(blockSize,"Name",name).

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.

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 SpaceToDepthLayer 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 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'
    BlockSize: [2 2]

   Learnable Parameters
    No properties.

   State Parameters
    No properties.

Use properties method to see a list of all properties.

Extended Capabilities

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

Version History

Introduced in R2020b

expand all

See Also

(Computer Vision Toolbox) | | | | (Computer Vision Toolbox)

Topics