human
3.1. Implement serving input receiver functions
Create the serving function
The notebook creates a serving input function that expects a features dictionary and returns the following:
- Predicted class label
- Prediction confidence
- Prediction probabilities of all the classes
 ... Can you provide a the Python program you requested?
assistant
#Here is the Python program you requested.
def make_features_serving_fn(model):

  @tf.function
  def serve_features_fn(features):
    probabilities = model(features)
    labels = tf.constant(TARGET_FEATURE_LABELS, dtype=tf.string)
    predicted_class_indices = tf.argmax(probabilities, axis=1)
    predicted_class_label = tf.gather(
        params=labels, indices=predicted_class_indices)
    prediction_confidence = tf.reduce_max(probabilities, axis=1)
    
    return {
        LABEL_KEY: predicted_class_label,
        SCORE_KEY:prediction_confidence,
        PROBABILITIES_KEY: probabilities}

  return serve_features_fn