Contenido principal

formatLayer

R2026b

Format layer

Since R2026b

    Description

    A format layer applies a data format to its input data.

    Creation

    Description

    layer = formatLayer(fmt) creates a format layer that applies the specified data format to the layer input.

    example

    layer = formatLayer(fmt,Name=name) also sets the optional Name property using a name-value argument.

    Input Arguments

    expand all

    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

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

    This argument sets the Name property.

    Data Types: char | string

    Properties

    expand all

    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

    Layer name, specified as a character vector. For Layer array input, the trainnet and dlnetwork 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

    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

    expand all

    Extended Capabilities

    expand all

    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