C coder with Machine Learning model weight parameters

2 views (last 30 days)
Hi there,
I'm currently developing AI models using MATLAB C coder.
I've succeeded in converting our AI model (which includes a BiLSTM network) into C code.
However, is there any method to change only the weight parameters without generating the code again?
The neural network structure will not be changed, but the trained weight parameters need to be updated after training the network with additional datasets.
Here is the output c code with weight parameters.
Thanks a lot!

Accepted Answer

Sayan Saha
Sayan Saha on 5 Dec 2023
Hello,
From the generated code it looks like you are generating code for a deep learning network with TargetLibrary = 'none' set in the coder.config() object. Currently it is not possible to update the weights of the network embedded in the generated code for TargetLibrary = 'none'. For other deep learning target libraries, like "mkldnn/arm-compute/cudnn/tensorrt" we do support updating the weights values after code has been generated using the coder.regenerateDeepLearningParameters function. For these target libraries the weights values are generated in separate binary files which are updated using the above-mentioned function. Here is an example of that workflow of updating only the weights files without having to codegen again: https://www.mathworks.com/help/coder/ug/post-codegen-network-learnables-update-raspberrypi.html Note that using these deep learning libraries does not support C code generation.
We will consider enhancing the code generation support with TargetLibrary = 'none' to support only updating the weights in a future release. However, I'd like to understand your workflow better to gather requirements for such an enhancement. Can you elaborate on your workflow? What is the motivation to update weights for already deployed code? Are you deploying code to any hardware? Should the updating of weights happen as the deployed code is already running or is it possible to restart the executable for the update to take place?
Thanks,
Sayan

More Answers (0)

Community Treasure Hunt

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

Start Hunting!