Compiled matlab function does not recognize 'predict' function from the statistics and machine learning toolbox
Mostrar comentarios más antiguos
Hi,
I have a very simple matlab function that calls the predict function (statistics and machine learning toolbox) to calculate a value (The model I use is a linear regression model if that matters). Whe I run the function in the matlab console, everything works perfectly fine. However, after compiling and executing the function I get the following error: Unrecognized function or variable 'predict'
I'm using MATLAB R2021 on a linux server. The command to compile the matlab function is: /usr/local/MATLAB/R2021b/bin/mcc -o predict_test -W main:predict_test -T link:exe -d build/ -v predict_test.m
Is there something wrong the way I compile the function?
Thanx!
Respuestas (1)
Steven Lord
el 18 de Abr. de 2023
0 votos
How are you creating or obtaining the first input you pass to predict? My suspicion is that you're loading an object from a MAT-file then calling predict with that object as the first input.
If that's the case you need to tell MATLAB Compiler that it needs to include the definition of the class of that object when it creates the application as per the Tip in the second section on this documentation page.
7 comentarios
Iris
el 18 de Abr. de 2023
Walter Roberson
el 21 de Abr. de 2023
As we said already in https://www.mathworks.com/matlabcentral/answers/1949593-how-to-install-deep-learning-toolbox-in-matlab-runtime#comment_2713273
you probably need to include the comment
%#function SeriesNetwork
The %#function is literal there -- do not replace function by some other word. The SeriesNetwork part is the name of the MATLAB class of the kind of network that you created. The other major possibility is DAGNetwork
bo
el 21 de Abr. de 2023
do you mean I add following comment before load?
%#function DAGNetwork
Walter Roberson
el 21 de Abr. de 2023
Yes, for the case you are using a DAGNetwork. What does class() of the saved network show?
bo
el 21 de Abr. de 2023
The class(network) show 'DAGNetwork'.
MATLAB report error when load the net.
>> load('DAGnet.mat')
Warning: Unable to load instances of class nnet.onnx.layer.ElementwiseAffineLayer into a heterogeneous array. The definition of nnet.onnx.layer.ElementwiseAffineLayer could be missing or contain an error. Default objects will be substituted.
Walter Roberson
el 21 de Abr. de 2023
You could try adding
%#function nnet.onnx.layer.ElementwiseAffineLayer
Categorías
Más información sobre Support Vector Machine Regression en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!