Created
September 19, 2020 08:36
-
-
Save ntakouris/a361cf5b133b33f2265d17030838fb7c to your computer and use it in GitHub Desktop.
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
def _get_serve_tf_examples_fn(model, tf_transform_output): | |
"""Returns a function that parses a serialized tf.Example and applies TFT.""" | |
model.tft_layer = tf_transform_output.transform_features_layer() | |
@tf.function | |
def serve_tf_examples_fn(serialized_tf_examples): | |
"""Returns the output to be used in the serving signature.""" | |
feature_spec = tf_transform_output.raw_feature_spec() | |
feature_spec.pop(_LABEL_KEY) | |
parsed_features = tf.io.parse_example(serialized_tf_examples, feature_spec) | |
transformed_features = model.tft_layer(parsed_features) | |
return model(transformed_features) | |
return serve_tf_examples_fn |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment