Manually log metrics with Vertex AI Experiments

TensorBoard time series metrics can be manually logged with a Vertex AI Experiments run. These metrics are visualized in the Vertex AI Experiments console, or in your Vertex AI TensorBoard experiment web app.

For more details on logging metrics and parameters, see Manually log data to an experiment run.

Python

fromtypingimport Dict, Optional
fromgoogle.cloudimport aiplatform
fromgoogle.protobufimport timestamp_pb2
deflog_time_series_metrics_sample(
 experiment_name: str,
 run_name: str,
 metrics: Dict[str, float],
 step: Optional[int],
 wall_time: Optional[timestamp_pb2.Timestamp],
 project: str,
 location: str,
):
 aiplatform.init(experiment=experiment_name, project=project, location=location)
 aiplatform.start_run(run=run_name, resume=True)
 aiplatform.log_time_series_metrics(metrics=metrics, step=step, wall_time=wall_time)
  • experiment_name: Provide a name for your experiment.
  • run_name: Provide a run name.
  • metrics: Dictionary of where keys are metric names and values are metric values.
  • step: Optional. Step index of this data point within the run.
  • wall_time: Optional. Wall clock timestamp when this data point is generated by the end user. If not provided, wall_time is generated based on the value from time.time().
  • project: . You can find these IDs in the Google Cloud console welcome page.
  • location: Location of your experiment and TensorBoard instance. If the experiment or TensorBoard don't already exist they will be created in this location.

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2025年10月13日 UTC.