Batch Normalization Layer
Libraries:
Deep Learning Toolbox /
Deep Learning Layers /
Normalization Layers
Description
The Batch Normalization Layer block normalizes input data across all observations for each channel independently. To speed up training of the convolutional neural network and reduce the sensitivity to network initialization, use batch normalization layers between convolutional layers and nonlinearities, such as ReLU layers.
After normalization, the layer scales the input with a learnable scale factor γ and shifts it by a learnable offset β.
This block accepts data that has dimensions corresponding to the format that you specify with the Data format block parameter.
The exportNetworkToSimulink
function generates this block to represent a batchNormalizationLayer
object.
Ports
Input
Port_1 — Input data
array
Input data to normalize. The data must have dimensions corresponding to the format that you specify with the Data format block parameter.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fixed point
Output
Port_1 — Normalized output data
array
Normalized output data. The output data has dimensions corresponding to the format that you specify with the Data format block parameter.
Data Types: single
| double
| int8
| int16
| int32
| int64
| uint8
| uint16
| uint32
| uint64
| fixed point
Parameters
To edit block parameters interactively, use the Property Inspector. From the Simulink® Toolstrip, on the Simulation tab, in the Prepare gallery, select Property Inspector.
Main
Layer — Corresponding layer object
layer
(default) | batchNormalizationLayer
object
Specify the name of a workspace variable that contains a
batchNormalizationLayer
object from a trained network. The
Batch Normalization Layer block configures itself by using the
properties of the object and calculates the block output by using the learnable
parameters of the object.
Programmatic Use
Block Parameter:
Layer |
Type: workspace variable |
Values:
batchNormalizationLayer object |
Default:
'layer' |
Data format — Format of input data
SSC
(default) | C
| CT
| SC
| SSSC
Data format for the input data. The options use the same
notation as the fmt
argument of the
dlarray
object, except layer blocks do not support the Batch
(B
) dimension and instead assume an observation number of
1
.
Programmatic Use
Block Parameter:
DataFormat |
Type: character vector |
Values:
'SSC' | 'C' | 'CT' |
'SC' | 'SSSC' |
Default:
'SSC' |
Data Types
Output minimum — Minimum output value for range checking
[]
(default) | scalar
Lower value of the output range that the software checks.
The software uses the minimum to perform:
Parameter range checking (see Specify Minimum and Maximum Values for Block Parameters (Simulink)) for some blocks.
Simulation range checking (see Specify Signal Ranges (Simulink) and Enable Simulation Range Checking (Simulink)).
Automatic scaling of fixed-point data types.
Optimization of the code that you generate from the model. This optimization can remove algorithmic code and affect the results of some simulation modes such as SIL or external mode. For more information, see Optimize using the specified minimum and maximum values (Embedded Coder).
Tips
Output minimum does not saturate or clip the actual output signal. Use the Saturation (Simulink) block instead.
Programmatic Use
To set the block parameter value programmatically, use
the set_param
(Simulink) function.
Parameter: | OutMin |
Values: | '[]' (default) | scalar in quotes |
Output maximum — Maximum output value for range checking
[]
(default) | scalar
Upper value of the output range that the software checks.
The software uses the maximum value to perform:
Parameter range checking (see Specify Minimum and Maximum Values for Block Parameters (Simulink)) for some blocks.
Simulation range checking (see Specify Signal Ranges (Simulink) and Enable Simulation Range Checking (Simulink)).
Automatic scaling of fixed-point data types.
Optimization of the code that you generate from the model. This optimization can remove algorithmic code and affect the results of some simulation modes such as SIL or external mode. For more information, see Optimize using the specified minimum and maximum values (Embedded Coder).
Tips
Output maximum does not saturate or clip the actual output signal. Use the Saturation (Simulink) block instead.
Programmatic Use
To set the block parameter value programmatically, use
the set_param
(Simulink) function.
Parameter: | OutMax |
Values: | '[]' (default) | scalar in quotes |
Output data type — Data type of output
Inherit: Inherit via internal
rule
(default) | Inherit: Keep MSB
| Inherit: Keep LSB
| Inherit: Inherit via back propagation
| Inherit: Same as first input
| Inherit: Same as accumulator
| <data type expression>
Choose the data type for the output. The type can be inherited, specified directly, or expressed as a data type object such as Simulink.NumericType
. When you choose Inherit: Inherit via internal rule
,
Simulink chooses a data type to balance numerical accuracy, performance, and generated code
size, while taking into account the properties of the embedded target hardware.
Programmatic Use
To set the block parameter value programmatically, use
the set_param
(Simulink) function.
Parameter: | OutDataTypeStr |
Values: | 'Inherit: Inherit via internal
rule' (default) | 'Inherit: Keep MSB' | 'Inherit: Keep LSB' | 'Inherit: Inherit via back propagation' | 'Inherit: Same as first input' | 'Inherit: Same as accumulator' | <data type expression> |
Lock data type settings against changes by the fixed-point tools — Prevent fixed-point tools from overriding data types
off
(default) | on
Select this parameter to prevent the fixed-point tools from overriding the data types you specify on this block. For more information, see Lock the Output Data Type Setting (Fixed-Point Designer).
Programmatic Use
To set the block parameter value programmatically, use
the set_param
(Simulink) function.
Block Parameter: LockScale |
Type: character vector |
Values: 'off' | 'on' |
Default: 'off' |
Integer rounding mode — Rounding mode for fixed-point operations
Floor
(default) | Ceiling
| Convergent
| Nearest
| Round
| Simplest
| Zero
Specify the rounding mode for fixed-point operations. For more information, see Rounding Modes (Fixed-Point Designer).
Block parameters always round to the nearest representable value. To control the rounding of a block parameter, enter an expression using a MATLAB® rounding function into the mask field.
Programmatic Use
To set the block parameter value programmatically, use
the set_param
(Simulink) function.
Parameter: | RndMeth |
Values: | 'Floor' (default) | 'Ceiling' | 'Convergent' | 'Nearest' | 'Round' | 'Simplest' | 'Zero' |
Saturate on integer overflow — Method of overflow action
off
(default) | on
Specify whether overflows saturate or wrap.
on
— Overflows saturate to either the minimum or maximum value that the data type can represent.off
— Overflows wrap to the appropriate value that the data type can represent.
For example, the maximum value that the signed 8-bit integer int8
can represent is 127. Any block operation result greater than this maximum value causes overflow of the 8-bit integer.
With this parameter selected, the block output saturates at 127. Similarly, the block output saturates at a minimum output value of -128.
With this parameter cleared, the software interprets the overflow-causing value as
int8
, which can produce an unintended result. For example, a block result of 130 (binary 1000 0010) expressed asint8
is -126.
Tips
Consider selecting this parameter when your model has a possible overflow and you want explicit saturation protection in the generated code.
Consider clearing this parameter when you want to optimize efficiency of your generated code. Clearing this parameter also helps you to avoid overspecifying how a block handles out-of-range signals. For more information, see Troubleshoot Signal Range Errors (Simulink).
When you select this parameter, saturation applies to every internal operation on the block, not just the output or result.
In general, the code generation process can detect when overflow is not possible. In this case, the code generator does not produce saturation code.
Programmatic Use
To set the block parameter value programmatically, use
the set_param
(Simulink) function.
Parameter: | SaturateOnIntegerOverflow |
Values: | 'off' (default) | 'on' |
Trained mean — Data type of trained mean
Inherit: Inherit via back
propagation
(default) | Inherit: Inherit from 'Constant value'
| <data type expression>
The block casts the value of the TrainedMean
property of the
object that you specify with the Layer parameter to this data
type. The type can be inherited, specified directly, or expressed as a data type object such as Simulink.NumericType
.
Programmatic Use
To set the block parameter value programmatically, use
the set_param
(Simulink) function.
Parameter: | TrainedMeanDataTypeStr |
Values: | 'Inherit: Inherit via back
propagation' (default) | 'Inherit: Inherit from 'Constant value'' | <data type expression> |
Standard deviation — Data type of standard deviation
Inherit: Inherit via back
propagation
(default) | Inherit: Inherit from 'Constant value'
| <data type expression>
Choose the data type for the output of the Constant block
StandardDeviation
inside the Batch Normalization
Layer block. The type can be inherited, specified directly, or expressed as a data type object such as Simulink.NumericType
.
The Constant block computes the square root of the sum of the
values of the TrainedVariance
and Epsilon
properties of the object that you specify with the Layer
parameter.
Programmatic Use
To set the block parameter value programmatically, use
the set_param
(Simulink) function.
Parameter: | STDDataTypeStr |
Values: | 'Inherit: Inherit via back
propagation' (default) | 'Inherit: Inherit from 'Constant value'' | <data type expression> |
Scale — Data type of scale
Inherit: Inherit via back
propagation
(default) | Inherit: Inherit from 'Constant value'
| <data type expression>
The block casts the value of the Scale
property of the object
that you specify with the Layer parameter to this data type.
The type can be inherited, specified directly, or expressed as a data type object such as Simulink.NumericType
.
Programmatic Use
To set the block parameter value programmatically, use
the set_param
(Simulink) function.
Parameter: | ScaleDataTypeStr |
Values: | 'Inherit: Inherit via back
propagation' (default) | 'Inherit: Inherit from 'Constant value'' | <data type expression> |
Offset — Data type of offset
Inherit: Inherit via back propagation
(default) | Inherit: Inherit from 'Constant value'
| <data type expression>
The block casts the value of the Offset
property of the object that you
specify with the Layer parameter to this data type. The type can be inherited, specified directly, or expressed as a data type object such as Simulink.NumericType
.
Programmatic Use
To set the block parameter value programmatically, use
the set_param
(Simulink) function.
Parameter: | OffsetDataTypeStr |
Values: | 'Inherit: Inherit via back
propagation' (default) | 'Inherit: Inherit from 'Constant value'' | <data type expression> |
Accumulator — Data type of accumulator
Inherit: Inherit via internal
rule
(default) | Inherit: Same as first input
| <data type expression>
Choose the data type of the accumulator for the Add1
Addition block inside the Batch Normalization Layer
block. The type can be inherited, specified directly, or expressed as a data type object such as Simulink.NumericType
. When you choose Inherit: Inherit via internal rule
,
Simulink chooses a data type to balance numerical accuracy, performance, and generated code
size, while taking into account the properties of the embedded target hardware.
Programmatic Use
To set the block parameter value programmatically, use
the set_param
(Simulink) function.
Parameter: | AccumDataTypeStr |
Values: | 'Inherit: Inherit via internal
rule' (default) | 'Inherit: Same as first input' | <data type expression> |
Product output — Data type of product output
Inherit: Inherit via internal
rule
(default) | Inherit: Keep MSB
| Inherit: Match scaling
| Inherit: Inherit via back propagation
| Inherit: Same as first input
| <data type expression>
Choose the data type for the output of the Matrix Multiply block
inside the Batch Normalization Layer block. The type can be inherited, specified directly, or expressed as a data type object such as Simulink.NumericType
. When you choose Inherit: Inherit via internal rule
,
Simulink chooses a data type to balance numerical accuracy, performance, and generated code
size, while taking into account the properties of the embedded target hardware.
Programmatic Use
To set the block parameter value programmatically, use
the set_param
(Simulink) function.
Parameter: | ProductOutDataTypeStr |
Values: | 'Inherit: Inherit via internal
rule' (default) | 'Inherit: Keep MSB' | 'Inherit: Match scaling' | 'Inherit: Inherit via back propagation' | 'Inherit: Same as first input' | <data type expression> |
Execution
Sample time — Option to specify sample time
-1
(default) | scalar
Specify the discrete interval between sample time hits or specify another type of sample time, such as continuous (0
) or inherited (-1
). For more options, see Types of Sample Time (Simulink).
By default, the block inherits its sample time based upon the context of the block within the model.
Programmatic Use
Block Parameter: SampleTime |
Type: character vector |
Values: scalar |
Default: '-1' |
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Version History
Introduced in R2024b
MATLAB 명령
다음 MATLAB 명령에 해당하는 링크를 클릭했습니다.
명령을 실행하려면 MATLAB 명령 창에 입력하십시오. 웹 브라우저는 MATLAB 명령을 지원하지 않습니다.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list:
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)