1D-Convolution Layer not supported by calibrate function
Mostra commenti meno recenti
Good morning,
I am trying to follow this example: https://it.mathworks.com/help/coder/ug/generate-code-for-quantized-lstm-network-and-deploy-on-cortex-m-target.html on how to generate an Int8 Code for an implementation in a STM32.
My network is composed by the following layers:
6×1 Layer array with layers:
1 'input' Sequence Input Sequence input with 1 dimensions
2 'conv1' 1-D Convolution 10 8×1 convolutions with stride 1 and padding 'same'
3 'batchnorm1' Batch Normalization Batch normalization with 10 channels
4 'relu1' ReLU ReLU
5 'gru1' Projected Layer Projected GRU with 32 hidden units
6 'output' Projected Layer Projected fully connected layer with output size 1
When I try to calibrate the network as described in the example, I have the following error showing that the 1D-convolutional layer is not supported in the CPU environment: "Code generation for conv1 is not supported for target library 'mkldnn'. See documentation for a list of supported layers with each target library."
Can I solve this problem without having to change the 1D-convolutional layer?
Thank you in advance,
Silvia
5 Commenti
Silvia
il 14 Ott 2024
Hariprasad Ravishankar
il 14 Ott 2024
The Deep Learning Toolbox does not support quantizing convolution1dLayer or generating code for quantized convolution1dLayer as of R2024b.
However, you can still deploy your unquantized (single-precision compute) network to Cortex-M by generating plain C code and customizing it using the Cortex-M Code replacement library option.
You can specify 'None' as the TargetLibrary when creating a DeepLearningConfig to specify no 3p deep learning libraries (Generate plain C) as follows:
cfg.DeepLearningConfig = coder.DeepLearningConfig('TargetLibrary', 'none');
You can specify the Code Replacement Library for Cortex-M as follows:
cfg.CodeReplacementLibrary = 'ARM Cortex-M (CMSIS)';
Please take a look at this example for more details:
Silvia
il 5 Nov 2024
Hariprasad Ravishankar
il 5 Nov 2024
For code generation we expect the input to predict to be a dlarray. Please try modifying your function as follows:
function out = FinalFineTuned_predict(in) %#codegen
% A persistent object mynet is used to load the series network object.
% At the first call to this function, the persistent object is constructed and
% setup. When the function is called subsequent times, the same object is reused
% to call predict on inputs, thus avoiding reconstructing and reloading the
% network object.
% Copyright 2019-2021 The MathWorks, Inc.
persistent mynet;
if isempty(mynet)
mynet = coder.loadDeepLearningNetwork('FinalFineTuned.mat');
end
% pass in input
% We first cast the 'double' input to 'single' as code-generation only supports 'single' precision compute for dlnetwork.
% We specify the format of input as 'TC' to indicate that the first
% dimension is 'Time' and second dimension is 'channel'.
outDlarray = predict(mynet, dlarray(single(in), 'TC');
% We extract data from the dlarray to get back the result in 'single'
% datatype.
out = extractdata(outDlarray);
end
Risposte (0)
Categorie
Scopri di più su Quantization, Projection, and Pruning in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!