Main Content

flattenLayer

Flatten layer

Description

A flatten layer collapses the spatial dimensions of the input into the channel dimension.

For example, if the input to the layer is an H-by-W-by-C-by-N-by-S array (sequences of images), then the flattened output is an (H*W*C)-by-N-by-S array.

Creation

Description

layer = flattenLayer creates a flatten layer.

example

layer = flattenLayer('Name',Name) sets the optional Name property using a name-value pair. For example, flattenLayer('Name','flatten1') creates a flatten layer with name 'flatten1'.

Properties

expand all

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

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

Object Functions

Examples

collapse all

Create a flatten layer with the name 'flatten1'.

layer = flattenLayer('Name','flatten1')
layer = 
  FlattenLayer with properties:

    Name: 'flatten1'

Algorithms

expand all

Extended Capabilities

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

GPU Code Generation
Generate CUDA® code for NVIDIA® GPUs using GPU Coder™.

Version History

Introduced in R2019a

expand all