简体   繁体   English

R nnet模型作为等式,可在其他编程语言中使用

[英]R nnet model as an equation for use in other programming languages

I've successfully created the model in RStudio using nnet. 我已经使用nnet在RStudio中成功创建了模型。
But now I need to code it up in Java. 但是现在我需要用Java编写代码。 I presume I could take the weights (wts) and build up the equations necessary for the activation functions, but I hope that someone has already written a function to do this. 我想我可以权重(wts)并建立激活函数所需的方程,但是我希望有人已经编写了一个函数来执行此操作。

How do people typically take their R model and implement them in C, Java, etc? 人们通常如何采用他们的R模型并用C,Java等实现它们?

str(mynn) gives:

List of 18
$ n            : num [1:3] 1 2 1
    $ nunits       : int 5
$ nconn        : num [1:6] 0 0 0 2 4 7
    $ conn         : num [1:7] 0 1 0 1 0 2 3
$ nsunits      : num 4
    $ decay        : num 0.02
$ entropy      : logi FALSE
    $ softmax      : logi FALSE
$ censored     : logi FALSE
    $ value        : num 26466497
$ wts          : num [1:7] 6.422 -0.433 -11.771 2.086 -12001.039 ...
    $ convergence  : int 0

etc... 等等...

Perhaps this has been asked before, but hours of google searches has not revealed the answer. 也许以前有人问过这个问题,但是经过数小时的Google搜索并没有找到答案。

Thank you for your help. 谢谢您的帮助。 I greatly appreciate it. 我非常感谢。

One approach is to use PMML . 一种方法是使用PMML The CRAN package pmml supports exporting nnet models: CRAN软件包pmml支持导出nnet模型:

library(caret)
library(nnet)
library(pmml)

model <- train(
  Sepal.Length~., iris, 
  method='nnet', trace=FALSE, 
  trControl=trainControl(verboseIter=TRUE))
pmml(model$finalModel)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM