The Unibright Ambassador Program

As announced in our blog post about our marketing and communication strategy, we want to start an Ambassador program. In this blog post you will learn what it is all about and how to become part of…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




How to Train and Save a CLASSIFICATION Model in KERAS for Tensorflow Serving

So many tutorials on Machine Learning… yet some don’t work, and virtually none of them prepare you to save the model for production use.

Tensorflow serving, is currently the best way to productionize AI, hands down. However, because it is so new, most examples are complex and incomplete.

If you just want to learn how to train a model and save it for TF Serving, Click here for a tutorial on how to do that for prediction, this one is for classification and is a bit more complex.

We will begin by using the simplest yet probably most popular dataset for training a classification model. It is the IRIS dataset.

1. sepal length in cm
2. sepal width in cm
3. petal length in cm
4. petal width in cm
classes:
— Iris Setosa
— Iris Versicolour
— Iris Virginica

you will find a pre-saved model in it in directory 1, running the code will save another model in directory 2.

To run the code you must set up your environment which is shown on the github. I have set it up where you can use pipenv. Pipenv is kind of like NPM(if you are familiar with node)

Here is the Part where there was no documentation. This is necessary to be able to save the model for TF serving in order to use the classify api action. We do this to extract the features for the model so we can specify them for the meta graph variables for tf serving.

but not enough for us to figure out how to do it in keras, so here you go:

There you go that is how to properly save a classification model using keras for tf serving.

Best of luck

— — Brian Alois Schardt

Add a comment

Related posts:

Chasing Sunsets

A couple days before my planned move to Missouri, I read Rembert Browne’s piece about the comforting solitude of an empty car and open road. He had dedicated his summer to visiting every state and…

Cuttlefish Bones

At this time of continually changing Raining season weather Churning sea waters throw up all kinds Of debris onto this beach of shifting sands. I walk among cuttlebones Laid out all around me on…