formatLayer
R2026bDescription
A format layer applies a data format to its input data.
Creation
Description
Input Arguments
Description of the data dimensions, specified as a character vector or string scalar that represents a deep learning data format.
A deep learning data format is a string of characters, where each character describes the type of the corresponding data dimension. The characters are:
"S"— Spatial"C"— Channel"B"— Batch"T"— Time"U"— Unspecified
For example, suppose you have an array that represents a batch of sequences where the
first, second, and third dimensions correspond to channels, observations, and time steps,
respectively. You can describe the data as having the format "CBT"
(channel, batch, time).
You can specify multiple dimensions labeled "S" or "U".
You can use the labels "C", "B", and
"T" at most once each. The software ignores singleton trailing
"U" dimensions after the second dimension.
To remove the data format from the data, specify fmt as
"".
The number of dimension labels must be greater than or equal to the number of dimensions in the layer input data. If the number of labels is greater than the number of input dimensions, then the layer introduces additional singleton dimensions.
For more information, see Deep Learning Data Formats.
This argument sets the DataFormat property.
Data Types: char | string
Properties
Format
This property is read-only after object creation. To set this property, use the corresponding
positional input argument when you create the FormatLayer
object.
Description of the data dimensions, represented as a character vector or string scalar that represents a deep learning data format.
A deep learning data format is a string of characters, where each character describes the type of the corresponding data dimension. The characters are:
"S"— Spatial"C"— Channel"B"— Batch"T"— Time"U"— Unspecified
For example, suppose you have an array that represents a batch of sequences where the
first, second, and third dimensions correspond to channels, observations, and time steps,
respectively. You can describe the data as having the format "CBT"
(channel, batch, time).
If the number of labels is greater than the number of input dimensions, then the layer introduces additional singleton dimensions.
If DataFormat is '', then the layer removes
the data format from the data.
For more information, see Deep Learning Data Formats.
Data Types: char
Layer
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
Create a format layer that applies the data format "SCB" (spatial, channel, batch) to its input.
layer = formatLayer("SCB")layer =
FormatLayer with properties:
Name: ''
DataFormat: 'SCB'
Hyperparameters
No properties.
Algorithms
Most layers in a layer array or layer graph pass data to subsequent layers as formatted
dlarray objects.
The format of a dlarray object is a string of characters in which each
character describes the corresponding dimension of the data. The format consists of one or
more of these characters:
"S"— Spatial"C"— Channel"B"— Batch"T"— Time"U"— Unspecified
For example, you can describe 2-D image data that is represented as a 4-D array, where the
first two dimensions correspond to the spatial dimensions of the images, the third
dimension corresponds to the channels of the images, and the fourth dimension
corresponds to the batch dimension, as having the format "SSCB"
(spatial, spatial, channel, batch).
FormatLayer objects support input data of any format. The layer applies
the data format specified by the DataFormat property to the layer input.
When DataFormat is "", the layer removes the data
format from the input, producing unformatted output.
For more information, see Deep Learning Data Formats.
FormatLayer objects support complex-valued input and outputs. The layer
applies the same underlying operation to complex-valued input as it does to
real-valued input. The layer outputs complex-valued data where applicable.
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 R2026b
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
Seleccione un país/idioma
Seleccione un país/idioma para obtener contenido traducido, si está disponible, y ver eventos y ofertas de productos y servicios locales. Según su ubicación geográfica, recomendamos que seleccione: .
También puede seleccionar uno de estos países/idiomas:
Cómo obtener el mejor rendimiento
Seleccione China (en idioma chino o inglés) para obtener el mejor rendimiento. Los sitios web de otros países no están optimizados para ser accedidos desde su ubicación geográfica.
América
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)