How can I make a file containing only weights when using codegen

2 views (last 30 days)
I did code generation using following command
" codegen -config cfg my_predict -args {inputData} -report "
In the codegen files, there are weights for deeplearning network as shown in below picture.
However, I do not want the weights to be in ".c" file.
I want to make an external file that contains only weights.
Is there a way I can do?
I will be waiting for your reply.
Thank you.

Answers (1)

Sayan Saha
Sayan Saha on 3 Dec 2023
Edited: Sayan Saha on 3 Dec 2023
Hello,
Looking at the generated code I assume you are generating code for the deep learning network with "TargetLibrary = none" set in the coder configuration object. Currently, it is not possible to generate the weights in a separate file with "TargetLibrary = none" setting. In the upcoming release, we are going to provide an option that will generate the weights in a separate binary file. For now, if you want to generate the weights separately, you'll have to use a "TargetLibrary" other than "none", for example, "mkldnn/arm-compute" for CPU targets or "cudnn/tensorrt" for GPU targets. For these target libraries, the weights are always generated in a separate binary file. Here's the documentation page for how to generate code for "mkldnn" https://www.mathworks.com/help/coder/ug/code-generation-for-deep-learning-networks-with-mkl-dnn.html. Note that the entire process of generating code remains the same, except for setting the "DeepLearningConfig" on the coder configuration object.
Hope this helps,
Sayan

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!