Is code generation supported for "convolution1DLayer"?

5 vues (au cours des 30 derniers jours)
MathWorks Support Team
MathWorks Support Team le 14 Déc 2022
Is code generation supported for "convolution1DLayer"?

Réponse acceptée

MathWorks Support Team
MathWorks Support Team le 29 Août 2024
Modifié(e) : MathWorks Support Team le 30 Août 2024
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 commentaires
Steven Lord
Steven Lord le 7 Août 2024
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 le 20 Août 2024
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.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Deep Learning Toolbox dans Help Center et File Exchange

Produits


Version

R2024a

Community Treasure Hunt

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

Start Hunting!

Translated by