main content

代码生成 -凯发k8网页登录

为 statistics and machine learning toolbox™ 函数生成 c/c 代码和 mex 函数

matlab® coder™ 可从支持代码生成的 statistics and machine learning toolbox 函数中生成可读且可移植的 c 代码和 c 代码。例如,您可以利用代码生成,将经过训练的支持向量机 (svm) 分类模型部署到不能运行 matlab 的硬件设备上,在这些硬件设备上对新观测值进行分类。

您可以通过多种方式为这些函数生成 c/c 代码:

  • 对机器学习模型的对象函数使用 savelearnerforcoderloadlearnerforcodercodegen (matlab coder)

  • 对机器学习模型的 predictupdate 对象函数使用由 learnercoderconfigurer 创建的代码生成器配置器。使用配置器配置代码生成选项,并在生成代码中更新模型参数。

  • 对于支持代码生成的其他函数,使用 codegen

您还可以生成定点 c/c 代码,用于预测一些机器学习模型。这种类型的代码生成需要 fixed-point designer™。

要将机器学习模型的预测集成到 simulink® 中,请使用 statistics and machine learning toolbox 库中的 matlab function 模块或 simulink 模块。

要了解代码生成,请参阅introduction to code generation

有关支持代码生成的函数的列表,请参阅。

函数

savelearnerforcodersave model object in file for code generation
loadlearnerforcoderreconstruct model object from saved model for code generation
generatelearnerdatatypefcngenerate function that defines data types for fixed-point code generation

创建代码生成器配置器对象

learnercoderconfigurercreate coder configurer of machine learning model

使用代码生成器配置器对象

generate c/c code using coder configurer
generate matlab files for code generation using coder configurer
validate and extract machine learning model parameters to update
updateupdate model parameters for code generation

对象

coder configurer of binary decision tree model for multiclass classification
coder configurer for support vector machine (svm) for one-class and binary classification
coder configurer for linear binary classification of high-dimensional data
coder configurer for multiclass model using binary learners
coder configurer of binary decision tree model for regression
coder configurer for support vector machine (svm) regression model
coder configurer for linear regression model with high-dimensional data

模块

classify observations using error-correcting output codes (ecoc) classification model
classify observations using ensemble of decision trees
classify observations using nearest neighbor classification model
classify observations using linear classification model
classify observations using neural network classification model
classificationsvm predictclassify observations using support vector machine (svm) classifier for one-class and binary classification
classify observations using decision tree classifier
predict responses using ensemble of decision trees for regression
predict responses using gaussian process (gp) regression model
使用线性回归模型预测响应
predict responses using neural network regression model
使用支持向量机 (svm) 回归模型预测响应
predict responses using regression tree model

主题

代码生成工作流

  • introduction to code generation
    learn how to generate c/c code for statistics and machine learning toolbox functions.

  • generate code for statistics and machine learning toolbox functions that do not use machine learning model objects.

  • generate code for the prediction of a classification or regression model at the command line.

  • generate code that implements incremental learning for binary linear classification at the command line.

  • generate code for the prediction of a classification or regression model by using the matlab coder app.
  • code generation for prediction and update using coder configurer
    generate code for the prediction of a model using a coder configurer, and update model parameters in the generated code.

  • generate code that accepts input arguments whose size might change at run time.

  • generate code for classifying data in a table containing numeric and categorical variables.

  • convert categorical predictors to numeric dummy variables before fitting an svm classifier and generating code.
  • fixed-point code generation for prediction of svm
    generate fixed-point code for the prediction of an svm classification or regression model.

  • train a classification model using the classification learner app, and generate c/c code for prediction.

  • generate code for finding nearest neighbors using a nearest neighbor searcher model.

  • generate code that fits a probability distribution object to sample data and evaluates the fitted distribution object.

  • this example shows how to train a binary glm logistic regression model using classification learner, and then generate c code that predicts labels using the exported classification model.

  • generate single-precision code that detects anomalies in data using a trained isolation forest model or one-class svm.

分类和回归预测模块

  • predict class labels using classificationsvm predict block
    this example shows how to use the classificationsvm predict block for label prediction in simulink®.

  • train a classification decision tree model using the classification learner app, and then use the classificationtree predict block for label prediction.

  • this example shows how to use the classificationlinear predict block for label prediction in simulink®.

  • train an ecoc classification model, and then use the classificationecoc predict block for label prediction.

  • train a classification ensemble model with optimal hyperparameters, and then use the classificationensemble predict block for label prediction.

  • train a neural network classification model, and then use the classificationneuralnetwork predict block for label prediction.

  • train a nearest neighbor classification model, and then use the classificationknn predict block for label prediction.
  • predict responses using regressionsvm predict block
    train a support vector machine (svm) regression model using the regression learner app, and then use the regressionsvm predict block for response prediction.

  • this example shows how to use the regressiontree predict block for response prediction in simulink®.

  • this example shows how to use the regressionlinear predict block for response prediction in simulink®.

  • train a regression ensemble model with optimal hyperparameters, and then use the regressionensemble predict block for response prediction.

  • train a neural network regression model, and then use the regressionneuralnetwork predict block for response prediction.

  • train a gaussian process (gp) regression model, and then use the regressiongp predict block for response prediction.

代码生成应用程序

  • predict class labels using matlab function block
    generate code from a simulink model that classifies data using an svm model.
  • system objects for classification and code generation
    generate code from a system object™ for making predictions using a trained classification model, and use the system object in a simulink model.
  • predict class labels using stateflow
    generate code from a stateflow® model that classifies data using a discriminant analysis classifier.

  • generate code from a classification simulink model prepared for fixed-point deployment.
  • (simulink support package for arduino hardware)
    this example shows how to use the simulink® support package for arduino® hardware to identify punch and flex hand gestures using a machine learning algorithm.

  • predict in simulink using a neural network regression model, and deploy the simulink model to an fpga/asic platform by using hdl code generation.
网站地图