Is code generation supported for "convolution1DLayer"?

조회 수: 9 (최근 30일)
Is code generation supported for "convolution1DLayer"?

채택된 답변

MathWorks Support Team
MathWorks Support Team 2024년 8월 29일
편집: MathWorks Support Team 2024년 8월 30일
For MATLAB R2024a and later, code generation is supported for "convolution1DLayer". Please note that code generation is only supported for generating generic C/C++ code that does not depend on third-party libraries.
For MATLAB versions before R2024a, there are several potential workarounds for this issue, dependent on the purpose of 1-D Convolutional Layer being used.
Workaround: Use "convolution2dLayer" and set the "height" property to 1Requisite: The layer performs spatial convolution rather than temporal convolution
Spatial convolution refers to analysis within physical dimensions, for example, inspecting a standalone 2-D image input. Temporal convolution refers to time-dependent input data to the layer, where the layer inspects for patterns as a function of time. In the first case, spatial convolution, the "convolution2dLayer" method with "height" set to 1 in the "filterSize" input will perform in the same way. See this page for documentation on the "convolution2dLayer" method:
Workaround: Create a custom layer that achieves the same behaviourRequisite: Execution time is not an important requirement
Code generation from custom layers is supported by the MATLAB compiler, and so the user can define their own custom layer to perform the same functionality as the "convolution1dLayer" method. The user would then directly replace the "convolution1dLayer" in their network with their own "customLayer". Documentation on how to define a custom layer can be found on the following documentation page.
Workaround: Use a Long Short-Term Memory (LSTM) layer to achieve the same behaviourRequisite: Specific to certain use cases
The two documentation links below show a 1-D Convolutional layer and a LSTM layer being used to classify the same sequential data.
Workaround: Permuting the input data to transpose temporal convolution into spatial convolution.
Requisite: Specific to certain use cases
In some use cases, it may be possible to use the first solution, "convolution2dLayer", with temporal input data, contrary to the information above. However, the data must be permuted first so that, when the "height" component of the "filterSize" of the input is set to 1, it is applied to the temporal component rather than the spatial component. Therefore, 3 layers are required to perform the convolution.
        1. An initial layer to permute the input data.
2. "convolution2dLayer" with "height" set to 1 in the "filterSize" property.
3. A final layer to permute the classified data back to its original state.
  댓글 수: 2
Steven Lord
Steven Lord 2024년 8월 7일
According to the Deep Learning Toolbox Release Notes, it appears that code generation support for convolution1dLayer (and several other layers) was added in release R2024a.
Sayan Saha
Sayan Saha 2024년 8월 20일
Note that, code generation support for convolution1dLayer added in MATLAB R2024a was only for TargetLibrary = 'none' that generates code for the layer without depending on third party deep learning libraries. Code generation for this layer for deep learning libraries like cudnn/tensorrt/mkldnn/arm-compute is not supported.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Deep Learning Toolbox에 대해 자세히 알아보기

제품


릴리스

R2024a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by