Main Content

inputLayer

Input layer

Since R2023b

    Description

    An input layer inputs data into a neural network with a custom format.

    Creation

    Description

    example

    layer = inputLayer(inputSize,inputFormat) creates an input layer and sets the InputSize and InputFormat properties.

    layer = inputLayer(inputSize,format,Name=name) also sets the Name property.

    Properties

    expand all

    Input

    This property is read-only.

    Size of the input, specified as a row vector of positive integers or NaN.

    For networks that support variable sizes for the batch or time dimensions, specify the size of the corresponding dimension as NaN.

    Example: [224 224 3]

    Description of the data dimensions, specified as a character vector or string scalar.

    A 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, consider an array containing a batch of sequences where the first, second, and third dimensions correspond to channels, observations, and time steps, respectively. You can specify that this array has 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. When the number of dimensions is greater than two, the input size corresponding to the rightmost "U" dimension in the input format must be greater than 1.

    For more information, see Deep Learning Data Formats.

    Example: "SSCB"

    Example: "SCBT"

    Example: "TCB"

    Data Types: char | string

    Layer

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

    The InputLayer object stores this property as a character vector.

    Data Types: char | string

    This property is read-only.

    Number of inputs of the layer. The layer has no inputs.

    Data Types: double

    This property is read-only.

    Input names of the layer. The layer has no inputs.

    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

    Create an input layer that inputs 1-D image data (3-D data, with dimensions corresponding to space, channels, and observations). Specify that the data has three channels and a image height size of 64. Specify that the batch dimension can vary.

    inputSize = [64 3 NaN];
    inputFormat = "SCB";
    layer = inputLayer(inputSize,inputFormat)
    layer = 
      InputLayer with properties:
    
               Name: ''
          InputSize: [64 3 NaN]
        InputFormat: 'SCB'
    
    

    Include the input layer in a network.

    layers = [
        inputLayer([64 3 NaN],"SCB")
        convolution1dLayer(5,32)
        batchNormalizationLayer
        reluLayer
        fullyConnectedLayer(10)
        softmaxLayer];

    Create an input layer that inputs spatiotemporal data (4-D data, with dimensions corresponding to space, channels, time, and observations). Specify that the data has three channels and a spatial size of 64. Specify that the batch and time dimensions can vary.

    inputSize = [64 3 NaN NaN];
    inputFormat = "SCBT";
    layer = inputLayer(inputSize,inputFormat)
    layer = 
      InputLayer with properties:
    
               Name: ''
          InputSize: [64 3 NaN NaN]
        InputFormat: 'SCBT'
    
    

    Include the input layer in a network.

    layers = [
        inputLayer([64 3 NaN NaN],"SCBT")
        convolution1dLayer(5,32)
        batchNormalizationLayer
        reluLayer
        globalAveragePooling1dLayer
        flattenLayer
        lstmLayer(100,OutputMode="last")
        fullyConnectedLayer(10)
        softmaxLayer];

    Algorithms

    expand all

    Extended Capabilities

    Version History

    Introduced in R2023b

    expand all