networkDataLayout - Deep learning network data layout for learnable parameter
initialization - MATLAB ([original](https://in.mathworks.com/help/deeplearning/ref/networkdatalayout.html)) ([raw](?raw))
Main Content
Deep learning network data layout for learnable parameter initialization
Since R2022b
Description
Network data layout objects represent the data size anddlarray
format information of input data for parameter initialization.
You can use networkDataLayout
objects to initializedlnetwork
objects and custom layer learnable parameters using its size and format information as an alternative to using example data.
Creation
Syntax
Description
`layout` = networkDataLayout(sz)
creates an unformatted network data layout object and sets theSize
property.
`layout` = networkDataLayout(sz,fmt)
creates a formatted network data layout object and sets theSize
and Format
properties.
Properties
Size, specified as a row vector of two or more nonnegative integers orNaN
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
finddim | Find dimensions with specified label |
---|
Examples
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.
ans = 1×2 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: [8×1 nnet.cnn.layer.Layer]
Connections: [7×2 table]
Learnables: [8×3 table]
State: [2×3 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")
Version History
Introduced in R2022b