Skip to content

Latest commit

 

History

History
38 lines (28 loc) · 1.41 KB

File metadata and controls

38 lines (28 loc) · 1.41 KB

gcp-ai-platform-hyperparameter-tuning-tf2

Perform Hyperparameter tuning on a small Regression problem using TensorFlow 2

Run with Docker image on Vertex AI

  • Setup environment variables
export REGION=us-central1
export PROJECT_ID=$(gcloud config list project --format "value(core.project)")
export IMAGE_REPO_NAME=gcp-vertex-ai-hyperparameter-tuning-tf
export IMAGE_NAME=gcp-vertex-ai-hyperparameter-tuning-tf
export IMAGE_TAG=latest
export IMAGE_URI=$REGION-docker.pkg.dev/$PROJECT_ID/$IMAGE_REPO_NAME/$IMAGE_NAME:$IMAGE_TAG
gcloud auth configure-docker $REGION-docker.pkg.dev
  • Build Docker image
docker build -f Dockerfile -t $IMAGE_URI ./
  • Push the Docker image to GCP artifacts registry
docker push $IMAGE_URI
  • Prepare hyperparameter tuning config file

In the hptuning_config.yaml you add the parameters to optimize with your hyperparameter tuning and provide arguments to your code as hyperparameters that will be used to optimize. You can also specify the job submission details like parallel jobs to run and how many jobs to run.

  • Training with hyperparameter tuning on the Vertex AI platform from Docker image

Initialize input variables

export JOB_NAME=hyperparameter_tuning_example

Submit the jobs


gcloud ai hp-tuning-jobs create --region $REGION --config hptuning_config.yaml --project=$PROJECT_ID --display-name=$JOB_NAME