INNER CODE UNIT · Python

predict

GoogleCloudPlatform/vertex-ai-samples · community-content/tf_agents_bandits_movie_recommendation_with_kfp_and_vertex_sdk/mlops_pipeline_tf_agents_bandits_movie_recommendation/src/prediction_container/main.py:143

async def predict(
    request: fastapi.Request) -> Dict[str, List[Dict[str, List[int]]]]:
  """Handles prediction requests.

  Unpacks observations in prediction requests and queries the trained policy for
  predicted actions.

  Args:
    request: Incoming prediction requests that contain observations.

  Returns:
    A dict with the key "predictions" mapping to a list of predicted actions
    corresponding to each observation in the prediction request.
  """
  body = await request.json()
  instances = body["instances"]
  return _predict(instances, app_vars["trained_policy"])

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…