c++ - 将权重和参数从 matlab 导出到 C++

标签 c++ matlab machine-learning classification multilabel-classification

我使用 tree bagger 函数为获得的训练分类器创建随机森林模型。

使用函数:

 %Create a Random Forest model with 100 trees,
  randomfmodel = TreeBagger(...............)

有没有一种方法可以导出直接生成的模型值(以值和权重的形式),以便它可以在 C++ 平台上使用。

我读到 matlab 运行时很大,基本上这就是为什么我想使用从 matlab 模型生成的权重和参数然后将其导出并编写代码以在 C++ 中测试新数据的原因 我试图避免重写 C++ 中的代码进行训练。 (使用来自 matlab 的模型值将帮助我直接测试新数据。)

我在 matlab 中有一个 randomfmodel.mat 文件。有没有一种方法可以导出所有权重,以便我可以用 C++ 重写一个函数来使用它来测试新数据?

最佳答案

我自己没有尝试过,但发现了以下内容。 文件的描述完全符合您的要求: https://github.com/kenders2000/decisionTreeMat2Cpp

https://github.com/dhasenfratz/TreeBagger-Matlab2Cpp

This program takes a decision tree trained in Matlab using TreeBagger or the classification tree function ClassificationTree and outputs the header file decTreeConstants.h containing all the branch information. This header file is used by the attached C++ class to make decisions based on presented features in deployed applications.

This is useful for deploying code developed in Matlab into embedded applications where Matlab is not available and no input files can be read.

关于c++ - 将权重和参数从 matlab 导出到 C++,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41212901/

相关文章:

c++ - 为什么模板中的 static_assert 使用等效表达式会给我不同的结果?

c++ - 如何将 NULL 字符 '\0' 写入文本文件

matlab - 最佳拟合散点图线

arrays - 从数组设置对象数组中的属性

machine-learning - 回归问题的降维/降噪技术

r - 如何使用 R 将两个或多个变量转换(计算)为一个?

C++ - 选择最大 "n"值

c++ - OpenGL 着色器拒绝链接

c++ - 如何将 MATLAB 的 mex 设置定向到用于 C++ 编译的 Microsoft Windows SDK? (位置设置错误)

nlp - 如何将 reuters-21578 数据集与 svm.net 一起使用进行文本分类?