jpmml / jpmml-converter

Java library for authoring PMML
GNU Affero General Public License v3.0
15 stars 4 forks source link

support tensorflow #5

Closed ElianoMarques closed 7 years ago

ElianoMarques commented 7 years ago

Hi guys, I wonder if you guys have in the roadmap the conversion of tensorflow models into pmml?

Thank you, Eliano

vruusmann commented 7 years ago

Support for deep neural networks (Tensorflow and possibly some others) is the logical next step for JPMML-family of software. However, the timeline is not very clear, as there is so much work to do in current focus areas.

Supposedly, there will be a JPMML-Tensorflow library, that will be able to de-serialize and convert DNN models from Tensorflow representation to PMML representation. This library will then be integrated into "end user"-friendly libraries such as JPMML-R and JPMML-SkLearn. For example, you could train a Tensorflow model using SkFlow, and then convert it using the sklearn2pmml package just like any other Scikit-Learn estimator.

vruusmann commented 7 years ago

On a side note, PMML should be able to represent most common DNN topologies without problem. For example, there are converters for Scikit-Learn's MLPRegressor and MLPClassifier estimator types, and Apache Spark's MultilayerPerceptronClassificationModel model type.

And if there really are some DNN features/topologies that don't have PMML mappings at the moment, then both the PMML specification and the JPMML-family of software are easily extensible.

ElianoMarques commented 7 years ago

@vruusmann thanks for that. makes total sense and happy to know you have this in roadmap. Skflow has been merged into contrib.learn in tensor flow, doesn't change your point at all. very keen to continue to leverage your framework going forward, great stuff guys!

mhnatiuk commented 7 years ago

Hi, any news on that issue? I'd love to be able to deploy tensorflow models via OpenScoringAPI. An ideal solution would include serving tensorflow "pb" files via OpenScoringAPI. What can I do to help here?

ElianoMarques commented 7 years ago

@vruusmann just checking if there any updates on this?

vruusmann commented 7 years ago

@ElianoMarques I am working on the JPMML-TensorFlow library at this very moment. Expecting to make the prototype available for my customers already next week.

The starting point for conversion is TF's "SavedModel" directory: https://www.tensorflow.org/api_docs/python/tf/estimator/Estimator#export_savedmodel

ElianoMarques commented 7 years ago

Awesome, thank you very much for this. would you mind to share so i could give a test too?

would you plan to support keras too?

chandu1234567 commented 7 years ago

@ElianoMarques , love to know DL model deployment progress. Got to know about Zemantis -ADAPA and UPPI proprietary tools http://zementis.com/solutions/by-platform/deep-learning/ but at Open Source level , these things are really help full. Any Work around this is highly appreciated.

Please update / help in converting a DL Model into a PMML and then to make use of the same in production Environment .

Thks

ElianoMarques commented 7 years ago

@vruusmann any chance i could get access and try it out? That would be awesome!

blublinsky commented 7 years ago

@vruusmann I would be interested in testing it as well. Also, why did you decide to use "SavedModel" directory approach? Its great for continuation of learning or using multiple model with common calculation, but it is far from optimal for serving due to its size. Freezing and optimizing TF graph can provide significantly smaller graph and consequently smaller model

vruusmann commented 7 years ago

@blublinsky I'm using learn.Estimator as "user interface" - keeping things simple in the beginning, and moving on to free-form TF graphs at some later time. The recommended way of exporting learn.Estimator objects is via the export_savedmodel method, which gives me a "SavedModel" directory.

The SavedModel directory contains all the needed information. The enclosed TF graph is definitely big and messy, but the conversion application looks for specific TF subgraphs and operations, and is completely unfazed by it.

However, how would you recommend to "shrink" the learn.Estimator object (or the corresponding SavedModel directory)? Some special TF operation, or command-line utility?

blublinsky commented 7 years ago

I have tried 2 approaches - the saved model one and optimize_for_inference TF operations. Here is the simple code for both

Archive.zip

blublinsky commented 7 years ago

You can clearly see the difference between the 2. Optimize for inference creates fairly simple and straightforward graph, which is easy to follow

vruusmann commented 7 years ago

See https://github.com/jpmml/jpmml-tensorflow