1D-Convolution Layer not supported by calibrate function
40 views (last 30 days)
Show older comments
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 Comments
Hariprasad Ravishankar
on 5 Nov 2024 at 14:39
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
Answers (0)
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!