Main Content

networkDataLayout

Deep learning network data layout for learnable parameter initialization

Since R2022b

    Description

    Network data layout objects represent the data size and dlarray format information of input data for parameter initialization.

    You can use networkDataLayout objects to initialize dlnetwork objects and custom layer learnable parameters using its size and format information as an alternative to using example data.

    Creation

    Description

    layout = networkDataLayout(sz) creates an unformatted network data layout object and sets the Size property.

    example

    layout = networkDataLayout(sz,fmt) creates a formatted network data layout object and sets the Size and Format properties.

    example

    Properties

    expand all

    Size, specified as a row vector of two or more nonnegative integers or NaN values, where sz(i) denotes the size of dimension i and NaN values correspond to unknown dimension sizes.

    Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

    Data format, specified as a string scalar or a character vector. Each character in the string must be one of the following dimension labels:

    • "S" — Spatial

    • "C" — Channel

    • "B" — Batch

    • "T" — Time

    • "U" — Unspecified

    You can specify multiple dimensions labeled "S" or "U". You can use the labels "C", "B", and "T" at most once.

    Data Types: string | char

    Object Functions

    finddimFind dimensions with specified label

    Examples

    collapse all

    Create an unformatted networkDataLayout object representing data of size [28 28 1].

    layout = networkDataLayout([28 28 1])
    layout = 
      networkDataLayout with properties:
    
          Size: [28 28 1]
        Format: ''
    
    

    Create a formatted networkDataLayout object representing a batch of 2-D RGB images of size [227 227], where the batch size is unknown.

    layout = networkDataLayout([227 227 3 NaN],"SSCB")
    layout = 
      networkDataLayout with properties:
    
          Size: [227 227 3 NaN]
        Format: 'SSCB'
    
    

    Create an uninitialized dlnetwork object that has two unconnected inputs.

    layers = [
        convolution2dLayer(5,16,Name="conv")
        batchNormalizationLayer
        reluLayer
        fullyConnectedLayer(50)
        flattenLayer
        concatenationLayer(1,2,Name="cat")
        fullyConnectedLayer(10)
        softmaxLayer];
    
    net = dlnetwork(layers,Initialize=false);

    View the input names of the network.

    net.InputNames
    ans = 1x2 cell
        {'conv'}    {'cat/in2'}
    
    

    Create network data layout objects that represent input data for the inputs. For the first input, specify a batch of 28-by-28 grayscale images. For the second input specify a batch of single-channel feature data.

    layout1 = networkDataLayout([28 28 1 NaN],"SSCB");
    layout2 = networkDataLayout([1 NaN],"CB");

    Initialize the network using the network data layout objects.

    net = initialize(net,layout1,layout2)
    net = 
      dlnetwork with properties:
    
             Layers: [8x1 nnet.cnn.layer.Layer]
        Connections: [7x2 table]
         Learnables: [8x3 table]
              State: [2x3 table]
         InputNames: {'conv'  'cat/in2'}
        OutputNames: {'softmax'}
        Initialized: 1
    
      View summary with summary.
    
    

    Create a formatted network data layout object representing 2-D image sequences. Specify the format "SSCBT" (spatial, spatial, channel, batch, time).

    layout = networkDataLayout([227 227 3 NaN 100],"SSCBT");

    Find the dimensions with the label "S".

    dim = finddim(layout,"S")
    dim = 1×2
    
         1     2
    
    

    Version History

    Introduced in R2022b