INNER CODE UNIT · Python

observation_array

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

  observation_array = env._observe()  # pylint: disable=protected-access
  # Convert to nested list to be sent to the endpoint for prediction.
  observation = [
      list(observation_batch) for observation_batch in observation_array
  ]

  cloud.aiplatform.init(
      project=env_vars.project_id, location=env_vars.region)
  endpoint = cloud.aiplatform.Endpoint(env_vars.endpoint_id)

  # Send prediction request to endpoint and get prediction result.
  predictions = endpoint.predict(
      instances=[
          {"observation": observation},
      ]
  )

  logging.info("prediction result: %s", predictions[0])

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…