title: How to export VocabularyProcessor and use it after TF serve loading?
body: <p>I have two parts of my code:</p>
  
  <ul>
  <li>script for training data (python+tf+bag_of_words)  </li>
  <li>script for predict class of any string (now python, but later golang in
  production)</li>
  </ul>
  
  <p>I am going to train my model at python and use model in production through golang API.</p>
  
  <p>Training steps:</p>
  
  <ol>
  <li>Fit <code>tf.contrib.learn.preprocessing.VocabularyProcessor</code></li>
  <li>Train with BOW algorithm</li>
  <li>Add output <code>tf.estimator.export.ClassificationOutput</code></li>
  <li>Add input <code>tf.estimator.export.ServingInputReceiver</code></li>
  <li>Export my <code>tf.estimator.Estimator</code> by <code>export_savedmodel</code></li>
  </ol>
  
  <p>It works fine, but I want proxy from my client to the model <code>string</code>. And this <code>string</code> should be converted to vector through VocabularyProcessor. But VocabularyProcessor is not tensor and I can not use it as graph node. And I can not pickle it because I will not restore it with golang client implementation.</p>
  
  <p>Is it possible to resolve my question?</p>
  
  <pre><code>def preprocess_for_prediction(n_words):
    def serving_input_fn():
      words = tf.placeholder(dtype=tf.string)
      receiver_inputs = {"raw_words": words}
  
      # Now use const by needed to convert raw_words to 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
  </code></pre>
  
  <p>UPD:</p>
  
  <p>I just read about tensorflow-transform. I think it will work for me, after trying I will write answer here.</p>