Skip to content

Instantly share code, notes, and snippets.

@hanneshapke
Created May 24, 2020 00:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hanneshapke/7446513f5a1832bce9e9c25a842514f8 to your computer and use it in GitHub Desktop.
Save hanneshapke/7446513f5a1832bce9e9c25a842514f8 to your computer and use it in GitHub Desktop.
def _get_serve_tf_examples_fn(model, tf_transform_output):
model.tft_layer = tf_transform_output.transform_features_layer()
@tf.function
def serve_tf_examples_fn(serialized_tf_examples):
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