python - How to export VocabularyProcessor and use it after TF serve loading? -


i have 2 parts of code:

  • script training data (python+tf+bag_of_words)
  • script predict class of string (now python, later golang in production)

i going train model @ python , use model in production through golang api.

training steps:

  1. fit tf.contrib.learn.preprocessing.vocabularyprocessor
  2. train bow algorithm
  3. add output tf.estimator.export.classificationoutput
  4. add input tf.estimator.export.servinginputreceiver
  5. export tf.estimator.estimator export_savedmodel

it works fine, want proxy client model string. , string should converted vector through vocabularyprocessor. vocabularyprocessor not tensor , can not use graph node. , can not pickle because not restore golang client implementation.

is possible resolve question?

def preprocess_for_prediction(n_words):   def serving_input_fn():     words = tf.placeholder(dtype=tf.string)     receiver_inputs = {"raw_words": words}      # use const needed convert raw_words vector     vector = tf.constant([0, 1, 2, 3, 4, 5, 6, 7, 8, 9], shape=(1, 10), dtype=tf.int32)     features = {words_feature: vector}     return tf.estimator.export.servinginputreceiver(features, receiver_inputs)    return serving_input_fn 

upd:

i read tensorflow-transform. think work me, after trying write answer here.


Comments

Popular posts from this blog

PHP and MySQL WP -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

go - golang pprof for c library code -