Image3DInputLayer - 3-D image input layer - MATLAB (original) (raw)

Description

A 3-D image input layer inputs 3-D images or volumes to a neural network and applies data normalization.

For 2-D image input, use imageInputLayer.

Creation

Syntax

Description

`layer` = image3dInputLayer([inputSize](#mw%5F5244486b-0fe8-4dae-b34a-0a121c454a84)) returns a 3-D image input layer and specifies the InputSize property.

`layer` = image3dInputLayer([inputSize](#mw%5F5244486b-0fe8-4dae-b34a-0a121c454a84),[Name=Value](#namevaluepairarguments)) sets optional properties using one or more name-value arguments.

example

Input Arguments

expand all

Size of the input data, specified as a row vector of integers [h w d c], where h, w,d, and c correspond to the height, width, depth, and number of channels respectively.

For 2-D image input, use imageInputLayer.

Example: [132 132 116 3]

Name-Value Arguments

expand all

Specify optional pairs of arguments asName1=Value1,...,NameN=ValueN, where Name is the argument name and Value is the corresponding value. Name-value arguments must appear after other arguments, but the order of the pairs does not matter.

Before R2021a, use commas to separate each name and value, and enclose Name in quotes.

Example: image3dInputLayer([132 132 116 3],Name="input") creates a 3-D image input layer for 132-by-132-by-116 color 3-D images with name'input'.

Data normalization to apply every time data is forward propagated through the input layer, specified as one of the following:

This layer supports complex-valued data. (since R2024a) To input complex-valued data into the network, theNormalization option must be "zerocenter","zscore", "none", or a function handle.

Tip

The software, by default, automatically calculates the normalization statistics when you use the trainnet function. To save time when training, specify the required statistics for normalization and set the ResetInputNormalization option in trainingOptions to 0 (false).

The Image3DInputLayer object stores theNormalization property as a character vector or a function handle.

Normalization dimension, specified as one of the following:

The Image3DInputLayer object stores theNormalizationDimension property as a character vector.

Mean for zero-center and z-score normalization, specified as a_h_-by-_w_-by-_d_-by-c array, a 1-by-1-by-1-by-c array of means per channel, a numeric scalar, or [], where h, w,d, and c correspond to the height, width, depth, and the number of channels of the mean, respectively.

To specify the Mean property, the Normalization property must be"zerocenter" or "zscore". If Mean is [], then the software automatically sets the property at training or initialization time:

Before R2024a: This option does not support complex-valued data.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64
Complex Number Support: Yes

Standard deviation for z-score normalization, specified as a_h_-by-_w_-by-_d_-by-c array, a 1-by-1-by-1-by-c array of means per channel, a numeric scalar, or [], where h, w,d, and c correspond to the height, width, depth, and the number of channels of the standard deviation, respectively.

To specify the StandardDeviation property, the Normalization property must be"zscore". If StandardDeviation is [], then the software automatically sets the property at training or initialization time:

Before R2024a: This option does not support complex-valued data.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64
Complex Number Support: Yes

Minimum value for rescaling, specified as a_h_-by-_w_-by-_d_-by-c array, a 1-by-1-by-1-by-c array of minima per channel, a numeric scalar, or [], where h, w,d, and c correspond to the height, width, depth, and the number of channels of the minima, respectively.

To specify the Min property, the Normalization must be"rescale-symmetric" or "rescale-zero-one". If Min is [], then the software automatically sets the property at training or initialization time:

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

Maximum value for rescaling, specified as a_h_-by-_w_-by-_d_-by-c array, a 1-by-1-by-1-by-c array of maxima per channel, a numeric scalar, or [], where h, w,d, and c correspond to the height, width, depth, and the number of channels of the maxima, respectively.

To specify the Max property, the Normalization must be"rescale-symmetric" or "rescale-zero-one". If Max is [], then the software automatically sets the property at training or initialization time:

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

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

This argument sets the Name property.

Data Types: char | string

Properties

expand all

3-D Image Input

Size of the input data, specified as a row vector of integers [h w d c], where h, w,d, and c correspond to the height, width, depth, and number of channels respectively.

For 2-D image input, use imageInputLayer.

Example: [132 132 116 3]

Data normalization to apply every time data is forward propagated through the input layer, specified as one of the following:

This layer supports complex-valued data. (since R2024a) To input complex-valued data into the network, the Normalization option must be "zerocenter", "zscore","none", or a function handle.

Tip

The software, by default, automatically calculates the normalization statistics when you use the trainnet function. To save time when training, specify the required statistics for normalization and set the ResetInputNormalization option in trainingOptions to 0 (false).

The Image3DInputLayer object stores this property as a character vector or a function handle.

Normalization dimension, specified as one of the following:

The Image3DInputLayer object stores this property as a character vector.

Mean for zero-center and z-score normalization, specified as a_h_-by-_w_-by-_d_-by-c array, a 1-by-1-by-1-by-c array of means per channel, a numeric scalar, or [], where h, w,d, and c correspond to the height, width, depth, and the number of channels of the mean, respectively.

To specify the Mean property, the Normalization property must be "zerocenter" or "zscore". If Mean is[], then the software automatically sets the property at training or initialization time:

Before R2024a: This option does not support complex-valued data.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64
Complex Number Support: Yes

Standard deviation for z-score normalization, specified as a_h_-by-_w_-by-_d_-by-c array, a 1-by-1-by-1-by-c array of means per channel, a numeric scalar, or [], where h, w,d, and c correspond to the height, width, depth, and the number of channels of the standard deviation, respectively.

To specify the StandardDeviation property, theNormalization property must be"zscore". If StandardDeviation is[], then the software automatically sets the property at training or initialization time:

Before R2024a: This option does not support complex-valued data.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64
Complex Number Support: Yes

Minimum value for rescaling, specified as a_h_-by-_w_-by-_d_-by-c array, a 1-by-1-by-1-by-c array of minima per channel, a numeric scalar, or [], where h, w,d, and c correspond to the height, width, depth, and the number of channels of the minima, respectively.

To specify the Min property, the Normalization must be "rescale-symmetric" or"rescale-zero-one". If Min is[], then the software automatically sets the property at training or initialization time:

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

Maximum value for rescaling, specified as a_h_-by-_w_-by-_d_-by-c array, a 1-by-1-by-1-by-c array of maxima per channel, a numeric scalar, or [], where h, w,d, and c correspond to the height, width, depth, and the number of channels of the maxima, respectively.

To specify the Max property, the Normalization must be "rescale-symmetric" or"rescale-zero-one". If Max is[], then the software automatically sets the property at training or initialization time:

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

Layer

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, stored as 1. This layer has a single output only.

Data Types: double

This property is read-only.

Output names, stored as {'out'}. This layer has a single output only.

Data Types: cell

Examples

collapse all

Create a 3-D image input layer for 132-by-132-by-116 color 3-D images

layer = image3dInputLayer([132 132 116])

layer = Image3DInputLayer with properties:

                  Name: ''
             InputSize: [132 132 116 1]

Hyperparameters Normalization: 'zerocenter' NormalizationDimension: 'auto' Mean: []

Include a 3-D image input layer in a Layer array.

layers = [ image3dInputLayer([28 28 28 3]) convolution3dLayer(5,16,Stride=4) reluLayer maxPooling3dLayer(2,Stride=4) fullyConnectedLayer(10) softmaxLayer]

layers = 6×1 Layer array with layers:

 1   ''   3-D Image Input   28×28×28×3 images with 'zerocenter' normalization
 2   ''   3-D Convolution   16 5×5×5 convolutions with stride [4  4  4] and padding [0  0  0; 0  0  0]
 3   ''   ReLU              ReLU
 4   ''   3-D Max Pooling   2×2×2 max pooling with stride [4  4  4] and padding [0  0  0; 0  0  0]
 5   ''   Fully Connected   10 fully connected layer
 6   ''   Softmax           softmax

Algorithms

expand all

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:

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).

The input layer of a network specifies the layout of the data that the network expects. If you have data in a different layout, then specify the layout using the InputDataFormats training option.

The layer inputs_h_-by-_w_-by-_d_-by-_c_-by-N arrays to the network, where h, w,d, and c are the height, width, depth, and number of channels of the images, respectively, and N is the number of images. Data in this layout has the data format "SSSCB" (spatial, spatial, spatial, channel, batch).

Image3DInputLayer objects support passing complex-valued data to subsequent layers. (since R2024a)

If the input data is complex-valued, then the Normalization option must be "zerocenter", "zscore","none", or a function handle. The Mean andStandardDeviation properties of the layer also support complex-valued data for "zerocenter" and "zscore" normalization options.

For an example showing how to train a network with complex-valued data, see Train Network with Complex-Valued Data.

Version History

Introduced in R2019a

expand all

For complex-valued input to the neural network, the layer passes complex-valued data to subsequent layers.

If the input data is complex-valued, then the Normalization option must be "zerocenter", "zscore","none", or a function handle. The Mean andStandardDeviation properties of the layer also support complex-valued data for "zerocenter" and "zscore" normalization options.

AverageImage will be removed. Use Mean instead. To update your code, replace all instances of AverageImage with Mean. There are no differences between the properties that require additional updates to your code.

Starting in R2019b, imageInputLayer and image3dInputLayer, by default, use channel-wise normalization. In previous versions, these layers use element-wise normalization. To reproduce this behavior, set the NormalizationDimension option of these layers to'element'.