Convolution 1D Layer
Libraries:
Deep Learning Toolbox /
Deep Learning Layers /
Convolution and Fully Connected Layers
Description
The Convolution 1D Layer block applies sliding convolutional filters to 1-D input. The layer convolves the input by moving the filters along the input and computing the dot product of the weights and the input, then adding a bias term.
The dimension that the layer convolves over depends on the layer input:
For time series and vector sequence input in the
CT
format (two dimensions corresponding to channels and time steps, in that order), the layer convolves over the time dimension.For 1-D image input in the
SC
format (two dimensions corresponding to spatial pixels and channels, in that order), the layer convolves over the spatial dimension.
The exportNetworkToSimulink
function generates this block to represent a convolution1dLayer
object.
Limitations
The Layer parameter has limited support for the
'manual'
padding mode and does not support the'causal'
padding mode. It is recommended to use aconvolution1dLayer
object that has thePaddingMode
property set to'same'
.The Layer parameter does not support
convolution1dLayer
objects that have thePaddingValue
property set to"symmetric-exclude-edge"
. If you specify an object that uses that padding value, the block produces a warning and uses the value"symmetric-include-edge"
instead.The Layer parameter does not support
convolution1dLayer
objects that have theDilationFactor
property set to a value other than1
.
Ports
Input
Input data on which to perform the convolution operation. The data must have two 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
The result of convolving the input data. The output data has two 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
Specify the name of a workspace variable that contains a
convolution1dLayer
object from a trained network. The
Convolution 1D 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:
convolution1dLayer object |
Default:
'layerObject' |
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:
'CT' | 'SC' |
Default:
'CT' |
Data Types
Minimum value of the output range that the software checks.
The software uses the minimum value to perform:
Parameter range checking for some blocks. For more information, see Specify Minimum and Maximum Values for Block Parameters (Simulink).
Simulation range checking. For more information, 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 |
Maximum value of the output range that the software checks.
The software uses the maximum value to perform:
Parameter range checking for some blocks. For more information, see Specify Minimum and Maximum Values for Block Parameters (Simulink).
Simulation range checking. For more information, 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 |
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 select 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> |
Select this parameter to prevent the fixed-point tools from overriding the Output data type you specify on the block. For more information, see Use Lock Output Data Type Setting (Fixed-Point Designer).
Programmatic Use
To set the block parameter value programmatically, use
the set_param
(Simulink) function.
Parameter: | LockScale |
Values: | 'off' (default) | 'on' |
Specify the rounding mode for the output value of the block, generated by the final fixed-point cast operation. For the rounding mode for the other internal block operations, see Internal integer rounding mode. 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 in 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' |
Specify whether integer overflows saturate or wrap for the output value of the block, generated by the final fixed-point cast operation. For the method of overflow action of the internal block operations, see Internal saturate on integer overflow.
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 the 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
Set this parameter to
on
when your model has a possible overflow and you want explicit saturation protection in the generated code.To optimize the efficiency of your generated code, keep the default
off
setting for this parameter. Using the default setting also helps you avoid overspecifying how the block handles out-of-range signals. For more information, see Troubleshoot Signal Range Errors (Simulink).When you select this parameter, saturation applies to only the output or the 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' |
The block casts the value of the Weights
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: | WeightsDataTypeStr |
Values: | 'Inherit: Inherit via back
propagation' (default) | 'Inherit: Inherit from 'Constant value'' | <data type expression> |
The block casts the value of the Bias
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: | BiasDataTypeStr |
Values: | 'Inherit: Inherit via back
propagation' (default) | 'Inherit: Inherit from 'Constant value'' | <data type expression> |
Choose the data type of the accumulator for each Convolution block
inside the Convolution 1D Layer block. The type can be inherited, specified directly, or expressed as a data type object such as Simulink.NumericType
. When you select 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> |
Specify the rounding mode for internal fixed-point computations except for the output operation. For the rounding mode of the output operation, see Output integer rounding mode. 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 in the mask field.
Programmatic Use
To set the block parameter value programmatically, use
the set_param
(Simulink) function.
Parameter: | InternalRndMeth |
Values: | 'Floor' (default) | 'Ceiling' | 'Convergent' | 'Nearest' | 'Round' | 'Simplest' | 'Zero' |
Specify whether integer overflows saturate or wrap for the internal operations of the block. For the method of overflow action of the block output, see Output saturate on integer overflow.
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 the 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
Set this parameter to
on
when your model has a possible overflow and you want explicit saturation protection in the generated code.To optimize the efficiency of your generated code, keep the default
off
setting for this parameter. Using the default setting also helps you avoid overspecifying how the block handles out-of-range signals. For more information, see Troubleshoot Signal Range Errors (Simulink).When you select this parameter, saturation applies just to internal operations of the block.
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: | InternalSaturateOnIntegerOverflow |
Values: | 'off' (default) | 'on' |
Execution
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 on the context of the block within the model.
Programmatic Use
To set the block parameter value
programmatically, use the set_param
(Simulink) function.
Parameter:
SampleTime |
Data Types:
char |
Values:
'-1' (default) | scalar |
Extended Capabilities
C/C++ Code Generation
Generate C and C++ code using Simulink® Coder™.
Version History
Introduced in R2024bStarting in R2025a, the default value for the Layer parameter is 'layerObject'
. In previous versions, the default value is 'layer'
. If you have code that programmatically creates Simulink and relies on variables with the name 'layer'
, update your code so that the variable has the name 'layerObject'
.
The Integer rounding mode and Saturate integer overflow parameters are now split into output and internal versions of the parameters. Output integer rounding mode and Output saturate on integer overflow control the behavior of the final cast operation of the output of the block. Internal integer rounding mode and Internal saturate on integer overflow control the internal block operations.
MATLAB Command
You clicked a link that corresponds to this MATLAB command:
Run the command by entering it in the MATLAB Command Window. Web browsers do not support MATLAB commands.
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: United States.
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)