Transforming h2o model into non-h2o one

倖福魔咒の 提交于 2019-12-08 16:49:07

问题


I know that there is possibility to export/import h2o model, that was previously trained.

My question is - is there a way to transform h2o model to a non-h2o one (that just works in plain R)?

I mean that I don't want to launch the h2o environment (JVM) since I know that predicting on trained model is simply multiplying matrices, applying activation function etc.

Of course it would be possible to extract weights manually etc., but I want to know if there is any better way to do it.

I do not see any previous posts on SA about this problem.


回答1:


No.

Remember that R is just the client, sending API calls: the algorithms (those matrix multiplications, etc.) are all implemented in Java.

What they do offer is a POJO, which is what you are asking for, but in Java. (POJO stands for Plain Old Java Object.) If you call h2o.download_pojo() on one of your models you will see it is quite straightforward. It may even be possible to write a script to convert it to R code? (Though it might be better, if you were going to go to that trouble, to convert it to C++ code, and then use Rcpp!)

Your other option is to export the weights and biases, in the case of deep learning, implement your own activation function, and use them directly.

But, personally, I've never found the Java side to be a bottleneck, either from the point of view of dev ops (install is easy) or computation (the Java code is well optimized).



来源:https://stackoverflow.com/questions/39215243/transforming-h2o-model-into-non-h2o-one

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!