Created
January 27, 2017 18:05
-
-
Save nqbao/5a512b89256fbe4c0d80acb19439a5b3 to your computer and use it in GitHub Desktop.
Export named signatures from a tf.contrib.learn estimator
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# XXX: Only work with tf 11 | |
from tensorflow.contrib.learn.python.learn.utils import export | |
from tensorflow.contrib.session_bundle import exporter | |
def my_input_fn(): | |
# Return features tensors, the name is empty because when we build the model | |
# we feed in empty column name | |
return { | |
"": tf.placeholder(tf.float32, shape=[None, 4]) | |
}, None | |
def my_signature_fn(examples,features,predictions): | |
return None,{ | |
"inputs": exporter.generic_signature({"features": examples}), | |
"outputs": exporter.generic_signature({"score": predictions}) | |
} | |
classifier.export( | |
"/tmp/iris_exported_model", | |
input_fn=my_input_fn, | |
input_feature_key="", | |
use_deprecated_input_fn=False, | |
signature_fn=my_signature_fn | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment