Compare commits

...
Author SHA1 Message Date
Andrew FerlitschandGitHub 06daeb1575 Merge branch 'main' into instance_schema 2022-10-31 13:30:28 -07:00
Andrew Ferlitsch 2074fb56a9 feat: add example of instance schema 2022-10-31 20:29:16 +00:00
Andrew FerlitschandGitHub 1bdbb7921a fix: reduce visibility of proto code (#1202) 2022-10-31 16:00:27 -04:00
7154a722ba Update Experiments notebook for log_classification_metrics (#1182)
* Update build_model_experimentation_lineage_with_prebuild_code.ipynb

* Update build_model_experimentation_lineage_with_prebuild_code.ipynb

* Update build_model_experimentation_lineage_with_prebuild_code.ipynb

* Update build_model_experimentation_lineage_with_prebuild_code.ipynb

* Update build_model_experimentation_lineage_with_prebuild_code.ipynb

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-10-31 12:27:27 -07:00
halio-gandGitHub 99d4a8c31a Adding Open Source Vizier converstion sample[Updated] (#1187)
* Add a colab to show how to integrate the training job with Dask.

* Reformat the notebook xgboost_data_parallel_training_on_cpu_using_dask

* Add the code owner of the sample training/xgboost_data_parallel_training_on_cpu_using_dask.ipynb

* Changed the project id to [your-project-id].

* Fixed the issue for Non colab.

* Adding the sample of converting the Vertex Vizier SDK with Open source Vizier.

* Add the owner for conversions_vertex_vizier_and_open_source_vizier.ipynb

* Addressed the comments in the xgboost_data_parallel_training_on_cpu_using_dask

* Fixed the format of xgboost_data_parallel_training_on_cpu_using_dask

* Addressed the comments in the training/xgboost_data_parallel_training_on_cpu_using_dask.ipynb

* Add explanation that Docker is not available on Colab.

* Add  before docker command.

* add timeout in the worker to wait for the scheduler.

* Addressed the comments in the pr.

* Addressed the comments in the pr.
2022-10-28 15:26:14 -07:00
f9cedf2850 Added notebook demonstrating hyperparameter tuning (#1168)
* Added notebook demonstrating hyperparameter tuning

* fix lint errors

* fix failing test

* ran linter

* ran linter

* resolved editorial comments

* small editorial edits

* fix failing test

* fix linter

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-10-28 09:53:22 -07:00
f4f0112a6a Pipelines xgboost (#1196)
* feat: add notebook

* feat: add notebook

* fix: typos in text

Co-authored-by: gericdong <itseric@google.com>
2022-10-27 20:18:20 -04:00
Kevin NaughtonandGitHub e441568c38 Quick typo update in model_monitoring.ipynb (#1197)
The Monitoring Interval is in hours, not seconds.
2022-10-27 17:10:42 -07:00
Andrew FerlitschandGitHub fee8c969e4 feat: add xgboost pipeline notebook (#1194)
* feat: add notebook

* feat: add notebook
2022-10-27 15:20:10 -04:00
Andrew FerlitschandGitHub bdac091e3f feat: add sklearn pipeline notebook (#1193)
* feat: add notebook

* feat: add notebook

* fix: typo in text for dataset-url
2022-10-27 13:32:09 -04:00
kthytangandGitHub ff9338ed3c chore: remove preview note from CPR notebooks (#1192) 2022-10-26 11:31:42 -07:00
Andrew FerlitschandGitHub 1a538fd249 fix: multi-class vs binary classifier (#1191) 2022-10-26 08:28:35 -07:00
4f09c94b5f fix: textual corrections and Upgrade the gcpc version for automl_video_classification_model_evaluation notebook. (#1169)
* added model evaluation component

* linter test cases

* linter test cases

* model_name param issues resolved

* linter test case

* import issues resloved

* linter test cases

* made review changes

* made review changes

* ran linter test

* made review changes

* made review changes

* made review changes

* linter test

* ran linter test

* made review changes

* ran linter test

* made review changes

* ran linter test

* linter test

* review changes

* ran linter test

* added The links for Colab, Github and Workbench

* added The links for Colab, Github and Workbench

* ran linter test

* added The links for Colab, Github and Workbench

* ran linter test

* added The links for Colab, Github and Workbench

* ran linter test

* notebook title changed

* ran linter test

* text changes and made review changes

* ran linter test

* made review changes

* linter test

* made review changes

* linter test

* content changes

* ran linter test

* textual corrections and links

* ran linter test

Co-authored-by: Ivan Cheung <ivans.mailbox@gmail.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
Co-authored-by: Soheila Zangeneh <49654056+soheilazangeneh@users.noreply.github.com>
2022-10-25 17:32:44 -04:00
bcf3e6b0f5 Updated file custom_tabular_regression_model_evaluation (#1180)
* made text corrections

* ran linter

* modified notebook

* modified notebook

* ran linter

* modified installation step

* ran linter

Co-authored-by: Soheila Zangeneh <49654056+soheilazangeneh@users.noreply.github.com>
2022-10-25 12:42:48 -04:00
Bo zhengandGitHub fbcf783064 feat: change E2E AutoML dataset to use bank marketing data
* Change E2E AutoML dataset to use bank marketing data

* Remove vs code config
2022-10-24 22:15:43 -07:00
halio-gandGitHub 2f5fe80f34 Adding the official version for Dask parallel training on cpu (#1153)
* Add a colab to show how to integrate the training job with Dask.

* Reformat the notebook xgboost_data_parallel_training_on_cpu_using_dask

* Add the code owner of the sample training/xgboost_data_parallel_training_on_cpu_using_dask.ipynb

* Changed the project id to [your-project-id].

* Fixed the issue for Non colab.

* Addressed the comments in the xgboost_data_parallel_training_on_cpu_using_dask

* Fixed the format of xgboost_data_parallel_training_on_cpu_using_dask

* Addressed the comments in the training/xgboost_data_parallel_training_on_cpu_using_dask.ipynb

* Add explanation that Docker is not available on Colab.

* Add  before docker command.

* add timeout in the worker to wait for the scheduler.
2022-10-24 10:37:13 -07:00
a850f3a88a fix: missed bad links (#1183)
* fix: missed bad links

* fix: missed bad links

Co-authored-by: gericdong <itseric@google.com>
2022-10-21 11:09:11 -04:00
Andrew FerlitschandGitHub de91feaca1 Update README.md (#1181)
added missing link
2022-10-21 07:15:38 -07:00
Andrew FerlitschandGitHub a7fd0734dc feat: XGBoost online serving (#1175)
* feat: xgboost online serving

* fix: review comments and added pipeline example

* fix: review comments
2022-10-19 08:49:31 -07:00
Soheila ZangenehandGitHub ce1b167f08 Edit folder and file name for model registry (#1178)
* Update folder and file name

* Update file name

* Update CODEOWNERS

* Update notebook links

* Update README

* Run linter
2022-10-18 14:40:52 -07:00
Soheila ZangenehandGitHub 65ff3cab60 Revert "Update folder and file names (#1176)" (#1177)
This reverts commit c7ef72f1d3.
2022-10-18 16:59:39 -04:00
Soheila ZangenehandGitHub c7ef72f1d3 Update folder and file names (#1176)
* Rename folder

* Rename file

* Update the links

* Update CODOWNERS

* Run linter
2022-10-18 16:42:36 -04:00
Andrew FerlitschandGitHub bd58428857 fix: issue 1122 (#1173) 2022-10-18 15:09:35 -04:00
Andrew FerlitschandGitHub a4a6ed848b fix: working on abstract class (#1156)
* fix: working on abstract class

* fix: working on abstract class
2022-10-13 10:56:17 -04:00
Andrew FerlitschandGitHub b753bc58d3 fix: enum and cell index naming (#1152) 2022-10-12 14:54:57 -04:00
6279e12eea Bug fixes and automation improvements for google_cloud_pipeline_components_dataproc_tabular.ipynb (#1139)
* Bug fixes and improved automation

* Clean up notebook

* Add --quiet flag to gcloud call

* Add Python prediction and subnetwork parameter

Co-authored-by: Win Woo <wwoo@google.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-10-12 08:19:25 -07:00
Andrew FerlitschandGitHub fc0c34c905 Boilerplate 2 (#1148)
* fix: merge corruption

* fix: still fix post corruption

* tuning: boiler plate script

* tuning: boiler plate

* tuning: boiler plate

* tuning: boiler plate
2022-10-11 14:01:41 -07:00
Andrew FerlitschandGitHub ef388ecf30 Boilerplate 2 (#1147)
* fix: merge corruption

* fix: still fix post corruption

* tuning: boiler plate script

* tuning: boiler plate

* tuning: boiler plate
2022-10-11 13:57:40 -07:00
Andrew FerlitschandGitHub bafb2c6f59 Boilerplate 2 (#1146)
* fix: merge corruption

* fix: still fix post corruption

* tuning: boiler plate script

* tuning: boiler plate
2022-10-11 13:43:27 -07:00
Andrew FerlitschandGitHub f2d431c182 tuning: boiler plate (#1145)
* fix: merge corruption

* fix: still fix post corruption

* tuning: boiler plate script
2022-10-11 13:31:55 -07:00
Andrew FerlitschandGitHub 2e4b6a1b1b fix: structure (#1138) 2022-10-11 13:29:11 -07:00
95cebcbf8f Update google_cloud_pipeline_components_dataproc_tabular.ipynb (#1136)
Removed extraneous `$` from CWD variable causing scala-sbt build to fail

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-10-11 13:04:28 -07:00
Andrew FerlitschandGitHub 08f1b659c5 Boilerplate 1 (#1144)
* feat: boiler plate reduction

* feat: boiler plate reduction
2022-10-11 11:30:08 -07:00
Andrew FerlitschandGitHub 86ba71931d fix: merge corruption (#1143) 2022-10-11 11:19:05 -07:00
d811306fb9 minor fixes (#1140)
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-10-11 11:09:24 -07:00
Andrew FerlitschandGitHub 4173e6d561 Boilerplate 1 (#1142)
* feat: boiler plate reduction

* feat: boiler plate reduction
2022-10-11 10:27:04 -07:00
Andrew FerlitschandGitHub 499d25055a feat: boiler plate reduction (#1141) 2022-10-11 09:32:30 -07:00
Andrew FerlitschandGitHub 60776de953 fix: bad links and branding (#1137) 2022-10-10 15:57:22 -07:00
Andrew FerlitschandGitHub 182ebcf285 fix: script format (#1134)
* fix: script format

* fix: script format

* fix: script format

* fix: script format
2022-10-10 15:56:31 -07:00
MarcandGitHub 39359a5b21 switch mm ownership to Andy (#1133) 2022-10-10 09:48:12 -07:00
0d72cfe070 Modified file automl_forecasting_bqml_arima_plus_comparison (#1124)
* modified notebook

* ran linter

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-10-10 08:51:51 -07:00
64fef140a2 Vertex SDK AutoML Image Classification (#1123)
* tf library issues solved

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-10-07 15:14:53 -07:00
015809b948 Cleans up official/migration/UJ3 notebook and fixes the issue from regression logs (#1063)
* cleans up the notebook,replaces docker with cloud build, textual edits still in progress

* cleans up the notebook

* ran linter test

* changes tf train/serve version to 2.9

* ran linter test

* adds '=' to fix a typo

* ran linter test

* updates the opencv installation package

* ran linter test

* updates the opencv installation dependencies

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-10-07 09:37:12 -07:00
gericdongandGitHub faccdd081f fix: improved notebook comments and readme (#1131)
* fix: improved notebook comments

* fix: improved notebook comments and formatting
2022-10-07 08:00:02 -07:00
3e8a3cf28e updates: autoreview (#1126)
Co-authored-by: gericdong <itseric@google.com>
2022-10-06 16:11:13 -04:00
Andrew FerlitschandGitHub 821bba2776 fix: loose ends on objective conformance (#1125) 2022-10-06 15:46:31 -04:00
c82bdee299 fix: incorrect linking (#1119)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* fix: incorrect linking for index

* fix: incorrect linking

Co-authored-by: gericdong <itseric@google.com>
2022-10-06 10:11:45 -04:00
Andrew FerlitschandGitHub c27381139b fix: incorrect linking (#1121) 2022-10-05 18:28:32 -07:00
Andrew FerlitschandGitHub 01236836f2 fix: incorrect linking (#1120) 2022-10-05 18:12:30 -07:00
Andrew FerlitschandGitHub b8380650bd fix: incorrect linking (#1118)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* fix: incorrect linking for index
2022-10-05 17:52:45 -07:00
Andrew FerlitschandGitHub 69d266cb90 add: autogen index for official/vizier (#1117)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index
2022-10-05 17:25:04 -07:00
Andrew FerlitschandGitHub 530524ac6e feat: add autogen index for official/training (#1116)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index
2022-10-05 17:22:17 -07:00
Andrew FerlitschandGitHub ba66961fce feat: add autoindex for official/tensorboard (#1115)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index
2022-10-05 17:20:06 -07:00
Andrew FerlitschandGitHub aca7035482 add: add autogen index for official/tabular_workflows (#1114)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index
2022-10-05 17:17:15 -07:00
Andrew FerlitschandGitHub 3d270cde69 feat: add autoindex for official/tabnet (#1113)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index
2022-10-05 17:14:48 -07:00
Andrew FerlitschandGitHub 9754c265ff feat: add autoindex for official/structured_data (#1112)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index
2022-10-05 17:09:35 -07:00
Andrew FerlitschandGitHub f5d730c9f1 feat: add autoindex for official/sdk (#1111)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index
2022-10-05 17:02:06 -07:00
Andrew FerlitschandGitHub acd42a3a1b feat: add autogen index for official/reduction_server (#1110)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index
2022-10-05 16:58:46 -07:00
Andrew FerlitschandGitHub eb7cf4b6bc feat: add autoindex for official/pipelines (#1109)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index
2022-10-05 16:54:26 -07:00
Andrew FerlitschandGitHub 34b1011ac9 feat: add autoindex for official/model-registry (#1108)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index
2022-10-05 16:46:04 -07:00
Andrew FerlitschandGitHub 239d664990 feat: add autogen index for official/model_monitoring (#1107)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index
2022-10-05 16:43:16 -07:00
Andrew FerlitschandGitHub 920c771238 feat: add autogen index for official/model_evaluation (#1106)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index
2022-10-05 16:41:01 -07:00
Andrew FerlitschandGitHub e7c68ecb78 fix: autogen index for official/ml_metadata (#1105)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index

* feat: add autogen index

* feat: add autogen index
2022-10-05 16:37:29 -07:00
Andrew FerlitschandGitHub cfeb118d8b feat: add autogen index for official/matching_engine (#1104)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index

* feat: add autogen index
2022-10-05 16:30:00 -07:00
Andrew FerlitschandGitHub 2c9c8db15c feat: add autogen index for official/feature_store (#1103)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index

* feat: add autogen index
2022-10-05 16:24:10 -07:00
Andrew FerlitschandGitHub 6778a2cfbf fix: update autogen index for official/automl (#1102)
* feat: add autogen index

* fix: missed the REAME

* fix: update autogen index
2022-10-05 16:14:24 -07:00
Andrew FerlitschandGitHub 26c5d56e6d feat: update autogen index for official/explainable_ai (#1101)
* feat: add autogen index

* fix: missed the REAME
2022-10-05 16:08:41 -07:00
Andrew FerlitschandGitHub 527fe79f15 feat: add autogen index (#1100) 2022-10-05 16:06:38 -07:00
Andrew FerlitschandGitHub 2a003fa9c3 add: autogen index (#1085) 2022-10-05 15:55:29 -07:00
Andrew FerlitschandGitHub 03b9b6026f feat: add index (#1084) 2022-10-05 15:55:09 -07:00
Andrew FerlitschandGitHub ff8d6a9d56 feat: add autogen index (#1083) 2022-10-05 13:21:55 -07:00
Andrew FerlitschandGitHub 874c881ad6 feat: add autogen index (#1080) 2022-10-05 13:21:24 -07:00
Andrew FerlitschandGitHub f484429a89 fix: auto regen index for curated (#1076)
* fix: auto regen index for curated

* fix: bad links
2022-10-05 13:20:22 -07:00
Andrew FerlitschandGitHub 7fa2502c09 PR: bad links and objective (#1099)
* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective
2022-10-05 11:13:12 -07:00
Andrew FerlitschandGitHub 056791fadd fix: bad links and objective (#1098)
* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective
2022-10-05 11:10:35 -07:00
Andrew FerlitschandGitHub 154be75dce fix: bad links and objective (#1097)
* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective
2022-10-05 11:07:09 -07:00
Andrew FerlitschandGitHub ed7e900a02 fix: bad links and objective (#1096)
* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective
2022-10-05 11:01:19 -07:00
Andrew FerlitschandGitHub f109fefbfa fix: bad links (#1095)
* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective
2022-10-05 10:54:19 -07:00
Andrew FerlitschandGitHub 6f9c99d1df fix: bad links and objective (#1094)
* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective

* fix: bad links and objective
2022-10-05 10:49:41 -07:00
Andrew FerlitschandGitHub ed39d78005 fix: bad links and objective conformance (#1093)
* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: bad links and objective

* fix: bad links and objective
2022-10-05 10:25:02 -07:00
Andrew FerlitschandGitHub d6466ab1a6 fix: bad links and objective (#1092)
* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: bad links and objective
2022-10-05 10:15:36 -07:00
Andrew FerlitschandGitHub 65e310e4e6 fix: bad links and objective (#1091)
* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance
2022-10-05 10:08:39 -07:00
Andrew FerlitschandGitHub 0e773ba90f fix: bad links and objective (#1090)
* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance

* fix: objective conformance
2022-10-05 10:07:35 -07:00
Andrew FerlitschandGitHub 0747f9efb8 fix: objective (#1089)
* fix: objective conformance

* fix: objective conformance

* fix: objective conformance
2022-10-05 09:38:50 -07:00
Andrew FerlitschandGitHub 53785fb812 fix: objective section (#1088)
* fix: objective conformance

* fix: objective conformance
2022-10-05 09:33:13 -07:00
Andrew FerlitschandGitHub b85c24dca5 fix: objective conformance (#1087) 2022-10-05 09:21:49 -07:00
Andrew FerlitschandGitHub ea5c12c22a Autoreview 17 (#1082)
* fix: bad link

* fix: objective
2022-10-04 17:32:04 -07:00
Andrew FerlitschandGitHub 392c1b7361 fix: bad link (#1081) 2022-10-04 17:26:30 -07:00
Andrew FerlitschandGitHub c5980e636e Autoreview 15 (#1079)
* fix: tag handling

* fix: objective

* fix: bad links
2022-10-04 17:08:46 -07:00
Andrew FerlitschandGitHub 8859e9426d fix: tag handling (#1078) 2022-10-04 16:57:34 -07:00
Andrew FerlitschandGitHub db7cc9000a fix: bad links (#1077)
* fix: bad links

* fix: bad links and branding
2022-10-04 16:44:03 -07:00
Andrew FerlitschandGitHub d1fe50a1d9 fix: last tag handling (#1075) 2022-10-04 14:18:22 -07:00
Andrew FerlitschandGitHub 9e3597692f Autoreview text fixes (#1074)
* fix: bad links

* fix: bad links

* fix: objective intro

* fix: objective

* fix: objective statement

* fix: objective statement
2022-10-04 14:07:17 -07:00
Andrew FerlitschandGitHub 45c8deebe5 Autoreview text fixes (#1073)
* fix: bad links

* fix: bad links

* fix: objective intro

* fix: objective

* fix: objective statement
2022-10-04 14:03:10 -07:00
Andrew FerlitschandGitHub 6705c4e4ee Autoreview text fixes (#1072)
* fix: bad links

* fix: bad links

* fix: objective intro

* fix: objective
2022-10-04 13:54:50 -07:00
Andrew FerlitschandGitHub b7f06d948a Autoreview text fixes (#1071)
* fix: bad links

* fix: bad links

* fix: objective intro
2022-10-04 13:20:29 -07:00
Andrew FerlitschandGitHub 7f3c1a9a36 fix: bad links (#1070)
* fix: bad links

* fix: bad links
2022-10-04 13:12:54 -07:00
2e991c5b9d New notebook for PyTorch distributed training on reduction server (#1064)
* feat: added new notebook for PyTorch distributed training on reduction server

* Fixed linter errors

* Addressed review comments

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-10-04 13:07:43 -07:00
Andrew FerlitschandGitHub f8ac68ec10 Autoreview 10 (#1069)
* fix: handling of linkback for web output

* fix: tune markdown output
2022-10-04 13:06:38 -07:00
Andrew FerlitschandGitHub a591c39367 fix: handling of linkback for web output (#1068) 2022-10-04 12:08:46 -07:00
Andrew FerlitschandGitHub d938982aae feat: calculate links for new notebooks (#1065) 2022-10-04 12:08:18 -07:00
1397c9a64a Fixed line break (#1067)
* Added tags, links to corresponding documentation pages

* Fixed line break issue

Co-authored-by: Max Reznitskii <reznitskii@google.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-10-04 11:31:32 -07:00
da97ec2244 Added tags, links to corresponding documentation pages (#1066)
Co-authored-by: Max Reznitskii <reznitskii@google.com>
2022-10-04 11:20:08 -07:00
c3f1f8239b UJ15 Vertex SDK AutoML Object Tracking (#1055)
* resloved tf library issues

* ran linter test

* made review changes

* ran linter test

* made review changes

* ran linter

* made review changes

* linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-10-04 08:51:17 -07:00
Andrew FerlitschandGitHub 73878dcc01 update: support for multi-tags and desc for web output (#1061) 2022-10-04 09:32:20 -04:00
Andrew FerlitschandGitHub 13bad2e6a3 Autoreview readme (#1060)
* fix: re autogen index

* fix: descriptions

* fix: descriptions
2022-10-03 13:24:59 -07:00
Andrew FerlitschandGitHub 0172f2b11b fix: re autogen index (#1059) 2022-10-03 12:39:50 -07:00
Andrew FerlitschandGitHub 1ba0c17555 fix: tuning README output (#1058) 2022-10-03 15:14:32 -04:00
399c961074 Modified notebook chicago_taxi_fare_prediction according to notebook template (#1043)
* error resolved

* ran linter

* andrew comments resolved

* ran linter

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-10-03 08:35:59 -07:00
d44836db9d Modified notebook inventory_prediction (#1041)
* resolved error

* resolved error

* ran linter

* andrew comments resolved

* ran linter

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-10-03 08:34:47 -07:00
4e236fd553 Text classification evaluation (#959)
* Model evaluation for text classification using Automl

* Removed unused library

* Ran Linter Test

* Commented text

* Commented Text

* Ran Linter test

* Made changes suggested in review

* Removed unused import

* Ran Linter Test

* Removed dataflow parameters as mentioned in the review

* Ran Linter Test

* Made review changes and changed notebook links in the beginning of the notebook

* Ran Linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-10-02 13:49:06 -07:00
Andrew FerlitschandGitHub 352b1e2710 fix: error handling improvements (#1053) 2022-09-30 15:40:30 -04:00
13cc94d3b7 feat: Add notebook for Wide & Deep on Vertex Pipelines (#984)
* Add notebook for Wide & Deep on Vertex Pipelines

* Address comments

* Clear output

* Fix deletion logic

* Run linter

* Rename custom_job and hpt_job to pipeline_job

* Use Vertex SDK for deletion instead of gcloud

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-30 09:46:23 -07:00
632362ed80 Modified notebook fraud-detection-model notebook (#1052)
* resolved error

* ran linter

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-30 09:44:45 -07:00
90b5575b0c feat: Add notebook for TabNet on Vertex Pipelines (#726)
* Added notebook for TabNet on Vertex Pipelines

* Added notebook for TabNet on Vertex Pipelines

* Added notebook for TabNet on Vertex Pipelines

* Run linter

* Ran linter

* Ran linter again

* Addressed comments

* Addressed more comments

* Remove parameter definitions, reference documentation, add details under CustomJob/HPT job sections

* Address more comments

* Fix tests

* Bug fix

* Rework TabNet HPT job section

* Addressed more comments

* Update documentation links

* Fix tests

* Fix tests

* Linter and some changes

* Address more comments

* Update CustomJob description to align with documentation

* Use bank-marketing dataset instead of safedriver

* Rename variables

* Rename variables

* Update gcs location to official one

* Changes to make notebook run with updated SDK

* Bug fix

* Rewording

* Fix workbench link

* Update notebook format to align with template

* Fix deletion logic

* Run linter

* Rename custom_job and hpt_job to pipeline_job

* Use Vertex SDK for deletion instead of gcloud

Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
Co-authored-by: Ivan Cheung <ivans.mailbox@gmail.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-29 16:58:53 -07:00
2d96cc0af1 Rapid prototyping bqml automl (#877)
* Made changes in accordance with Notebook template

* Ran Linter Test

* Attached UUID to BQ_DATSET and use bq to delete dataset

* Removed unused imports

* Ran Linter Test

* Fixed BQ_DATASET

* Fixed BQ_DATASET

* Ran linter test

* Made review changes

* Removed unused library

* Ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-29 13:17:14 -07:00
aadc80752b UJ6 Vertex SDK AutoML Text Classification (#1039)
* add The links for Colab, Github and Workbench

* added The links for Colab, Github and Workbench

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-29 13:15:10 -07:00
e8745a750b Modified notebook telecom-subscriber-churn-prediction (#874)
* modified notebook telecom-subscriber-churn-prediction.ipynb

* ran linter

* changes suggested by andrew are done

* ran linter

* changes suggested by andrew done

* ran linter

* resolved error

* ran linter

* fixed a monor bug

* ran linter

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-29 13:13:40 -07:00
Andrew FerlitschandGitHub 67b54685be fix: bad link (#1050)
* fix: bad link

* fix: bad link
2022-09-29 12:07:27 -07:00
Andrew FerlitschandGitHub 738dc1e01c fix: bad links (#1049)
* fix: bad link

* fix: bad link
2022-09-29 12:02:54 -07:00
Andrew FerlitschandGitHub 3b481a43a9 fix: bad links (#1048)
* fix: bad links

* fix: bad links
2022-09-29 12:02:08 -07:00
Andrew FerlitschandGitHub 35d0dee5a0 fix: bad link (#1047)
* fix: bad link

* fix: bad link
2022-09-29 11:47:25 -07:00
Andrew FerlitschandGitHub 90a0bb9b4c fix: bad link (#1046)
* fix: bad link

* fix: bad link
2022-09-29 11:47:01 -07:00
Andrew FerlitschandGitHub e59d5462b4 fix: improve args and add webdoc generation (#1045) 2022-09-29 14:15:52 -04:00
Andrew FerlitschandGitHub f94bf3c7e1 fix: bad link (#1044)
* fix: bad links

* fix: bad links
2022-09-29 09:36:59 -07:00
Andrew FerlitschandGitHub dd215b8cf0 corrections to official notebook (#978)
* fix: corrections

* fix: corrections

* fix: missing bq client

* fix: missing bq client

* fix: installs

* fix: installs

* fix: add missing imports

* fix: add missing imports
2022-09-29 09:10:44 -07:00
Andrew FerlitschandGitHub 784c94a72f fix: bad link, title (#1023)
* fix: bad link, title

* fix: bad link, title
2022-09-29 09:10:08 -07:00
Andrew FerlitschandGitHub dccfed9743 fix: broken link (#1033)
* fix: bad link

* fix: bad link
2022-09-29 09:05:29 -07:00
8346855cfe automl_video_classification_model_evaluation (#1035)
* added model evaluation component

* linter test cases

* linter test cases

* model_name param issues resolved

* linter test case

* import issues resloved

* linter test cases

* made review changes

* made review changes

* ran linter test

* made review changes

* made review changes

* made review changes

* linter test

* ran linter test

* made review changes

* ran linter test

* made review changes

* ran linter test

* linter test

* review changes

* ran linter test

* added The links for Colab, Github and Workbench

* added The links for Colab, Github and Workbench

* ran linter test

* added The links for Colab, Github and Workbench

* ran linter test

* added The links for Colab, Github and Workbench

* ran linter test

Co-authored-by: Ivan Cheung <ivans.mailbox@gmail.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-29 09:13:24 -04:00
Andrew FerlitschandGitHub 64ad5123d0 fix: bad link (#1008)
* fix: bad link

* fix: bad link
2022-09-28 19:26:37 -07:00
Andrew Ferlitsch 0025e56323 fix: Objective 2022-09-29 02:23:03 +00:00
Andrew Ferlitsch 8fd9f35aca fix: Objective 2022-09-29 02:22:33 +00:00
Andrew FerlitschandGitHub 658abd6d5b fix: title in link (#1029)
* fix: bad links

* fix: bad links
2022-09-28 18:52:04 -07:00
Andrew FerlitschandGitHub 1243f736e2 fix: bad link (#1007)
* fix: bad link

* fix: bad link
2022-09-28 17:01:53 -07:00
Andrew FerlitschandGitHub dd0b07163f fix: bad links (#1031)
* fix: bad links

* fix: bad links
2022-09-28 16:54:38 -07:00
Andrew FerlitschandGitHub c6b268ba89 fix: bad links (#1028)
* fix: bad links

* fix: bad links
2022-09-28 15:53:01 -07:00
Andrew FerlitschandGitHub fd4f7d2641 fix: bad links (#1030)
* fix: bad links

* fix: bad links
2022-09-28 15:52:39 -07:00
Andrew FerlitschandGitHub 5c513e20c9 fix: parsing links (#1032) 2022-09-28 15:45:15 -07:00
Andrew FerlitschandGitHub d78dba7941 fix: bad links (#1025)
* fix: bad links

* fix: bad links
2022-09-28 15:37:55 -07:00
Andrew FerlitschandGitHub 42fa88547b fix: bad links (#1027)
* fix: bad links

* fix: bad links
2022-09-28 15:33:47 -07:00
Andrew FerlitschandGitHub c4cda29095 fix: bad links (#1026)
* fix: bad links

* fix: bad links
2022-09-28 15:33:25 -07:00
Andrew FerlitschandGitHub 47725449b5 fix: bad link (#1005)
* fix: bad link

* fix: bad link
2022-09-28 15:01:44 -07:00
Andrew FerlitschandGitHub 2eba462437 fix: bad link (#1010)
* fix: bad link

* fix: bad link
2022-09-28 14:31:37 -07:00
Andrew FerlitschandGitHub 97a3f4d3dd fix: add abbr (#1024) 2022-09-28 14:28:34 -07:00
Andrew FerlitschandGitHub 531e567358 fix: bad links (#1009)
* fix: bad link

* fix: bad link
2022-09-28 14:12:58 -07:00
Andrew FerlitschandGitHub 1f7c7105bb fix: link, title, format (#1018)
* fix: link, title, format

* fix: link, title, format
2022-09-28 14:12:29 -07:00
Andrew FerlitschandGitHub b109183d52 fix: bad links (#1011)
* fix: bad link

* fix: bad link
2022-09-28 13:53:45 -07:00
Andrew FerlitschandGitHub 72ed00fe0f fix: bad links (#1012)
* fix: bad link

* fix: bad link
2022-09-28 13:53:27 -07:00
Andrew FerlitschandGitHub e8d9137a50 fix: bad links (#1013)
* fix: bad link

* fix: bad link
2022-09-28 13:52:51 -07:00
Andrew FerlitschandGitHub 872e98c544 fix: bad links (#1014)
* fix: bad link

* fix: bad link
2022-09-28 13:52:17 -07:00
Andrew FerlitschandGitHub 0966fc56a4 fix: bad links, missing title (#1015)
* fix: bad link, missing title

* fix: bad link, missing title
2022-09-28 13:51:56 -07:00
Andrew FerlitschandGitHub e8d1e58fc6 fix: bad link, title (#1016)
* fix: bad link, correct title

* fix: bad link, correct title
2022-09-28 13:50:44 -07:00
Andrew FerlitschandGitHub f73ff8a44f fix: bad link, title (#1017)
* fix: bad link, correct title

* fix: bad link, correct title
2022-09-28 13:49:53 -07:00
Andrew FerlitschandGitHub 48c5810bd7 fix: bad link, title (#1019)
* fix: bad link, title

* fix: bad link, title
2022-09-28 13:49:25 -07:00
Andrew FerlitschandGitHub 9821d8986c fix: bad link, title (#1020)
* fix: bad link, title

* fix: bad link, title
2022-09-28 13:48:57 -07:00
Andrew FerlitschandGitHub 207d5db3e9 fix: bad link, title (#1021)
* fix: bad link, title

* fix: bad link, title
2022-09-28 13:48:29 -07:00
Andrew FerlitschandGitHub 9deb05e3e7 fix: bad link (#1022)
* fix: bad links

* fix: bad links
2022-09-28 13:47:59 -07:00
Andrew FerlitschandGitHub 8dafc25aab fix: bad link (#1006)
* fix: bad link

* fix: bad link
2022-09-28 13:47:25 -07:00
ef10e7db53 Vertex AI Model Registry - AutoML model management notebook (#995)
* new notebook

* linter test passed

* linter test passed

* andy review

* linter test passed

* add codeowner

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-28 09:41:50 -07:00
Andrew FerlitschandGitHub cba907ddf8 fix: tuning the script (#1004) 2022-09-28 12:21:47 -04:00
16c3d7fe25 automl_video_classification_model_evaluation (#960)
* added model evaluation component

* linter test cases

* linter test cases

* model_name param issues resolved

* linter test case

* import issues resloved

* linter test cases

* made review changes

* made review changes

* ran linter test

* made review changes

* made review changes

* made review changes

* linter test

* ran linter test

* made review changes

* ran linter test

* made review changes

* ran linter test

* linter test

* review changes

* ran linter test

Co-authored-by: Ivan Cheung <ivans.mailbox@gmail.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-28 07:33:08 -07:00
60e1f92ef4 Vertex AI Model Registry - BQML and custom model management notebook (#991)
* add new notebook

* linter test passed

* clean text

* linter test passed

* add code owner new model registry notebook

* add more description

* linter test passed

* align with new template

* linter test passed

* andy reviews

* linter test passed

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-28 00:05:41 -07:00
Andrew FerlitschandGitHub fb392c6375 Issue 937 (#998)
* fix: issue 937

* fix: issue 937

* fix: wrong method for service account

* fix: wrong method for service account
2022-09-27 21:33:12 -07:00
b4d10bc5aa Modified SDK_Custom_Training_Python_Package_Managed_Text_Dataset_Tensorflow_Serving_Container.ipynb (#996)
* modified notebook, resolved error and modified notebook according to template

* ran linter

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-27 19:51:55 -07:00
4049250bad chore: Fix Workbench links. (#983)
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-27 15:24:51 -07:00
923db816e1 Added changes such as timestamp, removed colab references, added markup text mentioning usage of flag -q in a command for the file SDK_Custom_Container_Prediction (#503)
* Added changes in notebook

* Ran linter test

* Replaced Timestamp with UUID; Added 'delete-bucket' in cleanup; Added condition for repo creation and few other minor changes

* Ran Linter Test

* Made some minor changes to install packages

* Made minor changes to fix linter failed tests

* ran linter test

* Made some minor changes

* ran linter test

* addresses the review comments: fixes container build steps, license year, updates according to the template

* ran linter test

* removes beta from gcloud to avoid timeouts

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
Co-authored-by: Karl Weinmeister <11586922+kweinmeister@users.noreply.github.com>
Co-authored-by: SamyuktaDR <samyukta.dontireddy@springml.com>
Co-authored-by: SamyuktaDR <45586340+SamyuktaDR@users.noreply.github.com>
Co-authored-by: Krishna Chaitanya Movva <krishr2d2@gmail.com>
Co-authored-by: krishr2d2 <krishna.movva@springml.com>
2022-09-27 15:13:29 -07:00
Andrew FerlitschandGitHub 872f1561cd fix: argument handling improvements (#999) 2022-09-27 16:51:41 -04:00
8d7832de6e fix: issue 241479124 (#997)
* fix: issue 241479124

* fix: issue 241479124

Co-authored-by: gericdong <itseric@google.com>
2022-09-27 15:08:10 -04:00
Michael HuandGitHub f840017cda fix: bump gcpc version for bqml arima notebook (#985)
* fix: bump gcpc version for bqml arima notebook

* pr fixes
2022-09-27 11:02:38 -07:00
de3f35b8a6 Modified notebook sdk_automl_tabular_forecasting_batch.ipynb (#896)
* modified notebook

* ran linter

Co-authored-by: Ivan Cheung <ivans.mailbox@gmail.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-26 20:17:58 -07:00
b746bc80d4 Resolves shell-output issue in google_cloud_pipeline_components_model_upload_predict_evaluate.ipynb notebook (#878)
* resolves the shell-output issue + updates the structure based on the template

* ran linter test

* fixes issues from review: textual updates, delete_bucket=False

* ran linter test

Co-authored-by: Ivan Cheung <ivans.mailbox@gmail.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-26 16:27:29 -07:00
2001604d37 Modified pricing-optimization.ipynb (#867)
* modified notebook according to notebook_template.

* ran linter

* Added create dataset step

* ran linter

* replaced hardcoded dataset name with a variable

* ran linter

* changes suggested by nadrew done

* ran linter

* followed prolong lin comments, data cleaning now done in bigquery

* ran linter

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
Co-authored-by: Ivan Cheung <ivans.mailbox@gmail.com>
2022-09-26 15:37:48 -07:00
faa148f66e Bqml vertex model registry (#993)
* Add bqml-vertexai-model-registry notebook

* Run linter

* Add notebook to CODEOWNERS file

* Update the links

* Ran linter again

* Rename bigquey-ml folder to model-registry

* Add bigquery-ml folder

* Moved the notebook

* Deleted folder

* Resolve comments

* Use UUID

* Remove using existing endpoint

* Remove try statement

* Get model sample based on model's name

* Use job.result to check query job status

* Run linter

* Fix dataset not found error by adding region in bq client creation

* Revert changes

* Fix bq bugs

* Run linter

* Resolve comments

* Display dataframe

* Updated the codeowner file

* Updated the links and editted text

* Run linter

* Remove repeated resources

* Run linter

* Resolve comments

* Run linter

* Install pyarrow

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-26 18:22:57 -04:00
f184411666 Create a function to get notebook python version for execution (#828)
* Create a function to get notebook python version for execution

* Inject python version to yaml file

* Fix python version references

* Add python string to python version variable

* add python version extraction script (untested)

* Create a function to get notebook python version for execution

* Inject python version to yaml file

* Fix python version references

* Add python string to python version variable

* Remove one notebook condition

* Remove extra check and use python 3 as default version

* Use python3.9 as default version

* Update python version notebook parser

* Add python version to the notebook template

* Fix bug

* Update python version parser function

* Add python version to a notebook for testing

* Run linter

* Use regex in python version parser function

* Add new notebook for testing

* Use better variable name

* fix typo

* Use f string instead +

* Use python from env instead of using _PYTHON_VERSION

* Use simpler regex

* Add python version test notebook

* Fixed a mistake

* Updated notebook template with python version

* Fixed python version format

* Print log contents to stdout

* Remove failing notebook

* Run linter

* Remove extra steps in the printed log

* Edit comments

* Run linter

* Run linter

* Revert test changes

Co-authored-by: AG Sol <aarongabriel@google.com>
2022-09-26 14:32:53 -07:00
bdad774100 Vertex SDK AutoML Text Sentiment Analysis (#824)
* new changes for sentiment analysis notebook

* new changes for sentiment analysis notebook

* changed back to year 2021 text

* changed back to year 2021 text

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-25 08:37:58 -07:00
9abe9a643b Added Custom tabular regression model evaluation file (#942)
* added file

* removed unnecessary imports

* ran linter

* removed extra batch prediction component

* ran linter

* moved file to official

* changed links to point to official

* ran linter

* Jason comments addressed

* ran linter

* comments addressed

* ran linter

* comments addresed

* ran linter

* added predictionschema instance schema files

* ran linter

* Followed Karen Lin's comments

* ran linter

* replaced old prebuilt containers with latest ones

* ran linter

Co-authored-by: Ivan Cheung <ivans.mailbox@gmail.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-24 11:12:06 -07:00
ab230ca06f add fixes to sdk-feature-store.ipynb (formatting, link edits) (#913)
* fix sdk-feature-store.ipynb Workbench link

* adding changes

* fixing links

* lint issues:

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-24 09:37:06 -07:00
dcbd3702d2 Made uuid changes and cleaned Uj6 vertex sdk auto ml text classification notebook (#904)
* Made some minor changes to notebook

* Ran linter test

* Ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-24 09:03:11 -07:00
0505d0c04c Vizier sdk (#981)
* update: replace GAPIC with SDK

* update: replace GAPIC with SDK

Co-authored-by: gericdong <itseric@google.com>
2022-09-23 16:27:36 -04:00
a47e0aacbb Model monitor batch (#980)
* fix: batch monitoring notebook

* fix: batch monitoring notebook

Co-authored-by: gericdong <itseric@google.com>
2022-09-23 15:10:54 -04:00
15912adeaf Update the vizier sample to replace the gapic library with new Vertex Vizier SDK. (#979)
* Update the vizier codelab to replace the gapic library with new Vertex Vizier SDK.

* Added the [project_id] and [region] in the parameter field.

* Fixed the lint errors for vizier sample.

Co-authored-by: Ivan Cheung <ivans.mailbox@gmail.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-23 11:12:28 -07:00
Ivan NardiniandGitHub 35fdba7e1c Vertex AI Experiments - Title fix (#982)
* title fix

* linter test passed
2022-09-23 07:17:58 -07:00
f403fa9051 Made UUID changes for Sdk automl tabular regression batch bq (#976)
* Made UUID changes

* Ran lintertest

Co-authored-by: Ivan Cheung <ivans.mailbox@gmail.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-22 14:45:45 -07:00
0d346b136e Vertex AI Experiments - Comparing local trained models notebook - update (#971)
* clean and update comparing_local_trained_models based on feedback

* linter test passed

* fix libraries

* linter test passed

* andy review fixes

* linter test passed

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-22 12:21:22 -07:00
Andrew FerlitschandGitHub 60d71d29cc update: add explain example (#974) 2022-09-22 09:35:13 -07:00
28c872f4b6 chore(deps): update python docker tag to v3.10 (#977)
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-21 17:09:31 -07:00
Andrew FerlitschandGitHub c637d693b7 tune: pricing, branding, combining text cells (#966)
* tune: pricing, branding, combining text cells

* fix: lint
2022-09-21 13:20:01 -07:00
Andrew FerlitschandGitHub 5c3a216eb7 feat: Add notebook for automl text model online predict (#973) 2022-09-21 14:34:10 -04:00
Ivan CheungandGitHub 0b7831b0f4 Added Dockerfile for linter (#975)
Updated Dockerfile
2022-09-21 09:26:42 -07:00
Andrew FerlitschandGitHub 6a6f077ae4 update: add explain (#972) 2022-09-20 18:40:49 -04:00
Andrew FerlitschandGitHub 27f0a4bb63 feat: notebook for automl tabular online serving (#961)
* feat: notebook for automl tabular online serving

* feat: notebook for AutoML tabular model online prediction

* updates: add explain
2022-09-20 12:54:46 -07:00
1476453603 Moves Sentiment-Analysis notebook from community to official folder (#868)
* moves the sentiment_analysis notebook from community to official folder after making the updates

* removes unused modules

* ran linter test

* updates the dataset's GCS links and notebook links in the heading

* ran linter test

* fixes the typo(=)

* ran linter test

* removes wait() calls and IS_TESTING condition

* ran linter test

Co-authored-by: Ivan Cheung <ivans.mailbox@gmail.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-20 07:35:15 -07:00
dbafcb47ea Modified notebook UJ4 Vertex SDK AutoML Tabular Binary Classification (#891)
* modified notebook

* ran linter

* tensorflow was used only for file reading.So replaced tensorflow with pandas

* ran linter

* made text changes

* ran linter

* latest andrew domments addressed

* ran linter

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-19 14:46:22 -07:00
f20700f25a Model monitoring (#964)
* Changed protobuf version

* ran linter test

* Cleared execution outputs

* Ran Linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-19 11:31:01 -07:00
Andrew FerlitschandGitHub d1ca1cd7f8 fix: reported issues (#968) 2022-09-19 14:11:56 -04:00
Andrew FerlitschandGitHub 9b03fb7f8e fix: install issues (#969) 2022-09-19 09:43:07 -07:00
aac271eacc Sdk metric parameter tracking for custom jobs (#844)
* Replaced timestamp with UUID

* Ran Linter test

* Removed local kernel from metadata

* ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
Co-authored-by: Ivan Cheung <ivans.mailbox@gmail.com>
2022-09-16 11:43:45 -07:00
68b53e0d32 UJ11 Vertex SDK Hyperparameter Tuning (#957)
* library issues resolved

* library issues resolved

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-16 11:02:37 -07:00
Andrew FerlitschandGitHub bf354adfd3 fix: filename consistency (#952)
* fix: filename consistency

* fix: package name
2022-09-16 09:56:02 -07:00
Andrew FerlitschandGitHub 55ad5701e4 fix: pip dependency fixes (#965) 2022-09-16 12:51:05 -04:00
Andrew FerlitschandGitHub 918564dcc7 fix: missing delete dataset (#963) 2022-09-16 12:44:17 -04:00
19b3b5da0f Add Vertex AI hyperparameter tuning notebook for R using custom containers (#958)
* add unfinished notebook on hpt using R

* clear output

* add working version of notebook

* finish R HPT notebook

* update CODEOWNERS

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-15 08:37:16 -07:00
2bdab9a9b8 Fix export_additional_model_without_custom_ops argument in AutoML Tabular Workflows notebook (#914)
Co-authored-by: Helin Wang <helin@google.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-15 08:09:25 -07:00
Andrew FerlitschandGitHub 88e5d5d236 feat: notebook for automl image online prediction (#953) 2022-09-14 15:20:56 -04:00
Andrew FerlitschandGitHub 79730d191f fix: add details on dataset input formats (#951) 2022-09-13 18:43:08 -04:00
Andrew FerlitschandGitHub 019040e4cb fix: links (#950) 2022-09-13 15:15:43 -04:00
Andrew FerlitschandGitHub 4fd3514d6d feat: add index to batch features/notebooks (#949) 2022-09-13 14:29:46 -04:00
Andrew FerlitschandGitHub bb17381b03 fix: detecting copyright cell (#948) 2022-09-13 11:14:19 -07:00
Andrew FerlitschandGitHub 3f06f48282 fix: filename rename (#943)
* fix: filename rename

* fix: lint issues
2022-09-13 10:01:22 -07:00
33abd1e427 Move model evaluation notebooks from community to official (#940)
* Add automl regression model eval first draft

* Remove extra file

* Pring evaluation results

* adds the automl-tabular-classification notebook in model_evaluation folder

* removes unnecessary imports

* adjusts the imports inside the pipeline

* adjusts the imports

* elaborates imports inside pipeline

* modified regression notebook

* renamed pipeline displayname to resolve error

* Add automl regression model eval first draft

* Remove extra file

* Pring evaluation results

* modified some text

* added suggested updates from review: remove dataflow params, add/change textual descriptions, add UUID

* removes the output from the notebooks

* removes the extra matplotlib import

* ran linter test

* addressed soheila's comments

* ran linter

* addresses the review comments

* ran linter test

* removes the artifacts comment

* ran linter test

* reviewed comments

* ran linter

* addresses review comments: textual updates, removes unnecessary parameters

* ran linter test

* addressed comments

* ran linter

* removed unwanted variables

* ran linter

* addresses the tech-writer's comments + updates the pipeline image with data-sampler task

* ran linter test

* Update text

* Move model eval folder to official

* Update CODEOWNERS

* Run linter

* Removed problem_type parameter

* Run linter

* addresses Andrew's review comments: textual updates and removes additional gcpc installation

* ran linter test

* comments addressed

* ran linter

* removed trailing comma on last parameter of trainingjob.run

* ran linter

Co-authored-by: krishr2d2 <krishna.movva@springml.com>
Co-authored-by: sudarshan-SpringML <sudarshan.c@springml.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-13 09:28:16 -07:00
Peter PingandGitHub 1d9bfe9934 Stream Update v2 (#946)
* Stream Update v2

* correct codeowner name
2022-09-12 18:24:53 -04:00
fb9defa985 Merge to sparkml branch (#881) (#882)
* Merge to sparkml branch (#881)

* feat: initial commit

* feat: WIP

* feat: still WIP, need to work on EDA

* fix: change name, still WIP

* fix: initial draft

* install geopandas in the notebook

* fix: add codeowners

* fix: install pyarrow

* fix: add condition for testing env

* fix: indentation

* fix: add dependencies for gpd

* fix: install seaborn

* fix: isort and codeowner

* fix: description

* fix: add debriefing the result

* fix: decrease sample size for testing

* fix: code review wip

* fix: code review

* fix: change dataset to 2017

* fix: code review

* fix: not using sql

* fix: lint

* fix: delete outputs

* fix: code review

* fix: typo

* fix: make sample pandas df if not testing

* Update spark_ml.ipynb (#884)

(Tech writer edit) Editing for syntax and clarification.

* small text updates

* lint fixes

* constraining plotting to non-test environments

* lint fixes

* put plotting back into tests

* address review feedback

* added comment to rerun cell if URLError thrown

Co-authored-by: Hyunuk Lim <hyunuklim@google.com>
Co-authored-by: aman-ebay <amancuso@google.com>
2022-09-12 17:28:09 -04:00
Soheila ZangenehandGitHub 824fb689e4 Bqml vertex model registry (#945)
* Add bqml-vertexai-model-registry notebook
2022-09-12 16:44:46 -04:00
Andrew FerlitschandGitHub c48dd8662b Issue 235883443 (#944)
* fix: remove obsoleted case

* fix: remove obsoleted case
2022-09-12 15:49:52 -04:00
gericdongandGitHub f251721d23 Enable Cloud Resource Manager API (#939)
* Enable Cloud Resource Manager API

* Reformatted file
2022-09-09 14:05:36 -07:00
Andrew FerlitschandGitHub e949eb128f fix: autoreview of mlops notebooks (#936)
* fix: tune for autoreview

* fix: tune for autoreview
2022-09-09 12:02:50 -04:00
df48e74f59 feat: Batch prediction for custom text model (#934)
* feat: notebook for custom text model batch prediction

* feat: notebook for custom text model batch prediction

Co-authored-by: gericdong <itseric@google.com>
2022-09-09 09:26:13 -04:00
MarcandGitHub ce9e6ecf62 add back pip install of xai sdk (#935) 2022-09-09 01:02:56 +01:00
9ab5f4274a Add automl regression and classification with model evaluation (#911)
* Add automl regression model eval first draft

* Remove extra file

* Pring evaluation results

* adds the automl-tabular-classification notebook in model_evaluation folder

* removes unnecessary imports

* adjusts the imports inside the pipeline

* adjusts the imports

* elaborates imports inside pipeline

* modified regression notebook

* renamed pipeline displayname to resolve error

* Add automl regression model eval first draft

* Remove extra file

* Pring evaluation results

* modified some text

* added suggested updates from review: remove dataflow params, add/change textual descriptions, add UUID

* removes the output from the notebooks

* removes the extra matplotlib import

* ran linter test

* addressed soheila's comments

* ran linter

* addresses the review comments

* ran linter test

* removes the artifacts comment

* ran linter test

* reviewed comments

* ran linter

* addresses review comments: textual updates, removes unnecessary parameters

* ran linter test

* addressed comments

* ran linter

* removed unwanted variables

* ran linter

* addresses the tech-writer's comments + updates the pipeline image with data-sampler task

* ran linter test

Co-authored-by: krishr2d2 <krishna.movva@springml.com>
Co-authored-by: sudarshan-SpringML <sudarshan.c@springml.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-08 14:42:04 -07:00
Andrew FerlitschandGitHub 29e584a422 feat: add batch automl video notebook (#933)
* feat: batch for automl video

* feat: batch for automl video

* feat: batch for automl video
2022-09-08 11:34:29 -07:00
MarcandGitHub beabb87cff fix import problem described in b/245553683 (#932)
* fix aiplatform import problem

* lint fix

* build fix, missing tensforflow

* lint fixes
2022-09-08 16:47:20 +01:00
e3f6717ff6 community -> official for bqml-online-prediction.ipynb (#788)
* move bqml-vertex notebook from community to official

* add to CODEOWNERS official

* fix errors for execution-test

* fix project_id line

* fix linting

* fixes re: comments from sarahcdugan

* fix links at top of notebook from community/ to official/

* added UUID to model name

* fix linting

* fix error in TIMESTAMP --> UUID

* fixing linting double space

* fixes re: ivanmkc comments

* fixed notebook after linting issues

* linting via cloud shell

* simplified run_bq_query function

* linting

Co-authored-by: Ivan Cheung <ivans.mailbox@gmail.com>
2022-09-07 18:20:02 -04:00
fd30c4014a Minor fixes for CPR Pytorch sample (#744)
* Minor fixes for CPR Pytorch sample: Add missing test data, add auth info to readme, scrub private project and bucket names from config, tolerate missing config.json in unit tests.

* Minor fixes for CPR Pytorch sample: Add missing test data, add auth info to readme, scrub private project and bucket names from config, tolerate missing config.json in unit tests.

* Fix merge conflicts

* fix typo

* Point CPR links to main branch of SDK repo.

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-07 13:02:55 -07:00
Andrew FerlitschandGitHub 4be8b0a59a fix: finetuning of batch notebooks (#930)
* fix: fine-tuning

* fix: fine-tuning
2022-09-07 10:44:44 -07:00
Andrew FerlitschandGitHub aa09d46265 feat: batch prediction for AutoML text models (#929)
* feat: Automl text model batch predict

* feat: Automl text model batch predict

* feat: Automl text model batch predict
2022-09-07 13:14:16 -04:00
Andrew FerlitschandGitHub 5667967131 feat: add BQ input example (#926)
* feat: add notebook for custom tabular batch predict

* feat: add notebook for custom tabular batch predict

* feat: add example for BQ input

* feat: add example for BQ input

* feat: add example for BQ input

* feat: add example for BQ input
2022-09-07 08:38:36 -07:00
4e4f532658 feat: batch prediction for automl tabular models (#928)
* feat: notebook for AutoML tabular batch prediction

* feat: notebook for AutoML tabular batch prediction

Co-authored-by: gericdong <itseric@google.com>
2022-09-06 15:53:54 -04:00
Andrew FerlitschandGitHub 14b2ce4f2e feat: notebook for batch predict for automl image models (#927)
* feat: batch predict for automl image model

* feat: batch predict for automl image model
2022-09-06 11:45:04 -04:00
Chun-Hsiang WangandGitHub c14b98c92d samples: Minor fix for the wording. (#924) 2022-09-05 10:42:25 -07:00
8275ea6c49 fix: correct the download_url (#923)
* fix: correct the download_url

* fix: fixed formatting issue

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-02 17:04:42 -04:00
40fbffcc95 Sdk automl image object detection batch (#869)
* changed to andrew comments

* changes according to andrew comments

* changes according to andrew comments

* review changes

* review changes

* review changes

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-02 13:34:25 -07:00
Andrew FerlitschandGitHub 08bb513488 feat: Batch prediction for custom tabular model (#920)
* feat: add notebook for custom tabular batch predict

* feat: add notebook for custom tabular batch predict
2022-09-01 20:33:34 -04:00
Chun-Hsiang WangandGitHub b298f83cd3 Vertex Prediction PyTorch Experimental: Add a sample for pre-built PyTorch deployments. (#898)
* samples: Add a new sample for pre-built Pytorch deployments. It's
borrowed from the examples in community-content/pytorch_text_classification_using_vertex_sdk_and_gcloud.

* samples: Removed all training related stuff in the notebooks.

* samples: Fixed comments.

* samples: Updated readme.

* samples: Updated emails for Pytorch launch.
2022-09-01 11:48:59 -07:00
Andrew FerlitschandGitHub 659cbb54c4 feat: add model monitoring with custom container (#919)
* feat: add notebook using custom deployment container

* feat: add notebook using custom deployment container
2022-09-01 10:22:05 -07:00
6ddcaa540a fix: tf serving workaround (#917)
* fix: pin TF serving image

* fix: pin TF serving image

Co-authored-by: gericdong <itseric@google.com>
2022-09-01 12:58:27 -04:00
1656c57b18 feat: extend image batch notebook (#916)
* feat: add notebook for custom image model batch prediction

* feat: add notebook for custom image model batch prediction

* fix: review comments

* fix: review comments

* feat: extend image batch notebook

* feat: extend image batch notebook

Co-authored-by: gericdong <itseric@google.com>
2022-09-01 09:56:36 -07:00
6cac60f74a Sdk feature store ver1 (#790)
* Added condition to create Featurestore if it doesn't exist

* Ran Linter Test

* Made changes mentioned in review

* Ran Linter Test

* Attached uuid to featurestore_id to avoid error while creating featurestore with existing name

* Ran linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-09-01 08:57:16 -07:00
Andrew FerlitschandGitHub 55e37f795c feat: notebook for batch prediction with custom image model (#915)
* feat: add notebook for custom image model batch prediction

* feat: add notebook for custom image model batch prediction

* fix: review comments

* fix: review comments
2022-08-31 10:38:31 -07:00
c030d7ef74 use dataset instead of datasets (#892)
less chance for an error and confusion in name clashing with the `datasets` pypi package also used in the notebook.

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-31 07:44:46 -07:00
Andrew FerlitschandGitHub 96be449c69 feat: add notebook for MM autoML (#912)
* feat: model monitoring for AutoML

* feat: model monitoring for AutoML

* fix: correction on AutoML

* fix: correction on AutoML
2022-08-30 12:45:45 -07:00
e40ddab4d5 Upgrade to DataprocPySparkBatch v1 component and add Vertex AI placeholder features (#910)
* Fix typo in notebook heading.

* Fix linting issues.

* Use gcpc v1 components and use Vertex AI for model upload and serving.

* Notebook cleanup

* Minor heading cleanup

* Fix linting issues

* Fix linting issues

* Fix linting issues

* Fix linting issues

Co-authored-by: Win Woo <wwoo@google.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-30 10:46:21 -07:00
Michael HuandGitHub d02bc2d56b pin arima notebook dependencies (#905)
Pins the versions of packages installed in the notebook in anticipation for a breaking change to the GCPC package.
2022-08-29 19:35:54 -04:00
76b641b23d fix: private endpoint example (#909)
* fix: remove gcloud usage

* fix: remove gcloud usage

* fix: review comments

* fix: review comments

Co-authored-by: nayaknishant <nishantnayak@google.com>
2022-08-29 12:16:18 -07:00
Andrew FerlitschandGitHub bbf4345e76 fix: remove Pantheon links (#908)
* fix: issue 194103604

* fix: issue 194103604
2022-08-28 11:24:32 -04:00
058358a795 Vertex SDK AutoML Image Object Detection (#808)
* new notebook Vertex SDK AutoML Image Object Detection

* new notebook Vertex SDK AutoML Image Object Detection

* new notebook of Vertex SDK AutoML Image Object Detection

* new notebook of Vertex SDK AutoML Image Object Detection

* linter test

* linter test

* andrew commented changes

* andrew commented changes

* review changes

* review changes

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-26 15:56:46 -07:00
Andrew FerlitschandGitHub 1c2f75f680 update: GetVertexModelOp (#907)
* update: use GetVertexModelOp

* update: use GetVertexModelOp
2022-08-26 12:12:09 -07:00
Andrew FerlitschandGitHub 999866fad1 feat: model monitoring custom (#906)
* feat: notebook for custom models

* feat: notebook for custom models

* fix: refining

* fix: refining

* fix: review updates

* fix: review updates
2022-08-26 08:58:54 -07:00
89f4571a2c Create explore_data_in_bigquery_with_workbench.ipynb (#885)
* Create explore_data_in_bigquery_with_workbench.ipynb

Adding in notebook for exploratory data analysis as part of "Data to AI" effort. See this Colab for what this notebook looks like after it is run: https://colab.research.google.com/drive/1JeNeMtj2A_5P5vo9wxSkrwHQM5JQSoAu. Submitting it with outputs shown since a lot of this about interactive visualization, which can inspire folks to use/read the notebook beyond just the code.

* Update CODEOWNERS

Adding owner for forthcoming exploratory data analysis notebook

* Update CODEOWNERS

* Updating exploratory data analysis notebook with latest updates from linter/review

* Updated notebook formatting to try to pass format test

* Trying again to pass notebook formatting test

* Trying again to pass notebook formatting test

* Trying again to pass notebook formatting test

* Linted version of notebook & better project picker

* Uploading linted version from ivanmkc@

* Update CODEOWNERS with EDA notebook

* Updated notebook w/ Tech Writer edits, re-ran all

* 1-2 minor text updates, try to pass linter again

* Trying w/ updated linted file from ivanmkc@

Co-authored-by: Ivan Cheung <ivans.mailbox@gmail.com>
Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-26 08:46:17 -07:00
eaff81fd97 New Build model experimentation lineage with prebuild code (#785)
* new changes of build model notebook

* new changes of build model notebook

* linter test issues

* linter test issues

* review changes

* review changes

* review changes

* review changes

* review changes

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-26 08:42:15 -07:00
976ed94cf2 metrics_viz_run_compare_kfp (#847)
* added new cell for is_colab condition

* added new cell for is_colab condition

* changes andrew comments

* changes andrew comments

* review changes

* review changes

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-26 08:26:58 -07:00
haomengchaoandGitHub 8ab8ef9ca9 update featurestore api version (#861)
* update api version

* fix tests

* remove unused import

* Run lint to format the change
2022-08-25 10:05:45 -07:00
eaff80a920 Fraud detection notebook2 (#821)
* Made minor changes

* Ran linter test

* Made changes mentioned in the review

* Ran Linter test

Co-authored-by: Andrew Ferlitsch <aferlitsch@google.com>
2022-08-25 09:49:24 -07:00
Andrew FerlitschandGitHub 8646285c26 fix: fine-tuning (#902)
* feat: new mm notebook

* feat: new mm notebook

* fix: fine-tuning

* fix: fine-tuning

* fix: review comments

* fix: review comments

* fix: review comments

* fix: review comments
2022-08-25 08:34:34 -07:00
214 changed files with 71952 additions and 16348 deletions
@@ -17,13 +17,16 @@ import concurrent
import dataclasses
import datetime
import functools
import json
import git
import operator
import os
import pathlib
import re
import subprocess
import utils
from typing import List, Optional
from utils import util
import execute_notebook_helper
import execute_notebook_remote
@@ -35,6 +38,7 @@ from utils import NotebookProcessors, util
# A buffer so that workers finish before the orchestrating job
WORKER_TIMEOUT_BUFFER_IN_SECONDS: int = 60 * 60
PYTHON_VERSION = "3.9" # Set default python version
def format_timedelta(delta: datetime.timedelta) -> str:
@@ -66,6 +70,7 @@ class NotebookExecutionResult:
log_url: str
output_uri: str
build_id: str
logs_bucket: str
error_message: Optional[str]
@property
@@ -110,6 +115,33 @@ def _process_notebook(
nbformat.write(nb, new_file)
def _get_notebook_python_version(notebook_path: str) -> str:
"""
Get the python version for running the notebook if it is specified in
the notebook.
"""
python_version = PYTHON_VERSION
# Load the notebook
file = open(notebook_path)
src = file.read()
nb_json = json.loads(src)
#Iterate over the cells in the ipynb
for cell in nb_json['cells']:
if cell['cell_type'] == 'markdown':
markdown = str.join('', cell['source'])
# Look for the python version specification pattern
re_match = re.search('python version = (\d\.\d)', markdown, flags=re.IGNORECASE)
if re_match:
# get the version number
python_version = re_match.group(1)
break
return python_version
def _create_tag(filepath: str) -> str:
tag = os.path.basename(os.path.normpath(filepath))
tag = re.sub("[^0-9a-zA-Z_.-]+", "-", tag)
@@ -160,6 +192,7 @@ def process_and_execute_notebook(
output_uri=notebook_output_uri,
log_url="",
build_id="",
logs_bucket="",
error_message=None,
)
@@ -167,6 +200,10 @@ def process_and_execute_notebook(
time_start = datetime.datetime.now()
operation = None
try:
# Get the python version for running the notebook if specified
notebook_exec_python_version = _get_notebook_python_version(notebook_path=notebook)
print(f"Running notebook with python {notebook_exec_python_version}")
# Pre-process notebook by substituting variable names
_process_notebook(
notebook_path=notebook,
@@ -193,11 +230,13 @@ def process_and_execute_notebook(
private_pool_id=private_pool_id,
private_pool_region=variable_region,
timeout_in_seconds=timeout_in_seconds,
python_version=notebook_exec_python_version
)
operation_metadata = BuildOperationMetadata(mapping=operation.metadata)
result.build_id = operation_metadata.build.id
result.log_url = operation_metadata.build.log_url
result.logs_bucket = operation_metadata.build.logs_bucket
# Block and wait for the result
operation_result = operation.result()
@@ -339,7 +378,7 @@ def process_and_execute_notebooks(
seconds=max(timeout - WORKER_TIMEOUT_BUFFER_IN_SECONDS, 0)
)
if len(notebooks) > 1:
if len(notebooks) >= 1:
notebook_execution_results: List[NotebookExecutionResult] = []
print(f"Found {len(notebooks)} modified notebooks: {notebooks}")
@@ -404,6 +443,7 @@ def process_and_execute_notebooks(
result.log_url,
result.output_uri,
result.output_uri_web,
result.logs_bucket
]
for result in results_sorted
],
@@ -414,10 +454,35 @@ def process_and_execute_notebooks(
"log_url",
"output_uri",
"output_uri_web",
"logs_bucket"
],
)
)
if len(notebooks) == 1:
print("="*100)
print("The notebook execution build log:\n")
print("="*100)
build_id = results_sorted[0].build_id
logs_bucket_name = (results_sorted[0].logs_bucket).removeprefix("gs://")
log_file_name = f"log-{build_id}.txt"
log_contents = util.download_blob_into_memory(
bucket_name=logs_bucket_name,
blob_name=log_file_name,
download_as_text=True
)
# Remove extra steps from the log
match = re.search("starting Step #4", log_contents, flags=re.IGNORECASE)
if match is not None:
match_index = match.span()[0]
print(log_contents[match_index:])
else:
print(log_contents)
print("\n=== END RESULTS===\n")
total_notebook_duration = functools.reduce(
@@ -433,25 +498,5 @@ def process_and_execute_notebooks(
# Raise error if any notebooks failed
if not all([result.is_pass for result in results_sorted]):
raise RuntimeError("Notebook failures detected. See logs for details")
elif len(notebooks) == 1:
notebook = notebooks[0]
# Pre-process notebook by substituting variable names
_process_notebook(
notebook_path=notebook,
variable_project_id=variable_project_id,
variable_region=variable_region,
variable_service_account=variable_service_account,
variable_vpc_network=variable_vpc_network,
)
execute_notebook_helper.execute_notebook(
notebook_source=notebook,
output_file_or_uri="/".join(
[artifacts_bucket, pathlib.Path(notebook).name]
),
should_log_output=True,
)
else:
print("No notebooks modified in this pull request.")
+5
View File
@@ -40,6 +40,7 @@ def execute_notebook_remote(
private_pool_region: Optional[str],
tag: Optional[str],
timeout_in_seconds: Optional[int] = None,
python_version: Optional[str] = None
) -> operation.Operation:
"""Create and execute a single notebook on Google Cloud Build"""
# Load build steps from YAML
@@ -50,8 +51,12 @@ def execute_notebook_remote(
"_PYTHON_IMAGE": container_uri,
"_NOTEBOOK_GCS_URI": notebook_uri,
"_NOTEBOOK_OUTPUT_GCS_URI": notebook_output_uri,
"_PYTHON_VERSION" : f"python{python_version}"
}
if python_version is not None:
substitutions["_PYTHON_VERSION"] = "python" + python_version
build = cloudbuild_v1.Build()
options: Optional[client_options.ClientOptions] = None
@@ -10,21 +10,21 @@ steps:
entrypoint: /bin/sh
args:
- -c
- python3 .cloud-build/CheckPythonVersion.py -q
- ${_PYTHON_VERSION} .cloud-build/CheckPythonVersion.py -q
# Create a virtual environment
- name: ${_PYTHON_IMAGE}
entrypoint: /bin/sh
args:
- -c
- python3 -m venv workspace/env
- ${_PYTHON_VERSION} -m venv workspace/env
# Install Python dependencies
- name: ${_PYTHON_IMAGE}
entrypoint: /bin/sh
args:
- -c
- . workspace/env/bin/activate &&
python3 -m pip -q install -U pip &&
python3 -m pip -q install -U -r .cloud-build/requirements.txt
python -m pip -q install -U pip &&
python -m pip -q install -U -r .cloud-build/requirements.txt
# Install Python dependencies and run testing script
- name: ${_PYTHON_IMAGE}
entrypoint: /bin/sh
@@ -32,7 +32,7 @@ steps:
- -c
- |
. workspace/env/bin/activate &&
python3 .cloud-build/execute_notebook_cli.py --notebook_source "${_NOTEBOOK_GCS_URI}" --output_file_or_uri "${_NOTEBOOK_OUTPUT_GCS_URI}"
python .cloud-build/execute_notebook_cli.py --notebook_source "${_NOTEBOOK_GCS_URI}" --output_file_or_uri "${_NOTEBOOK_OUTPUT_GCS_URI}"
env:
- 'IS_TESTING=1'
timeout: 86400s
+3 -2
View File
@@ -1,5 +1,6 @@
notebooks/official/vizier/gapic-vizier-multi-objective-optimization.ipynb
notebooks/official/pipelines/lightweight_functions_component_io_kfp.ipynb
notebooks/official/ml_metadata/sdk-metric-parameter-tracking-for-locally-trained-models.ipynb
notebooks/official/pipelines/metrics_viz_run_compare_kfp.ipynb
notebooks/official/matching_engine/sdk_matching_engine_for_indexing.ipynb
notebooks/official/custom/custom-tabular-bq-managed-dataset.ipynb
notebooks/official/matching_engine/sdk_matching_engine_for_indexing.ipynb
.cloud-build/tests/python_version_test.ipynb
+1 -1
View File
@@ -1 +1 @@
notebooks/official/pipelines/metrics_viz_run_compare_kfp.ipynb
notebooks/official/custom/custom-tabular-bq-managed-dataset.ipynb
@@ -0,0 +1,61 @@
{
"cells": [
{
"cell_type": "markdown",
"metadata": {
"id": "57a3d44ed8a8"
},
"source": [
"### Set up your Google Cloud project\n",
"\n",
"**_NOTE_**: This notebook has been tested in the following environment:\n",
"\n",
"* Python version = 3.7\n",
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"1. [Select or create a Google Cloud project](https://console.cloud.google.com/cloud-resource-manager). When you first create an account, you get a $300 free credit towards your compute/storage costs.\n",
"\n",
"1. [Make sure that billing is enabled for your project](https://cloud.google.com/billing/docs/how-to/modify-project).\n",
"\n",
"1. [Enable the Vertex AI API and Compute Engine API](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com,compute_component).\n",
"\n",
"1. If you are running this notebook locally, you will need to install the [Cloud SDK](https://cloud.google.com/sdk).\n",
"\n",
"1. Enter your project ID in the cell below. Then run the cell to make sure the\n",
"Cloud SDK uses the right project for all the commands in this notebook.\n",
"\n",
"**Note**: Jupyter runs lines prefixed with `!` as shell commands, and it interpolates Python variables prefixed with `$` into these commands."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "c6516f90311b"
},
"outputs": [],
"source": [
"# test if the right python version is being used\n",
"import sys\n",
"\n",
"actual_python_version = f\"{sys.version_info.major}.{sys.version_info.minor}\"\n",
"print(f\"Runtime python version: {actual_python_version}\")\n",
"\n",
"assert actual_python_version == \"3.7\", \"Wrong python version!\""
]
}
],
"metadata": {
"colab": {
"name": "python_version_test.ipynb",
"toc_visible": true
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
}
},
"nbformat": 4,
"nbformat_minor": 0
}
+32 -1
View File
@@ -3,7 +3,7 @@ import subprocess
import tarfile
import uuid
from datetime import datetime
from typing import Optional
from typing import Optional, Union
from google.auth import credentials as auth_credentials
from google.cloud import storage
@@ -58,3 +58,34 @@ def archive_code_and_upload(staging_bucket: str):
print(f"Uploaded source code archive to {source_archived_file_gcs}")
return source_archived_file_gcs
def download_blob_into_memory(
bucket_name: str,
blob_name: str,
download_as_text: Optional[bool]=False
) -> Union[bytes, str]:
"""
Downloads a blob into memory as byte or as text if
download_as_text is set to True.
"""
storage_client = storage.Client()
bucket = storage_client.bucket(bucket_name)
# Construct a client side representation of a blob.
blob = bucket.blob(blob_name)
# Download the blob content
if download_as_text:
contents = blob.download_as_text()
else:
contents = blob.download_as_bytes()
print(
f"Downloaded storage object {blob_name} from bucket {bucket_name}."
)
return contents
+20
View File
@@ -0,0 +1,20 @@
# To use this image, run this command with the desired notebook args from the top-level vertex-ai-samples directory:
# 1. To lint all changed notebooks:
# docker run -v ${PWD}:/setup/app gcr.io/python-docs-samples-tests/notebook_linter:latest
# 2. To lint specific notebooks:
# docker run -v ${PWD}:/setup/app gcr.io/python-docs-samples-tests/notebook_linter:latest notebooks/1.ipynb notebooks/2.ipynb
FROM python:3.10
WORKDIR setup
COPY ./requirements.txt .
COPY ./run_linter.sh .
# Install dependencies.
RUN pip install --upgrade pip
RUN pip install -r requirements.txt
WORKDIR app
ENTRYPOINT ["/setup/run_linter.sh"]
+14 -4
View File
@@ -47,12 +47,22 @@ done
echo "Test mode: $is_test"
# Read in user-provided notebooks
notebooks=()
for arg in "$@"; do
if [[ $arg == *.ipynb ]]; then
notebooks+=("$arg")
fi
done
# Only check notebooks in test folders modified in this pull request.
# Note: Use process substitution to persist the data in the array
notebooks=()
while read -r file || [ -n "$line" ]; do
notebooks+=("$file")
done < <(git diff --name-only main... | grep '\.ipynb$')
if [ ${#notebooks[@]} -eq 0 ]; then
echo "Checking for changed notebooked using git"
while read -r file || [ -n "$line" ]; do
notebooks+=("$file")
done < <(git diff --name-only main... | grep '\.ipynb$')
fi
problematic_notebooks=()
if [ ${#notebooks[@]} -gt 0 ]; then
+1
View File
@@ -1,5 +1,6 @@
* @vertex-ai-samples-contributors @GoogleCloudPlatform/cloudml-samples-owners
/tf_agents_bandits_movie_recommendation_with_kfp_and_vertex_sdk @yinghsienwu
/pytorch_pre_built_images_deployment @googleapis/vertex-prediction-team
/pytorch_text_classification_using_vertex_sdk_and_gcloud @RajeshThallam
/pytorch_text_classification_using_vertex_sdk_and_gcloud @RajeshThallam @ultrons
/sklearn_text_classification_from_script_using_vertex_sdk @maxhardt
@@ -2,4 +2,5 @@ cpr_model_server.py
entrypoint.py
state_dict.pth
config.json
**/__pycache__
**/__pycache__
!testdata/**
@@ -2,7 +2,7 @@
## About CPR
CPR ([custom prediction routines](https://github.com/googleapis/python-aiplatform/blob/custom-prediction-routine/google/cloud/aiplatform/prediction/README.md)) is a framework designed by Google Cloud developers to make it easier to combine machine learning models with custom preprocessing and postprocessing logic in a real-time serving application.
CPR ([custom prediction routines](https://github.com/googleapis/python-aiplatform/blob/main/google/cloud/aiplatform/prediction/README.md)) is a framework designed by Google Cloud developers to make it easier to combine machine learning models with custom preprocessing and postprocessing logic in a real-time serving application.
## Using this example
@@ -34,6 +34,23 @@ Finally, install the Python modules required to build and run the model server:
pip install -r requirements.txt
```
### Auth
This example uses Google Cloud Storage for hosting model artifacts and Artifact Registry to store the container image.
You'll need to authorize yourself before you can interact with these.
First, log in to GCP with application default credentials:
```sh
gcloud auth application-default login
```
Next, if you haven't done so already, set up the [gcloud credential helper](https://cloud.google.com/artifact-registry/docs/docker/authentication)
for the Artifact Registry region where you intend to host the image.
```
gcloud auth configure-docker <region>-docker.pkg.dev
```
### Predictor
The `TimmPredictor` class in `timm_serving/predictor.py` implements most of the important logic for the server.
@@ -60,9 +60,9 @@ class CPRConfig(object):
image: str = "timm_predictor:latest"
artifact_local_dir: str = ""
region: str = "us-central1"
project_id: str = "samthrasher-experimental"
project_id: str = "<your project ID here>"
repository: str = "cpr-images"
artifact_gcs_dir: str = "gs://samthrasher-cpr-example/timm-vit224/"
artifact_gcs_dir: str = "gs://<your bucket ID here>/timm-vit224/"
model_name: str = ""
endpoint_name: str = ""
machine_type: str = "n1-standard-2"
@@ -5,4 +5,4 @@ timm==0.5.4
smart_open==6.0.0
google-cloud-storage>=1.26.0,<2.0.0dev
google-cloud-aiplatform[prediction] @ git+https://github.com/googleapis/python-aiplatform.git@custom-prediction-routine
google-cloud-aiplatform[prediction]>=1.16.0
@@ -70,7 +70,10 @@ class PredictorUnitTests(absltest.TestCase):
def setUp(self):
super().setUp()
self.config = CPRConfig()
self.config.load()
try:
self.config.load()
except FileNotFoundError:
logging.info("No saved config file found, using default values.")
self.predictor = predictor.TimmPredictor()
def test_load_from_saved_state_dict_ok(self):
@@ -170,7 +173,10 @@ class ServerEndToEndTests(absltest.TestCase):
def setUp(self):
super().setUp()
self.config = CPRConfig()
self.config.load()
try:
self.config.load()
except FileNotFoundError:
logging.info("No saved config file found, using default values.")
self.local_model = cpr.LocalModel(
serving_container_spec=aiplatform.gapic.ModelContainerSpec(
image_uri=self.config.image
@@ -0,0 +1 @@
blah
@@ -0,0 +1,30 @@
# PyTorch Deployment on Google Cloud: Text Classification
**This is an Experimental release**, covered by the Pre-GA Offerings Terms of your Google Cloud Platform [Terms of Service](https://cloud.google.com/terms).
Experiments are focused on validating a prototype and are not guaranteed to be released. They are not intended for production use or covered by any SLA, support obligation, or deprecation policy and might be subject to backward-incompatible changes.
**Kindly drop us a note before you run any scale tests.**
**Do not hesitate to contact vertexai-prediction-preview-feedback@google.com if you have any questions or run into any issues.**
The projects need to be added to the allowlist in order to deploy PyTorch models using Vertex AI Prediction pre-built PyTorch images. If you are interested in the feature, please send an email to vertexai-prediction-preview-feedback@google.com to provide your project numbers OR project ids.
## Overview
In the PyTorch on Google Cloud series of blog posts, we aim to share how to deploy PyTorch models at scale on [Vertex AI](https://cloud.google.com/vertex-ai).
This tutorial on text classification shows how to deploy a PyTorch based text classification model on [Vertex AI](https://cloud.google.com/vertex-ai/docs/start/client-libraries#python) using Vertex SDK and [`gcloud ai`](https://cloud.google.com/sdk/gcloud/reference/beta/ai).
## Notebooks
| <h4>Notebook</h4> | <h4>Description</h4> |
| :-------- | :------- |
| [pytorch-text-classification-vertex-ai-deploy.ipynb](./pytorch-text-classification-vertex-ai-deploy.ipynb) | Notebook to show deploying a PyTorch model on Vertex AI |
## Folders
| <h4>Folder Name</h4> | <h4>Description</h4> |
| :-------- | :------- |
| [`predictor`](./predictor) | Folder with custom prediction handler to deploy a PyTorch model to Vertex Prediction. In the [notebook](./pytorch-text-classification-vertex-ai-deploy.ipynb), this folder is used for deploying a PyTorch model on Vertex AI using Vertex Prediction pre-built PyTorch images |
@@ -0,0 +1,91 @@
import os
import json
import logging
import torch
from transformers import AutoModelForSequenceClassification, AutoTokenizer
from ts.torch_handler.base_handler import BaseHandler
logger = logging.getLogger(__name__)
class TransformersClassifierHandler(BaseHandler):
"""
The handler takes an input string and returns the classification text
based on the serialized transformers checkpoint.
"""
def __init__(self):
super(TransformersClassifierHandler, self).__init__()
self.initialized = False
def initialize(self, ctx):
""" Loads the model.pt file and initialized the model object.
Instantiates Tokenizer for preprocessor to use
Loads labels to name mapping file for post-processing inference response
"""
self.manifest = ctx.manifest
properties = ctx.system_properties
model_dir = properties.get("model_dir")
self.device = torch.device("cuda:" + str(properties.get("gpu_id")) if torch.cuda.is_available() else "cpu")
# Read model serialize/pt file
serialized_file = self.manifest["model"]["serializedFile"]
model_pt_path = os.path.join(model_dir, serialized_file)
if not os.path.isfile(model_pt_path):
raise RuntimeError("Missing the model.pt or pytorch_model.bin file")
# Load model
self.model = AutoModelForSequenceClassification.from_pretrained(model_dir)
self.model.to(self.device)
self.model.eval()
logger.debug('Transformer model from path {0} loaded successfully'.format(model_dir))
# Ensure to use the same tokenizer used during training
self.tokenizer = AutoTokenizer.from_pretrained('bert-base-cased')
# Read the mapping file, index to object name
mapping_file_path = os.path.join(model_dir, "index_to_name.json")
if os.path.isfile(mapping_file_path):
with open(mapping_file_path) as f:
self.mapping = json.load(f)
else:
logger.warning('Missing the index_to_name.json file. Inference output will default.')
self.mapping = {"0": "Negative", "1": "Positive"}
self.initialized = True
def preprocess(self, data):
""" Preprocessing input request by tokenizing
Extend with your own preprocessing steps as needed
"""
text = data[0].get("data")
if text is None:
text = data[0].get("body")
sentences = text.decode('utf-8')
logger.info("Received text: '%s'", sentences)
# Tokenize the texts
tokenizer_args = ((sentences,))
inputs = self.tokenizer(*tokenizer_args,
padding='max_length',
max_length=128,
truncation=True,
return_tensors = "pt")
return inputs
def inference(self, inputs):
""" Predict the class of a text using a trained transformer model.
"""
prediction = self.model(inputs['input_ids'].to(self.device))[0].argmax().item()
if self.mapping:
prediction = self.mapping[str(prediction)]
logger.info("Model predicted: '%s'", prediction)
return [prediction]
def postprocess(self, inference_output):
return inference_output
@@ -0,0 +1,5 @@
{
"0": "Negative",
"1": "Positive"
}
@@ -658,8 +658,8 @@
},
"outputs": [],
"source": [
"datasets = load_dataset(\"imdb\")\n",
"datasets"
"dataset = load_dataset(\"imdb\")\n",
"dataset"
]
},
{
@@ -668,7 +668,7 @@
"id": "RzfPtOMoIrIu"
},
"source": [
"The `datasets` object itself is [`DatasetDict`](https://huggingface.co/docs/datasets/package_reference/main_classes.html#datasetdict), which contains one key for the training, validation and test set."
"The `dataset` object itself is [`DatasetDict`](https://huggingface.co/docs/datasets/package_reference/main_classes.html#datasetdict), which contains one key for the training, validation and test set."
]
},
{
@@ -681,12 +681,12 @@
"source": [
"print(\n",
" \"Total # of rows in training dataset {} and size {:5.2f} MB\".format(\n",
" datasets[\"train\"].shape[0], datasets[\"train\"].size_in_bytes / (1024 * 1024)\n",
" dataset[\"train\"].shape[0], dataset[\"train\"].size_in_bytes / (1024 * 1024)\n",
" )\n",
")\n",
"print(\n",
" \"Total # of rows in test dataset {} and size {:5.2f} MB\".format(\n",
" datasets[\"test\"].shape[0], datasets[\"test\"].size_in_bytes / (1024 * 1024)\n",
" dataset[\"test\"].shape[0], dataset[\"test\"].size_in_bytes / (1024 * 1024)\n",
" )\n",
")"
]
@@ -708,7 +708,7 @@
},
"outputs": [],
"source": [
"datasets[\"train\"][0]"
"dataset[\"train\"][0]"
]
},
{
@@ -728,7 +728,7 @@
},
"outputs": [],
"source": [
"label_list = datasets[\"train\"].unique(\"label\")\n",
"label_list = dataset[\"train\"].unique(\"label\")\n",
"label_list"
]
},
@@ -779,7 +779,7 @@
},
"outputs": [],
"source": [
"show_random_elements(datasets[\"train\"])"
"show_random_elements(dataset[\"train\"])"
]
},
{
@@ -883,7 +883,7 @@
},
"outputs": [],
"source": [
"example = datasets[\"train\"][4]\n",
"example = dataset[\"train\"][4]\n",
"print(example)"
]
},
@@ -920,7 +920,7 @@
"source": [
"# Dataset loading repeated here to make this cell idempotent\n",
"# Since we are over-writing datasets variable\n",
"datasets = load_dataset(\"imdb\")\n",
"dataset = load_dataset(\"imdb\")\n",
"\n",
"# Mapping labels to ids\n",
"# NOTE: We can extract this automatically but the `Unique` method of the datasets\n",
@@ -948,7 +948,7 @@
"\n",
"\n",
"# apply preprocessing function to input examples\n",
"datasets = datasets.map(preprocess_function, batched=True, load_from_cache_file=True)"
"dataset = dataset.map(preprocess_function, batched=True, load_from_cache_file=True)"
]
},
{
@@ -1091,8 +1091,8 @@
"trainer = Trainer(\n",
" model,\n",
" args,\n",
" train_dataset=datasets[\"train\"],\n",
" eval_dataset=datasets[\"test\"],\n",
" train_dataset=dataset[\"train\"],\n",
" eval_dataset=dataset[\"test\"],\n",
" data_collator=default_data_collator,\n",
" tokenizer=tokenizer,\n",
" compute_metrics=compute_metrics,\n",
+8 -2
View File
@@ -7,7 +7,7 @@
/gapic @andrewferlitsch
/gapic/custom/showcase_custom_image_classification_online_explain_example_based_api.ipynb @inardini
/ml_ops @andrewferlitsch
/model_monitoring/* @mco-gh
/model_monitoring/* @andrewferlitsch
/structured_data/rapid_prototyping_* @rafael-carvalho
/managed_notebooks/
@@ -17,6 +17,7 @@
/explainable_ai/SDK_Custom_Container_XAI.ipynb @brianchunkang
/matching_engine/sdk_matching_engine_for_indexing.ipynb @ivanmkc
/matching_engine/matching_engine_for_indexing.ipynb @yinghsienwu
/matching_engine/stream_update_for_matching_engine.ipynb @peterping666
/sdk/pytorch_lightning_custom_container_training.ipynb @brianchunkang
/tensorboard @yfang1
/feature_store @nayaknishant @morgandu
@@ -27,4 +28,9 @@
/notebooks/community/ml_ops/stage2/get_started_with_visionapi_and_automl.ipynb @mansari
/notebooks/community/neo4j/graph_paysim.ipynb @benofben @laeg
/notebooks/community/ml_ops/stage1/get_started_with_visionapi_and_vertex_datasets.ipynb @mansari
/notebooks/community/pipelines/google_cloud_pipeline_components_bqml_pipeline_demand_forecasting.ipynb @inardini
/notebooks/community/pipelines/google_cloud_pipeline_components_bqml_pipeline_demand_forecasting.ipynb @inardini
/notebooks/community/ml_ops/stage2/get_started_vertex_hpt_r_kernel.ipynb @fhirschmann
/notebooks/community/ml_ops/stage2/get_started_vertex_training_r_using_r_kernel.ipynb @fhirschmann
/notebooks/community/vertex-ai-samples/notebooks/community/model_registry/vertex_ai_model_registry_bqml_custom_model_versioning.ipynb @inardini
/notebooks/community/vertex-ai-samples/notebooks/community/model_registry/vertex_ai_model_registry_automl_model_versioning.ipynb @inardini
/notebooks/community/vizier/conversions_vertex_vizier_and_open_source_vizier.ipynb @halio-g
@@ -292,6 +292,37 @@
" PROJECT_ID = \"python-docs-samples-tests\" # @param {type:\"string\"}"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "d9f118b92c74"
},
"source": [
"#### UUID\n",
"\n",
"If you are in a live tutorial session, you might be using a shared test account or project. To avoid name collisions between users on resources created, you create a uuid for each instance session, and append it onto the name of resources you create in this tutorial."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "3ee72715c0fd"
},
"outputs": [],
"source": [
"import random\n",
"import string\n",
"\n",
"\n",
"# Generate a uuid of a specifed length(default=8)\n",
"def generate_uuid(length: int = 8) -> str:\n",
" return \"\".join(random.choices(string.ascii_lowercase + string.digits, k=length))\n",
"\n",
"\n",
"UUID = generate_uuid()"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -478,7 +509,6 @@
"from google.cloud.aiplatform_v1.types import \\\n",
" featurestore_service as featurestore_service_pb2\n",
"from google.cloud.aiplatform_v1.types import io as io_pb2\n",
"from google.protobuf.duration_pb2 import Duration\n",
"\n",
"# Create admin_client for CRUD and data_client for reading feature values.\n",
"admin_client = FeaturestoreServiceClient(client_options={\"api_endpoint\": API_ENDPOINT})\n",
@@ -542,7 +572,7 @@
},
"outputs": [],
"source": [
"FEATURESTORE_ID = \"movie_prediction\"\n",
"FEATURESTORE_ID = f\"movie_prediction_{UUID}\"\n",
"try:\n",
" create_lro = admin_client.create_featurestore(\n",
" featurestore_service_pb2.CreateFeaturestoreRequest(\n",
@@ -567,7 +597,7 @@
"id": "ag8pCQ7rNjVf"
},
"source": [
"You can use [GetFeaturestore](https://cloud.google.com/vertex-ai/docs/reference/rpc/google.cloud.aiplatform.v1beta1#google.cloud.aiplatform.v1beta1.FeaturestoreService.GetFeaturestore) or [ListFeaturestores](https://cloud.google.com/vertex-ai/docs/reference/rpc/google.cloud.aiplatform.v1beta1#google.cloud.aiplatform.v1beta1.FeaturestoreService.ListFeaturestores) to check if the Featurestore was successfully created. The following example gets the details of the Featurestore.\n"
"You can use [GetFeaturestore](https://cloud.google.com/vertex-ai/docs/reference/rpc/google.cloud.aiplatform.v1#google.cloud.aiplatform.v1.FeaturestoreService.GetFeaturestore) or [ListFeaturestores](https://cloud.google.com/vertex-ai/docs/reference/rpc/google.cloud.aiplatform.v1#google.cloud.aiplatform.v1.FeaturestoreService.ListFeaturestores) to check if the Featurestore was successfully created. The following example gets the details of the Featurestore.\n"
]
},
{
@@ -589,7 +619,7 @@
"id": "018ab19d934f"
},
"source": [
"Auto scaling is available in v1beta1 since v1.11. Below is the example for the `CreateFeaturestoreRequest` with auto-scaling, use it with `aiplatform_v1beta1.FeaturestoreServiceClient` to create Featurestore:"
"Auto scaling is available in v1 since v1.11. Below is the example for the `CreateFeaturestoreRequest` with auto-scaling, use it with `aiplatform_v1.FeaturestoreServiceClient` to create Featurestore:"
]
},
{
@@ -600,17 +630,17 @@
},
"outputs": [],
"source": [
"from google.cloud.aiplatform_v1beta1.types import \\\n",
" featurestore as v1beta1_featurestore_pb2\n",
"from google.cloud.aiplatform_v1beta1.types import \\\n",
" featurestore_service as v1beta1_featurestore_service_pb2\n",
"from google.cloud.aiplatform_v1.types import \\\n",
" featurestore as v1_featurestore_pb2\n",
"from google.cloud.aiplatform_v1.types import \\\n",
" featurestore_service as v1_featurestore_service_pb2\n",
"\n",
"create_featurestore_request = v1beta1_featurestore_service_pb2.CreateFeaturestoreRequest(\n",
"create_featurestore_request = v1_featurestore_service_pb2.CreateFeaturestoreRequest(\n",
" parent=BASE_RESOURCE_PATH,\n",
" featurestore_id=FEATURESTORE_ID,\n",
" featurestore=v1beta1_featurestore_pb2.Featurestore(\n",
" online_serving_config=v1beta1_featurestore_pb2.Featurestore.OnlineServingConfig(\n",
" scaling=v1beta1_featurestore_pb2.Featurestore.OnlineServingConfig.Scaling(\n",
" featurestore=v1_featurestore_pb2.Featurestore(\n",
" online_serving_config=v1_featurestore_pb2.Featurestore.OnlineServingConfig(\n",
" scaling=v1_featurestore_pb2.Featurestore.OnlineServingConfig.Scaling(\n",
" min_node_count=1, max_node_count=5\n",
" )\n",
" ),\n",
@@ -681,7 +711,7 @@
"id": "dPkT7KDuEvWv"
},
"source": [
"Feature [monitoring](https://cloud.google.com/vertex-ai/docs/featurestore/monitoring) is in preview, so you need to use v1beta1 Python. Import feature analysis is only available through SDK for now."
"Feature [monitoring](https://cloud.google.com/vertex-ai/docs/featurestore/monitoring) is in preview, so you need to use v1 Python. Import feature analysis is only available through SDK for now."
]
},
{
@@ -692,36 +722,35 @@
},
"outputs": [],
"source": [
"from google.cloud.aiplatform_v1beta1 import \\\n",
" FeaturestoreServiceClient as v1beta1_FeaturestoreServiceClient\n",
"from google.cloud.aiplatform_v1beta1.types import \\\n",
" entity_type as v1beta1_entity_type_pb2\n",
"from google.cloud.aiplatform_v1beta1.types import \\\n",
" featurestore_monitoring as v1beta1_featurestore_monitoring_pb2\n",
"from google.cloud.aiplatform_v1beta1.types import \\\n",
" featurestore_service as v1beta1_featurestore_service_pb2\n",
"from google.cloud.aiplatform_v1 import \\\n",
" FeaturestoreServiceClient as v1_FeaturestoreServiceClient\n",
"from google.cloud.aiplatform_v1.types import entity_type as v1_entity_type_pb2\n",
"from google.cloud.aiplatform_v1.types import \\\n",
" featurestore_monitoring as v1_featurestore_monitoring_pb2\n",
"from google.cloud.aiplatform_v1.types import \\\n",
" featurestore_service as v1_featurestore_service_pb2\n",
"\n",
"v1beta1_admin_client = v1beta1_FeaturestoreServiceClient(\n",
"v1_admin_client = v1_FeaturestoreServiceClient(\n",
" client_options={\"api_endpoint\": API_ENDPOINT}\n",
")\n",
"\n",
"# Enable import feature analysis for users entity type.\n",
"# All Features belonging to this EntityType will by default inherit the monitoring config.\n",
"v1beta1_admin_client.update_entity_type(\n",
" v1beta1_featurestore_service_pb2.UpdateEntityTypeRequest(\n",
" entity_type=v1beta1_entity_type_pb2.EntityType(\n",
"v1_admin_client.update_entity_type(\n",
" v1_featurestore_service_pb2.UpdateEntityTypeRequest(\n",
" entity_type=v1_entity_type_pb2.EntityType(\n",
" name=admin_client.entity_type_path(\n",
" PROJECT_ID, REGION, FEATURESTORE_ID, \"users\"\n",
" ),\n",
" monitoring_config=v1beta1_featurestore_monitoring_pb2.FeaturestoreMonitoringConfig(\n",
" import_features_analysis=v1beta1_featurestore_monitoring_pb2.FeaturestoreMonitoringConfig.ImportFeaturesAnalysis(\n",
" anomaly_detection_baseline=v1beta1_featurestore_monitoring_pb2.FeaturestoreMonitoringConfig.ImportFeaturesAnalysis.Baseline.LATEST_STATS,\n",
" state=v1beta1_featurestore_monitoring_pb2.FeaturestoreMonitoringConfig.ImportFeaturesAnalysis.State.ENABLED,\n",
" monitoring_config=v1_featurestore_monitoring_pb2.FeaturestoreMonitoringConfig(\n",
" import_features_analysis=v1_featurestore_monitoring_pb2.FeaturestoreMonitoringConfig.ImportFeaturesAnalysis(\n",
" anomaly_detection_baseline=v1_featurestore_monitoring_pb2.FeaturestoreMonitoringConfig.ImportFeaturesAnalysis.Baseline.LATEST_STATS,\n",
" state=v1_featurestore_monitoring_pb2.FeaturestoreMonitoringConfig.ImportFeaturesAnalysis.State.ENABLED,\n",
" ),\n",
" numerical_threshold_config=v1beta1_featurestore_monitoring_pb2.FeaturestoreMonitoringConfig.ThresholdConfig(\n",
" numerical_threshold_config=v1_featurestore_monitoring_pb2.FeaturestoreMonitoringConfig.ThresholdConfig(\n",
" value=0.001,\n",
" ),\n",
" categorical_threshold_config=v1beta1_featurestore_monitoring_pb2.FeaturestoreMonitoringConfig.ThresholdConfig(\n",
" categorical_threshold_config=v1_featurestore_monitoring_pb2.FeaturestoreMonitoringConfig.ThresholdConfig(\n",
" value=0.001,\n",
" ),\n",
" ),\n",
@@ -736,7 +765,7 @@
"id": "85b1f59fbf6d"
},
"source": [
"The easiest way to set up snapshot analysis for now is using [console UI](https://console.cloud.google.com/vertex-ai/features). For completeness, below is example to do this using v1beta1 SDK.\n",
"The easiest way to set up snapshot analysis for now is using [console UI](https://console.cloud.google.com/vertex-ai/features). For completeness, below is example to do this using v1 SDK.\n",
"\n",
"You can view monitoring statistics on [console UI](https://console.cloud.google.com/vertex-ai/features)."
]
@@ -749,36 +778,35 @@
},
"outputs": [],
"source": [
"from google.cloud.aiplatform_v1beta1 import \\\n",
" FeaturestoreServiceClient as v1beta1_FeaturestoreServiceClient\n",
"from google.cloud.aiplatform_v1beta1.types import \\\n",
" entity_type as v1beta1_entity_type_pb2\n",
"from google.cloud.aiplatform_v1beta1.types import \\\n",
" featurestore_monitoring as v1beta1_featurestore_monitoring_pb2\n",
"from google.cloud.aiplatform_v1beta1.types import \\\n",
" featurestore_service as v1beta1_featurestore_service_pb2\n",
"from google.cloud.aiplatform_v1 import \\\n",
" FeaturestoreServiceClient as v1_FeaturestoreServiceClient\n",
"from google.cloud.aiplatform_v1.types import entity_type as v1_entity_type_pb2\n",
"from google.cloud.aiplatform_v1.types import \\\n",
" featurestore_monitoring as v1_featurestore_monitoring_pb2\n",
"from google.cloud.aiplatform_v1.types import \\\n",
" featurestore_service as v1_featurestore_service_pb2\n",
"\n",
"v1beta1_admin_client = v1beta1_FeaturestoreServiceClient(\n",
"v1_admin_client = v1_FeaturestoreServiceClient(\n",
" client_options={\"api_endpoint\": API_ENDPOINT}\n",
")\n",
"\n",
"# Enable snapshot analysis for users entity type.\n",
"# All Features belonging to this EntityType will by default inherit the monitoring config.\n",
"v1beta1_admin_client.update_entity_type(\n",
" v1beta1_featurestore_service_pb2.UpdateEntityTypeRequest(\n",
" entity_type=v1beta1_entity_type_pb2.EntityType(\n",
"v1_admin_client.update_entity_type(\n",
" v1_featurestore_service_pb2.UpdateEntityTypeRequest(\n",
" entity_type=v1_entity_type_pb2.EntityType(\n",
" name=admin_client.entity_type_path(\n",
" PROJECT_ID, REGION, FEATURESTORE_ID, \"users\"\n",
" ),\n",
" monitoring_config=v1beta1_featurestore_monitoring_pb2.FeaturestoreMonitoringConfig(\n",
" snapshot_analysis=v1beta1_featurestore_monitoring_pb2.FeaturestoreMonitoringConfig.SnapshotAnalysis(\n",
" monitoring_interval=Duration(seconds=86400), # 1 day\n",
" monitoring_config=v1_featurestore_monitoring_pb2.FeaturestoreMonitoringConfig(\n",
" snapshot_analysis=v1_featurestore_monitoring_pb2.FeaturestoreMonitoringConfig.SnapshotAnalysis(\n",
" monitoring_interval_days=1, # 1 day\n",
" staleness_days=30,\n",
" ),\n",
" numerical_threshold_config=v1beta1_featurestore_monitoring_pb2.FeaturestoreMonitoringConfig.ThresholdConfig(\n",
" numerical_threshold_config=v1_featurestore_monitoring_pb2.FeaturestoreMonitoringConfig.ThresholdConfig(\n",
" value=0.001,\n",
" ),\n",
" categorical_threshold_config=v1beta1_featurestore_monitoring_pb2.FeaturestoreMonitoringConfig.ThresholdConfig(\n",
" categorical_threshold_config=v1_featurestore_monitoring_pb2.FeaturestoreMonitoringConfig.ThresholdConfig(\n",
" value=0.001,\n",
" ),\n",
" ),\n",
@@ -891,8 +919,8 @@
"source": [
"## Search created features\n",
"\n",
"While the [ListFeatures](https://cloud.google.com/vertex-ai/docs/reference/rpc/google.cloud.aiplatform.v1beta1#google.cloud.aiplatform.v1beta1.FeaturestoreService.ListFeatures) method allows you to easily view all features of a single\n",
"entity type, the [SearchFeatures](https://cloud.google.com/vertex-ai/docs/reference/rpc/google.cloud.aiplatform.v1beta1#google.cloud.aiplatform.v1beta1.FeaturestoreService.SearchFeatures) method searches across all featurestores\n",
"While the [ListFeatures](https://cloud.google.com/vertex-ai/docs/reference/rpc/google.cloud.aiplatform.v1#google.cloud.aiplatform.v1.FeaturestoreService.ListFeatures) method allows you to easily view all features of a single\n",
"entity type, the [SearchFeatures](https://cloud.google.com/vertex-ai/docs/reference/rpc/google.cloud.aiplatform.v1#google.cloud.aiplatform.v1.FeaturestoreService.SearchFeatures) method searches across all featurestores\n",
"and entity types in a given location (such as `us-central1`). This can help you discover features that were created by someone else.\n",
"\n",
"You can query based on feature properties including feature ID, entity type ID,\n",
@@ -1206,7 +1234,7 @@
},
"source": [
"The\n",
"[Online Serving APIs](https://cloud.google.com/vertex-ai/docs/reference/rpc/google.cloud.aiplatform.v1beta1#featurestoreonlineservingservice)\n",
"[Online Serving APIs](https://cloud.google.com/vertex-ai/docs/reference/rpc/google.cloud.aiplatform.v1#featurestoreonlineservingservice)\n",
"lets you serve feature values for small batches of entities. It's designed for latency-sensitive service, such as online model prediction. For example, for a movie service, you might want to quickly shows movies that the current user would most likely watch by using online predictions."
]
},
File diff suppressed because it is too large Load Diff
+1 -1
View File
@@ -14,5 +14,5 @@ The purpose of this set of notebooks and markdown files is to demonstrate Google
4. [Evaluation](stage4)
5. [Deployment](stage5)
6. [Serving](stage6)
7. Monitoring
7. Monitoring(stage7)
8. Continuous Training
+43
View File
@@ -0,0 +1,43 @@
## Before you begin
### Set up your Google Cloud project
**The following steps are required, regardless of your notebook environment.**
1. [Select or create a Google Cloud project](https://console.cloud.google.com/cloud-resource-manager). When you first create an account, you get a $300 free credit towards your compute/storage costs.
1. [Make sure that billing is enabled for your project](https://cloud.google.com/billing/docs/how-to/modify-project).
1. [Enable the Vertex AI, BigQuery, Compute Engine and Cloud Storage APIs](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com,bigquery,compute_component,storage_component).
1. If you are running this notebook locally, you need to install the [Cloud SDK](https://cloud.google.com/sdk).
1. Enter your project ID in the cell below. Then run the cell to make sure the
Cloud SDK uses the right project for all the commands in this notebook.
**Note**: Jupyter runs lines prefixed with `!` as shell commands, and it interpolates Python variables prefixed with `$` into these commands.
### Set up your local development environment
**If you are using Colab or Vertex AI Workbench Notebooks**, your environment already meets all the requirements to run this notebook. You can skip this step.
**Otherwise**, make sure your environment meets this notebook's requirements. You need the following:
- The Cloud Storage SDK
- Python 3
- virtualenv
- Jupyter notebook running in a virtual environment with Python 3
The Cloud Storage guide to [Setting up a Python development environment](https://cloud.google.com/python/setup) and the [Jupyter installation guide](https://jupyter.org/install) provide detailed instructions for meeting these requirements. The following steps provide a condensed set of instructions:
1. [Install and initialize the SDK](https://cloud.google.com/sdk/docs/).
2. [Install Python 3](https://cloud.google.com/python/setup#installing_python).
3. [Install virtualenv](https://cloud.google.com/python/setup#installing_and_using_virtualenv) and create a virtual environment that uses Python 3. Activate the virtual environment.
4. To install Jupyter, run `pip3 install jupyter` on the command-line in a terminal shell.
5. To launch Jupyter, run `jupyter notebook` on the command-line in a terminal shell.
6. Open this notebook in the Jupyter Notebook Dashboard.
+112
View File
@@ -0,0 +1,112 @@
import os
import sys
import argparse
import subprocess
import random
import string
parser = argparse.ArgumentParser()
parser.add_argument('--bucket', dest='bucket_required', action='store_true',
default=False, help='Bucket required')
parser.add_argument('--email', dest='email_required', action='store_true',
default=False, help='Email required')
parser.add_argument('--sa', dest='sa_required', action='store_true',
default=False, help='Service account required')
parser.add_argument('--packages', dest='extra_packages',
default='', type=str, help='additional required packages')
args = parser.parse_args()
extra_pkgs = args.extra_packages
# Installation
# The Vertex AI Workbench Notebook product has specific requirements
IS_WORKBENCH_NOTEBOOK = os.getenv("DL_ANACONDA_HOME")
IS_USER_MANAGED_WORKBENCH_NOTEBOOK = os.path.exists(
"/opt/deeplearning/metadata/env_version"
)
IS_COLAB = "google.colab" in sys.modules
# Vertex AI Notebook requires dependencies to be installed with '--user'
USER_FLAG = ""
if IS_WORKBENCH_NOTEBOOK:
USER_FLAG = "--user"
# not used
'''
print("Installing packages")
os.system(f"pip3 install --upgrade --quiet {USER_FLAG} google-cloud-aiplatform {args.extra_packages}")
print("Done installation")
'''
# Authenticate
if IS_COLAB:
from google.colab import auth as google_auth
google_auth.authenticate_user()
# project ID
if IS_WORKBENCH_NOTEBOOK:
shell_output = subprocess.check_output("gcloud config list --format 'value(core.project)' 2>/dev/null", shell=True)
PROJECT_ID = shell_output[0:-1].decode('utf-8')
print("PROJECT ID: ", PROJECT_ID)
else:
PROJECT_ID = input("Enter PROJECT_ID: ")
os.system(f"gcloud config set project {PROJECT_ID}")
# email
if args.email_required:
shell_output = subprocess.check_output("gcloud config list --format 'value(core.account)' 2>/dev/null", shell=True)
EMAIL_ADDR = shell_output[0:-1].decode('utf-8')
if EMAIL_ADDR == '':
EMAIL_ADDR = input("Enter Email Address: ")
print("EMAIL_ADDR: ", EMAIL_ADDR)
# region
shell_output = subprocess.check_output("gcloud config list --format 'value(ai.region)'", shell=True)
REGION = shell_output[0:-1].decode('utf-8')
if REGION == '':
REGION = input("Enter REGION: ")
print("REGION: ", REGION)
# multi-region
MULTI_REGION = REGION.split('-')[0]
# UUID
# Generate a uuid of a specifed length(default=8)
def generate_uuid(length: int = 8) -> str:
return "".join(random.choices(string.ascii_lowercase + string.digits, k=length))
UUID = generate_uuid()
print("UUID", UUID)
# Bucket
if args.bucket_required:
BUCKET_NAME = PROJECT_ID + "aip-" + UUID
BUCKET_URI = f"gs://{BUCKET_NAME}"
os.system(f"gsutil mb -l {REGION} {BUCKET_URI}")
print("BUCKET_URI", BUCKET_URI)
# Project Number
if args.sa_required:
if IS_WORKBENCH_NOTEBOOK:
shell_output = subprocess.check_output("gcloud auth list 2>/dev/null", shell=True)
SERVICE_ACCOUNT = shell_output[:-1].decode('utf-8').split('\n')[2].strip()
PROJECT_NUMBER = SERVICE_ACCOUNT.split('-')[0]
else:
shell_output = subprocess.check_output(f"gcloud projects describe {PROJECT_ID}", shell=True)
try:
PROJECT_NUMBER = shell_output[:-1].decode('utf-8').split('\n')[7].split(':')[-1].strip().replace("'", "")
SERVICE_ACCOUNT = f"{PROJECT_NUMBER}-compute@developer.gserviceaccount.com"
except:
PROJECT_NUMBER = input("Enter project number: ")
SERVICE_ACCOUNT = f"{PROJECT_NUMBER}-compute@developer.gserviceaccount.com"
print("SERVICE_ACCOUNT", SERVICE_ACCOUNT)
print("PROJECT_NUMBER", PROJECT_NUMBER)
+42 -33
View File
@@ -28,50 +28,46 @@ The first stage in MLOps is the collection and preparation for the purpose of de
### Get Started
[Get started with Vertex AI datasets](get_started_vertex_datasets.ipynb)
[Get started with Dataflow](community/ml_ops/stage1/get_started_dataflow.ipynb)
In this tutorial, you learn how to use `Dataflow` for training with `Vertex AI`.
```
The steps performed include:
- Create a Vertex AI `Dataset` resource for:
- image data
- text data
- video data
- tabular data
- forecasting data
- Search `Dataset` resources using a filter.
- Read a sample of a `BigQuery` dataset into a dataframe.
- Generate statistics and data schema using TensorFlow Data Validation from the samples in the dataframe.
- Detect anomalies in new data using TensorFlow Data Validation.
- Generate a TFRecord feature specification using TensorFlow Transform from the data schema.
- Export a dataset and convert to TFRecords.
```
[Get started with Dataflow](get_started_dataflow.ipynb)
```
The steps performed include:
- Offline preprocessing of data:
- Serially - w/o dataflow
- Parallel - with dataflow
- Upstream preprocessing of data:
- tabular data
- image data
```
[Create an unlabelled Vertex AI AutoML text entity extraction dataset from pdfs using Vision API](get_started_with_visionapi_and_vertex_datasets.ipynb)
[Get started with Vertex AI datasets](community/ml_ops/stage1/get_started_vertex_datasets.ipynb)
In this tutorial, you learn how to use `Vertex AI Dataset` for training with `Vertex AI`.
```
The steps performed include:
1. Using `Vision API` to perform Optical Character Recognition (OCR) to extract text from PDF files.
2. Processing the results and saving them to text files.
3. Generating a `Vertex AI Dataset` import file.
4. Creating a new unlabelled text entity extraction `Vertex AI Dataset` resource in `Vertex AI`.
```
[Get started with BigQuery datasets](get_started_bq_datasets.ipynb)
- Create a Vertex AI `Dataset` resource for:
- image data
- text data
- video data
- tabular data
- forecasting data
- Search `Dataset` resources using a filter.
- Read a sample of a `BigQuery` dataset into a dataframe.
- Generate statistics and data schema using TensorFlow Data Validation from the samples in the dataframe.
- Detect anomalies in new data using TensorFlow Data Validation.
- Generate a TFRecord feature specification using TensorFlow Transform from the data schema.
- Export a dataset and convert to TFRecords.
[Get started with BigQuery datasets](community/ml_ops/stage1/get_started_bq_datasets.ipynb)
In this tutorial, you learn how to use `BigQuery` as a dataset for training with `Vertex AI`.
```
The steps performed include:
- Create a Vertex AI `Dataset` resource from `BigQuery` table -- compatible for `AutoML` training.
- Extract a copy of the dataset from `BigQuery` to a CSV file in Cloud Storage -- compatible for `AutoML` or custom training.
- Select rows from a `BigQuery` dataset into a `pandas` dataframe -- compatible for custom training.
@@ -79,19 +75,32 @@ The steps performed include:
- Select rows from extracted CSV files into a `tf.data.Dataset` -- compatible for custom training `TensorFlow` models.
- Create a `BigQuery` dataset from CSV files.
- Extract data from `BigQuery` table into a `DMatrix` -- compatible for custom training `XGBoost` models.
```
[Get started with Vertex AI data labeling](get_started_with_data_labeling.ipynb)
[Get started with Vertex AI Data Labeling](community/ml_ops/stage1/get_started_with_data_labeling.ipynb)
In this tutorial, you learn how to use the `Vertex AI Data Labeling` service.
```
The steps performed include:
- Create a Specialist Pool for data labelers.
- Create a data labeling job.
- Submit the data labeling job.
- List data labeling jobs.
- Cancel a data labeling job.
```
[Create an unlabelled Vertex AI AutoML text entity extraction dataset from PDFs using Vision API](community/ml_ops/stage1/get_started_with_visionapi_and_vertex_datasets.ipynb)
In this tutorial, you learn to use `Vision API` to extract text from PDF files stored on a Cloud Storage bucket. You then process the results and create an unlabelled `Vertex AI Dataset`, compatible with `AutoML`, for text entity extraction.
The steps performed include:
1. Using `Vision API` to perform Optical Character Recognition (OCR) to extract text from PDF files.
2. Processing the results and saving them to text files.
3. Generating a `Vertex AI Dataset` import file.
4. Creating a new unlabelled text entity extraction `Vertex AI Dataset` resource in `Vertex AI`.
### E2E Stage Example
@@ -120,7 +120,7 @@
" - XGBoost model training:\n",
" - Use BigQuery ML built-in XGBoost training.\n",
" - Alternatively, create a DMatrix generator from CSV files extracted from BigQuery table.\n",
" - Pytorch model training:\n",
" - PyTorch model training:\n",
" - Extract the BigQuery to a pandas dataframe.\n",
" - Preprocess the data in the dataframe.\n",
" - Create a DataLoader generator from the pandas dataframe.\n",
@@ -191,13 +191,8 @@
"if IS_WORKBENCH_NOTEBOOK:\n",
" USER_FLAG = \"--user\"\n",
"\n",
"# Install the packages\n",
"! pip3 install --upgrade pyarrow $USER_FLAG -q\n",
"! pip3 install --upgrade google-cloud-bigquery $USER_FLAG -q\n",
"! pip3 install --upgrade google-cloud-aiplatform $USER_FLAG -q\n",
"! pip3 install -U xgboost $USER_FLAG -q\n",
"! pip3 install -U tensorflow $USER_FLAG -q\n",
"! pip3 install -U tensorflow-io==0.18 $USER_FLAG -q"
"extra_pkgs = \"tensorflow tensorflow-io==0.18 pyarrow xgboost google-cloud-bigquery\"\n",
"! pip3 install --upgrade --quiet {USER_FLAG} google-cloud-aiplatform $extra_pkgs"
]
},
{
@@ -219,9 +214,9 @@
},
"outputs": [],
"source": [
"import os\n",
"import sys\n",
"\n",
"if not os.getenv(\"IS_TESTING\"):\n",
"if \"google.colab\" in sys.modules:\n",
" # Automatically restart kernel after installs\n",
" import IPython\n",
"\n",
@@ -232,274 +227,42 @@
{
"cell_type": "markdown",
"metadata": {
"id": "84cd83853240"
"id": "fc8fb52b5cca"
},
"source": [
"## Before you begin\n",
"### Common setup\n",
"\n",
"### Set up your Google Cloud project\n",
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"1. [Select or create a Google Cloud project](https://console.cloud.google.com/cloud-resource-manager). When you first create an account, you get a $300 free credit towards your compute/storage costs.\n",
"\n",
"1. [Make sure that billing is enabled for your project](https://cloud.google.com/billing/docs/how-to/modify-project).\n",
"\n",
"1. [Enable the Vertex AI, BigQuery, Compute Engine and Cloud Storage APIs](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com,bigquery,compute_component,storage_component).\n",
"\n",
"1. If you are running this notebook locally, you need to install the [Cloud SDK](https://cloud.google.com/sdk).\n",
"\n",
"1. Enter your project ID in the cell below. Then run the cell to make sure the\n",
"Cloud SDK uses the right project for all the commands in this notebook.\n",
"\n",
"**Note**: Jupyter runs lines prefixed with `!` as shell commands, and it interpolates Python variables prefixed with `$` into these commands."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "project_id"
},
"source": [
"#### Set your project ID\n",
"\n",
"**If you don't know your project ID**, you may be able to get your project ID using `gcloud`."
"Now, execute the common setup for the notebook tutorials."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "set_project_id"
"id": "001a0fcd5d78"
},
"outputs": [],
"source": [
"PROJECT_ID = \"[your-project-id]\" # @param {type:\"string\"}"
"# Common code setup for notebook tutorials\n",
"\n",
"! wget https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/setup.py -O setup.py\n",
"\n",
"%run setup.py --bucket"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "autoset_project_id"
"id": "d809f07a8935"
},
"outputs": [],
"source": [
"if PROJECT_ID == \"\" or PROJECT_ID is None or PROJECT_ID == \"[your-project-id]\":\n",
" # Get your GCP project id from gcloud\n",
" shell_output = ! gcloud config list --format 'value(core.project)' 2>/dev/null\n",
" PROJECT_ID = shell_output[0]\n",
" print(\"Project ID:\", PROJECT_ID)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "set_gcloud_project_id"
},
"outputs": [],
"source": [
"! gcloud config set project $PROJECT_ID"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "region"
},
"source": [
"#### Region\n",
"# Other Common setup instructions for notebook tutorials\n",
"\n",
"You can also change the `REGION` variable, which is used for operations\n",
"throughout the rest of this notebook. Below are regions supported for Vertex AI. We recommend that you choose the region closest to you.\n",
"! wget https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/setup.md -O setup.md\n",
"\n",
"- Americas: `us-central1`\n",
"- Europe: `europe-west4`\n",
"- Asia Pacific: `asia-east1`\n",
"\n",
"You may not use a multi-regional bucket for training with Vertex AI. Not all regions provide support for all Vertex AI services.\n",
"\n",
"Learn more about [Vertex AI regions](https://cloud.google.com/vertex-ai/docs/general/locations)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "region"
},
"outputs": [],
"source": [
"REGION = \"[your-region]\" # @param {type: \"string\"}\n",
"\n",
"if REGION == \"[your-region]\":\n",
" REGION = \"us-central1\""
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "timestamp"
},
"source": [
"#### Timestamp\n",
"\n",
"If you are in a live tutorial session, you might be using a shared test account or project. To avoid name collisions between users on resources created, you create a timestamp for each instance session, and append the timestamp onto the name of resources you create in this tutorial."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "timestamp"
},
"outputs": [],
"source": [
"from datetime import datetime\n",
"\n",
"TIMESTAMP = datetime.now().strftime(\"%Y%m%d%H%M%S\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "77c385f0db59"
},
"source": [
"### Authenticate your Google Cloud account\n",
"\n",
"**If you are using Vertex AI Workbench Notebooks**, your environment is already authenticated. Skip this step.\n",
"\n",
"**If you are using Colab**, run the cell below and follow the instructions when prompted to authenticate your account via oAuth.\n",
"\n",
"**Otherwise**, follow these steps:\n",
"\n",
"In the Cloud Console, go to the [Create service account key](https://console.cloud.google.com/apis/credentials/serviceaccountkey) page.\n",
"\n",
"1. **Click Create service account**.\n",
"\n",
"2. In the **Service account name** field, enter a name, and click **Create**.\n",
"\n",
"3. In the **Grant this service account access to project** section, click the Role drop-down list. Type \"Vertex AI\" into the filter box, and select **Vertex AI Administrator**. Type \"Storage Object Admin\" into the filter box, and select **Storage Object Admin**.\n",
"\n",
"4. Click Create. A JSON file that contains your key downloads to your local environment.\n",
"\n",
"5. Enter the path to your service account key as the GOOGLE_APPLICATION_CREDENTIALS variable in the cell below and run the cell."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "535223fa4b84"
},
"outputs": [],
"source": [
"# If you are running this notebook in Colab, run this cell and follow the\n",
"# instructions to authenticate your GCP account. This provides access to your\n",
"# Cloud Storage bucket and lets you submit training jobs and prediction\n",
"# requests.\n",
"\n",
"import os\n",
"import sys\n",
"\n",
"# If on Vertex AI Workbench, then don't execute this code\n",
"IS_COLAB = False\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\") and not os.getenv(\n",
" \"DL_ANACONDA_HOME\"\n",
"):\n",
" if \"google.colab\" in sys.modules:\n",
" IS_COLAB = True\n",
" from google.colab import auth as google_auth\n",
"\n",
" google_auth.authenticate_user()\n",
"\n",
" # If you are running this notebook locally, replace the string below with the\n",
" # path to your service account key and run this cell to authenticate your GCP\n",
" # account.\n",
" elif not os.getenv(\"IS_TESTING\"):\n",
" %env GOOGLE_APPLICATION_CREDENTIALS ''"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "bucket:custom"
},
"source": [
"### Create a Cloud Storage bucket\n",
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"When you create a dataset resource using the Vertex SDK, you can provide a Cloud Storage bucket that contains the data. Vertex AI creates the dataset resource from the data. In this tutorial, Vertex AI also creates a dataset resource from your data in the Cloud Storage bucket.\n",
"\n",
"Set the name of your Cloud Storage bucket below. Bucket names must be globally unique across all Google Cloud projects, including those outside of your organization."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "bucket"
},
"outputs": [],
"source": [
"BUCKET_NAME = \"[your-bucket-name]\" # @param {type:\"string\"}\n",
"BUCKET_URI = f\"gs://{BUCKET_NAME}\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "autoset_bucket"
},
"outputs": [],
"source": [
"if BUCKET_URI == \"\" or BUCKET_URI is None or BUCKET_URI == \"gs://[your-bucket-name]\":\n",
" BUCKET_NAME = PROJECT_ID + \"aip-\" + TIMESTAMP\n",
" BUCKET_URI = \"gs://\" + BUCKET_NAME"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "create_bucket"
},
"source": [
"**Only if your bucket doesn't already exist**: Run the following cell to create your Cloud Storage bucket."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "create_bucket"
},
"outputs": [],
"source": [
"! gsutil mb -l $REGION $BUCKET_URI"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "validate_bucket"
},
"source": [
"Finally, validate access to your Cloud Storage bucket by examining its contents:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "validate_bucket"
},
"outputs": [],
"source": [
"! gsutil ls -al $BUCKET_URI"
"%load setup.md"
]
},
{
@@ -620,7 +383,7 @@
"outputs": [],
"source": [
"dataset = aiplatform.TabularDataset.create(\n",
" display_name=\"NOAA historical weather data\" + \"_\" + TIMESTAMP,\n",
" display_name=\"NOAA historical weather data\" + \"_\" + UUID,\n",
" bq_source=[IMPORT_FILE],\n",
" labels={\"user_metadata\": BUCKET_URI[5:]},\n",
")\n",
@@ -695,7 +458,7 @@
"gcs_source = IMPORT_FILES\n",
"\n",
"dataset = aiplatform.TabularDataset.create(\n",
" display_name=\"NOAA historical weather data\" + \"_\" + TIMESTAMP,\n",
" display_name=\"NOAA historical weather data\" + \"_\" + UUID,\n",
" gcs_source=gcs_source,\n",
" labels={\"user_metadata\": BUCKET_URI[5:]},\n",
")\n",
@@ -737,10 +500,10 @@
" or BQ_MY_DATASET is None\n",
" or BQ_MY_DATASET == \"[your-dataset-name]\"\n",
"):\n",
" BQ_MY_DATASET = \"mlops_dataset_\" + TIMESTAMP\n",
" BQ_MY_DATASET = \"mlops_dataset_\" + UUID\n",
"\n",
"if BQ_MY_TABLE == \"\" or BQ_MY_TABLE is None or BQ_MY_TABLE == \"[your-view-name]\":\n",
" BQ_MY_TABLE = \"mlops_view_\" + TIMESTAMP"
" BQ_MY_TABLE = \"mlops_view_\" + UUID"
]
},
{
@@ -44,7 +44,7 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage1/get_started_dataflow.ipynb\">\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/stage1/get_started_dataflow.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
@@ -186,13 +186,9 @@
"if IS_WORKBENCH_NOTEBOOK:\n",
" USER_FLAG = \"--user\"\n",
"\n",
"! pip3 install -U tensorflow==2.5 $USER_FLAG -q\n",
"! pip3 install -U tensorflow-data-validation==1.2 $USER_FLAG -q\n",
"! pip3 install -U tensorflow-transform==1.2 $USER_FLAG -q\n",
"! pip3 install -U tensorflow-io==0.18 $USER_FLAG -q\n",
"! pip3 install --upgrade google-cloud-aiplatform $USER_FLAG -q\n",
"! pip3 install --upgrade google-cloud-bigquery $USER_FLAG -q\n",
"! pip3 install --upgrade apache-beam[gcp] $USER_FLAG -q"
"extra_pkgs = \"tensorflow==2.5 tensorflow-data-validation==1.2 tensorflow-transform==1.2 \\\n",
" tensorflow-io==0.18 pyarrow pandas apache-beam[gcp] google-cloud-bigquery\"\n",
"! pip3 install --upgrade --quiet {USER_FLAG} google-cloud-aiplatform $extra_pkgs"
]
},
{
@@ -214,9 +210,9 @@
},
"outputs": [],
"source": [
"import os\n",
"import sys\n",
"\n",
"if not os.getenv(\"IS_TESTING\"):\n",
"if \"google.colab\" in sys.modules:\n",
" # Automatically restart kernel after installs\n",
" import IPython\n",
"\n",
@@ -227,279 +223,42 @@
{
"cell_type": "markdown",
"metadata": {
"id": "84cd83853240"
"id": "fc8fb52b5cca"
},
"source": [
"## Before you begin\n",
"### Common setup\n",
"\n",
"### Set up your Google Cloud project\n",
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"1. [Select or create a Google Cloud project](https://console.cloud.google.com/cloud-resource-manager). When you first create an account, you get a $300 free credit towards your compute/storage costs.\n",
"\n",
"1. [Make sure that billing is enabled for your project](https://cloud.google.com/billing/docs/how-to/modify-project).\n",
"\n",
"1. [Enable the Vertex AI, BigQuery, Compute Engine and Cloud Storage APIs](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com,bigquery,compute_component,storage_component).\n",
"\n",
"1. If you are running this notebook locally, you need to install the [Cloud SDK](https://cloud.google.com/sdk).\n",
"\n",
"1. Enter your project ID in the cell below. Then run the cell to make sure the\n",
"Cloud SDK uses the right project for all the commands in this notebook.\n",
"\n",
"**Note**: Jupyter runs lines prefixed with `!` as shell commands, and it interpolates Python variables prefixed with `$` into these commands."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "project_id"
},
"source": [
"#### Set your project ID\n",
"\n",
"**If you don't know your project ID**, you may be able to get your project ID using `gcloud`."
"Now, execute the common setup for the notebook tutorials."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "set_project_id"
"id": "001a0fcd5d78"
},
"outputs": [],
"source": [
"PROJECT_ID = \"[your-project-id]\" # @param {type:\"string\"}"
"# Common code setup for notebook tutorials\n",
"\n",
"! wget https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/setup.py -O setup.py\n",
"\n",
"%run setup.py --bucket"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "autoset_project_id"
"id": "d809f07a8935"
},
"outputs": [],
"source": [
"if PROJECT_ID == \"\" or PROJECT_ID is None or PROJECT_ID == \"[your-project-id]\":\n",
" # Get your GCP project id from gcloud\n",
" shell_output = ! gcloud config list --format 'value(core.project)' 2>/dev/null\n",
" PROJECT_ID = shell_output[0]\n",
" print(\"Project ID:\", PROJECT_ID)"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "set_gcloud_project_id"
},
"outputs": [],
"source": [
"! gcloud config set project $PROJECT_ID"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "region"
},
"source": [
"#### Region\n",
"# Other Common setup instructions for notebook tutorials\n",
"\n",
"You can also change the `REGION` variable, which is used for operations\n",
"throughout the rest of this notebook. Below are regions supported for Vertex AI. We recommend that you choose the region closest to you.\n",
"! wget https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/setup.md -O setup.md\n",
"\n",
"- Americas: `us-central1`\n",
"- Europe: `europe-west4`\n",
"- Asia Pacific: `asia-east1`\n",
"\n",
"You may not use a multi-regional bucket for training with Vertex AI. Not all regions provide support for all Vertex AI services.\n",
"\n",
"Learn more about [Vertex AI regions](https://cloud.google.com/vertex-ai/docs/general/locations)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "region"
},
"outputs": [],
"source": [
"REGION = \"[your-region]\" # @param {type: \"string\"}\n",
"\n",
"if REGION == \"[your-region]\":\n",
" REGION = \"us-central1\""
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "timestamp"
},
"source": [
"#### Timestamp\n",
"\n",
"If you are in a live tutorial session, you might be using a shared test account or project. To avoid name collisions between users on resources created, you create a timestamp for each instance session, and append the timestamp onto the name of resources you create in this tutorial."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "timestamp"
},
"outputs": [],
"source": [
"from datetime import datetime\n",
"\n",
"TIMESTAMP = datetime.now().strftime(\"%Y%m%d%H%M%S\")"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "77c385f0db59"
},
"source": [
"### Authenticate your Google Cloud account\n",
"\n",
"**If you are using Vertex AI Workbench Notebooks**, your environment is already authenticated. Skip this step.\n",
"\n",
"**If you are using Colab**, run the cell below and follow the instructions when prompted to authenticate your account via oAuth.\n",
"\n",
"**Otherwise**, follow these steps:\n",
"\n",
"In the Cloud Console, go to the [Create service account key](https://console.cloud.google.com/apis/credentials/serviceaccountkey) page.\n",
"\n",
"1. **Click Create service account**.\n",
"\n",
"2. In the **Service account name** field, enter a name, and click **Create**.\n",
"\n",
"3. In the **Grant this service account access to project** section, click the Role drop-down list. Type \"Vertex AI\" into the filter box, and select **Vertex AI Administrator**. Type \"Storage Object Admin\" into the filter box, and select **Storage Object Admin**.\n",
"\n",
"4. Click Create. A JSON file that contains your key downloads to your local environment.\n",
"\n",
"5. Enter the path to your service account key as the GOOGLE_APPLICATION_CREDENTIALS variable in the cell below and run the cell."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "535223fa4b84"
},
"outputs": [],
"source": [
"# If you are running this notebook in Colab, run this cell and follow the\n",
"# instructions to authenticate your GCP account. This provides access to your\n",
"# Cloud Storage bucket and lets you submit training jobs and prediction\n",
"# requests.\n",
"\n",
"import os\n",
"import sys\n",
"\n",
"# If on Vertex AI Workbench, then don't execute this code\n",
"IS_COLAB = False\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\") and not os.getenv(\n",
" \"DL_ANACONDA_HOME\"\n",
"):\n",
" if \"google.colab\" in sys.modules:\n",
" IS_COLAB = True\n",
" from google.colab import auth as google_auth\n",
"\n",
" google_auth.authenticate_user()\n",
"\n",
" # If you are running this notebook locally, replace the string below with the\n",
" # path to your service account key and run this cell to authenticate your GCP\n",
" # account.\n",
" elif not os.getenv(\"IS_TESTING\"):\n",
" %env GOOGLE_APPLICATION_CREDENTIALS ''"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "bucket:custom"
},
"source": [
"### Create a Cloud Storage bucket\n",
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"When you submit a custom training job using the Vertex SDK, you upload a Python package\n",
"containing your training code to a Cloud Storage bucket. Vertex AI runs\n",
"the code from this package. In this tutorial, Vertex AI also saves the\n",
"trained model that results from your job in the same bucket. You can then\n",
"create an `Endpoint` resource based on this output in order to serve\n",
"online predictions.\n",
"\n",
"Set the name of your Cloud Storage bucket below. Bucket names must be globally unique across all Google Cloud projects, including those outside of your organization."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "bucket"
},
"outputs": [],
"source": [
"BUCKET_NAME = \"[your-bucket-name]\" # @param {type:\"string\"}\n",
"BUCKET_URI = f\"gs://{BUCKET_NAME}\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "autoset_bucket"
},
"outputs": [],
"source": [
"if BUCKET_NAME == \"\" or BUCKET_NAME is None or BUCKET_NAME == \"[your-bucket-name]\":\n",
" BUCKET_NAME = PROJECT_ID + \"aip-\" + TIMESTAMP\n",
" BUCKET_URI = \"gs://\" + BUCKET_NAME"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "create_bucket"
},
"source": [
"**Only if your bucket doesn't already exist**: Run the following cell to create your Cloud Storage bucket."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "create_bucket"
},
"outputs": [],
"source": [
"! gsutil mb -l $REGION $BUCKET_URI"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "validate_bucket"
},
"source": [
"Finally, validate access to your Cloud Storage bucket by examining its contents:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "validate_bucket"
},
"outputs": [],
"source": [
"! gsutil ls -al $BUCKET_URI"
"%load setup.md "
]
},
{
@@ -1319,7 +1078,7 @@
},
"outputs": [],
"source": [
"delete_storage = True\n",
"delete_storage = False\n",
"\n",
"if delete_storage or os.getenv(\"IS_TESTING\"):\n",
" if \"BUCKET_URI\" in globals():\n",
@@ -33,12 +33,12 @@
"\n",
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage1/get_started_vertex_datasets.ipynb\">\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage1/get_started_vertex_datasets.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/ai/platform/notebooks/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage1/get_started_vertex_datasets.ipynb\">\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage1/get_started_vertex_datasets.ipynb\">\n",
"<img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
" View on GitHub\n",
" </a>\n",
@@ -212,7 +212,7 @@
"\n",
"3. [Enable the Vertex AI APIs and Compute Engine APIs.](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com,compute_component)\n",
"\n",
"4. [Google Cloud SDK](https://cloud.google.com/sdk) is already installed in Google Cloud Notebooks.\n",
"4. [Google Cloud SDK](https://cloud.google.com/sdk) is already installed in Vertex AI Workbench Notebooks.\n",
"\n",
"5. Enter your project ID in the cell below. Then run the cell to make sure the\n",
"Cloud SDK uses the right project for all the commands in this notebook.\n",
@@ -374,15 +374,8 @@
"### Authenticate your Google Cloud account\n",
"\n",
"**If you are using Vertex AI Workbench Notebooks**, your environment is already\n",
"authenticated. Skip this step."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "32e1cd21a5d5"
},
"source": [
"authenticated. \n",
"\n",
"**If you are using Colab**, run the cell below and follow the instructions\n",
"when prompted to authenticate your account via oAuth.\n",
"\n",
@@ -39,18 +39,15 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage1/mlops_data_management.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\\\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/stage1/mlops_data_management.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
" </td>\n",
"</table>\n",
"<br/><br/><br/>"
"<br/><br/><br/>\n",
"\n",
"*Note: This notebook is not supported for execution in Colab*"
]
},
{
@@ -169,21 +166,20 @@
"if IS_WORKBENCH_NOTEBOOK:\n",
" USER_FLAG = \"--user\"\n",
"\n",
"ONCE_ONLY = True\n",
"ONCE_ONLY = False\n",
"if ONCE_ONLY:\n",
" ! pip3 install -U tensorflow==2.5 $USER_FLAG -q\n",
" ! pip3 install -U tensorflow-data-validation==1.2 $USER_FLAG -q\n",
" ! pip3 install -U tensorflow-transform==1.2 $USER_FLAG -q\n",
" ! pip3 install -U tensorflow-io==0.18 $USER_FLAG -q\n",
" ! pip3 install --upgrade google-cloud-aiplatform[tensorboard] $USER_FLAG -q\n",
" ! pip3 install --upgrade google-cloud-pipeline-components $USER_FLAG -q\n",
" ! pip3 install --upgrade google-cloud-bigquery $USER_FLAG -q\n",
" ! pip3 install --upgrade google-cloud-logging $USER_FLAG -q\n",
" ! pip3 install --upgrade apache-beam[gcp]==2.33.0 $USER_FLAG -q\n",
" ! pip3 install --upgrade pyarrow $USER_FLAG -q\n",
" ! pip3 install --upgrade cloudml-hypertune $USER_FLAG -q\n",
" ! pip3 install --upgrade kfp $USER_FLAG -q\n",
" ! pip3 install future $USER_FLAG -q"
" ! pip3 install -U {USER_FLAG} -q tensorflow==2.5 \\\n",
" tensorflow-data-validation==1.2 \\\n",
" tensorflow-transform==1.2 \\\n",
" tensorflow-io==0.18 \n",
" \n",
" ! pip3 install --upgrade {USER_FLAG} -q google-cloud-aiplatform[tensorboard] \\\n",
" google-cloud-pipeline-components \\\n",
" google-cloud-bigquery \\\n",
" google-cloud-logging \\\n",
" apache-beam[gcp] \\\n",
" pyarrow \\\n",
" cloudml-hypertune\n"
]
},
{
@@ -355,7 +351,7 @@
"source": [
"### Authenticate your Google Cloud account\n",
"\n",
"**If you are using Vertex AI Workbench Notebooks**, your environment is already authenticated. Skip this step.\n",
"**If you are using Vertex AI Workbench Notebooks**, your environment is already authenticated. \n",
"\n",
"**If you are using Colab**, run the cell below and follow the instructions when prompted to authenticate your account via oAuth.\n",
"\n",
@@ -417,7 +413,7 @@
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"When you submit a custom training job using the Vertex SDK, you upload a Python package\n",
"When you submit a custom training job using the Vertex AI SDK, you upload a Python package\n",
"containing your training code to a Cloud Storage bucket. Vertex AI runs\n",
"the code from this package. In this tutorial, Vertex AI also saves the\n",
"trained model that results from your job in the same bucket. You can then\n",
+182 -150
View File
@@ -35,44 +35,59 @@ The second stage in MLOps is experimenting in developing one or more baseline mo
### Get Started
[Get started with Vertex AI Training for R](community/ml_ops/stage2/get_started_vertex_training_r.ipynb)
[Get started with Vertex AI Training for Pytorch](get_started_vertex_training_pytorch.ipynb)
In this tutorial, you learn how to use `Vertex AI Training` for training a R custom model.
```
The steps performed include:
- Single node training using a Python package.
- Locally train an R model in a notebook using %%R magic commands
- Create a deployment image with trained R model and serving functions.
- Test the deployment image locally.
- Create a `Vertex AI Model` resource for the deployment image with embedded R model.
- Deploy the deployment image with embedded R model to a `Vertex AI Endpoint` resource.
- Test the deployment image with embedded R model.
- Create a R-to-Python training package.
- Create a training image for training the model.
- Train a R model using `Vertex AI Trainingh` service with the R-to-Python training package.
[Get started with Logging](community/ml_ops/stage2/get_started_with_logging.ipynb)
In this tutorial, you learn how to use Python and Cloud logging awhen training with `Vertex AI`.
The steps performed include:
- Use Python logging to log training configuration/results locally.
- Use Google Cloud Logging to log training configuration/results in cloud storage.
[Get started with Vertex AI Hyperparameter Tuning for XGBoost] (community/ml_ops/stage2/get_started_vertex_hpt_xgboost.ipynb)
In this tutorial, you learn how to use `Vertex AI Hyperparameter Tuning` for training a XGBoost custom model.
The steps performed include:
- Training using a Python package.
- Report accuracy when hyperparameter tuning.
- Save the model artifacts to Cloud Storage using GCSFuse.
- Create a `Vertex AI Model` resource.
```
[Get started with prebuilt TFHub models](get_started_with_tfhub_models.ipynb)
[Get started with Vertex AI Training for XGBoost](community/ml_ops/stage2/get_started_vertex_training_xgboost.ipynb)
In this tutorial, you learn how to use `Vertex AI Training` for training a XGBoost custom model.
```
The steps performed include:
- Download a TensorFlow Hub prebuilt model.
- Add the task component as a classifier for the CIFAR-10 dataset.
- Fine tune locally the model with transfer learning training.
- Construct a custom training script:
- Get training data from TensorFlow Datasets
- Get model architecture from TensorFlow Hub
- Train then model
- Save model artifacts and upload as Vertex AI Model resource.
```
[Get started with Vertex AI TensorBoard](get_started_vertex_tensorboard.ipynb)
- Training using a Python package.
- Report accuracy when hyperparameter tuning.
- Save the model artifacts to Cloud Storage using GCSFuse.
- Create a `Vertex AI Model` resource.
[Get started with TabNet builtin algorithm for training tabular models](community/ml_ops/stage2/get_started_with_tabnet.ipynb)
In this notebook, you learn how to run `Vertex AI TabNet` built algorithm for training custom tabular models.
```
The steps performed include:
- Create a TensorBoard callback when training a model.
- Using Tensorboard with locally trained model.
- Using Vertex AI TensorBoard with Vertex AI Training.
```
[Get started with TabNet builtin algorithm for training tabular models](get_started_with_tabnet.ipynb)
```
The steps performed include:
- Get the training data.
- Configure training parameters for the `Vertex AI TabNet` container.
- Train the model using `Vertex AI Training` using CSV data.
@@ -82,50 +97,107 @@ The steps performed include:
- Hyperparameter tuning the `Vertex AI TabNet` model.
- Train the model using `Vertex AI Training` using BigQuery table.
```
[Get started with prebuilt TFHub models](community/ml_ops/stage2/get_started_with_tfhub_models.ipynb)
[Get started with Vertex AI Vizier](get_started_vertex_vizier.ipynb)
In this tutorial, you learn how to use `Vertex AI Training` with prebuilt models from TensorFlow Hub.
```
The steps performed include:
- Download a TensorFlow Hub prebuilt model.
- Add the task component as a classifier for the CIFAR-10 dataset.
- Fine tune locally the model with transfer learning training.
- Construct a custom training script:
- Get training data from TensorFlow Datasets
- Get model architecture from TensorFlow Hub
- Train then model
- Save model artifacts and upload as Vertex AI Model resource.
[Get started with BigQuery ML Training](community/ml_ops/stage2/get_started_bqml_training.ipynb)
In this tutorial, you learn how to use `BigQueryML` (BQML) for training with `Vertex AI`.
The steps performed include:
- Create a local BigQuery table in your project
- Train a BQML model
- Evaluate the BQML model
- Export the BQML model as a cloud model
- Upload the exported model as a `Vertex AI Model` resource
- Hyperparameter tune a BQML model with `Vertex AI Vizier`
- Automatically register a BQML model to `Vertex AI Model Registry`
[Get started with Vertex AI Vizier](community/ml_ops/stage2/get_started_vertex_vizier.ipynb)
In this tutorial, you learn how to use `Vertex AI Vizier` for when training with `Vertex AI`.
The steps performed include:
- Hyperparameter tuning with Random algorithm.
- Hyperparameter tuning with Vizier (Bayesian) algorithm.
```
- Suggesting trials and updating results for Vizier study
[Automl image classfication training with customer managed encryption keys (CMEK)](get_started_with_cmek_training.ipynb)
[Get started with distributed training using DASK](community/ml_ops/stage2/get_started_with_distributed_training_xgboost.ipynb)
In this tutorial, you learn how to use `Vertex AI Training` for distributed training of XGBoost model using the OSS package DASK. Additionally, you learn to construct and deploy a custom serving container using a Flask web server.
```
The steps performed include:
- Creating a customer managed encryption key.
- Creating an image dataset with CMEK encryption.
- Train an AutoML model with CMEK encryption.
```
[Get started with Vertex AI distributed training](get_started_vertex_distributed_training.ipynb)
- Construct an XGBoost training script using DASK for distributed training.
- Construct a custom training container.
- Configure a distributed custom training job.
- Execute the custom training job.
- Construct a custom serving container using Flask.
- Upload the trained XGBoost model as a `Vertex AI Model` resource.
- Create a `Vertex AI Endpoint` resource.
- Deploy the `Vertex AI Model` resource to `Vertex AI Endpoint` resource.
- Make a prediction.
[Get started with Vertex AI TensorBoard](community/ml_ops/stage2/get_started_vertex_tensorboard.ipynb)
In this tutorial, you learn how to use `Vertex AI TensorBoard` when training with `Vertex AI`.
```
The steps performed include:
- `MirroredStrategy`: Train on a single VM with multiple GPUs.
- `MultiWorkerMirroredStrategy`: Train on multiple VMs with automatic setup of replicas.
- `MultiWorkerMirroredStrategy`: Train on multiple VMs with fine grain control of replicas.
- `ReductionServer`: Train on multiple VMS and sync updates across VMS with `Vertex AI Reduction Server`.
- `TPUTraining`: Train with multiple Cloud TPUs.
```
[Get started with Vertex AI Training for scikit-learn](get_started_vertex_training_sklearn.ipynb)
- Create a TensorBoard callback when training a model.
- Using TensorBoard with locally trained model.
- Using Vertex AI TensorBoard with Vertex AI Training.
[Get started with Vertex AI Training for R using R Kernel](community/ml_ops/stage2/get_started_vertex_training_r_using_r_kernel.ipynb)
In this tutorial, you learn how to use `Vertex AI`, using an R kernel, for training and deploying an R custom model.
```
The steps performed include:
- Training using a Python package.
- Report accuracy when hyperparameter tuning.
- Save the model artifacts to Cloud Storage using GCSFuse.
- Create a `Vertex AI Model` resource.
```
[Get started with Vertex AI Experiments](get_started_vertex_experiments.ipynb)
- Create a custom R training script
- Create a custom R serving script
- Create a custom R deployment (serving) container.
- Train the model using `Vertex AI` custom training.
- Create an `Endpoint` resouce.
- Deploy the `Model` resource (trained R model) to the `Endpoint` resource.
- Make an online prediction.
[Get started Vision API test preprocessing and AutoML text model generation](community/ml_ops/stage2/get_started_with_visionapi_and_automl.ipynb)
In this tutorial, you create an `AutoML` text entity extraction model pre-existing extracted data by generating a custom import file. You deploy this mode for online prediction from a Python script using the `BigQuery`, `Vision AI`, Cloud Storage and `Vertex AI SDK` for Python.
```
The steps performed include:
- Preprocess training files using `Vision AI` APIs to extract the text from PDF files.
- Create a custom import file that includes annotation data based on the sample `BigQuery` dataset.
- Create a `Vertex AI Dataset` resource.
- Train the model.
- View the model evaluation.
- Deploy the `Vertex AI Model` resource to a serving `Endpoint` resource.
- Make a prediction.
- Undeploy the `Model`.
[Get started with Vertex AI Experiments](community/ml_ops/stage2/get_started_vertex_experiments.ipynb)
In this tutorial, you learn how to use `Vertex AI Experiments` when training with `Vertex AI`.
The steps performed include:
- Local (notebook) Training
- Create an experiment
- Create a first run in the experiment
@@ -142,23 +214,23 @@ The steps performed include:
- Create a `Vertex AI Training` custom job
- Execute the custom job
- Visualize the experiment results
```
[Get started with Vertex AI Hyperparameter Tuning for XGBoost](get_started_vertex_hpt_xgboost.ipynb)
[AutoML Image Classfication Training with Customer Managed Encryption Keys (CMEK)](community/ml_ops/stage2/get_started_with_cmek_training.ipynb)
In this tutorial, you learn how to use a customer managed encryption key (CMEK) for `Vertex AI AutoML` training.
```
The steps performed include:
- Training using a Python package.
- Report accuracy when hyperparameter tuning.
- Save the model artifacts to Cloud Storage using GCSFuse.
- Create a `Vertex AI Model` resource.
```
- Creating a customer managed encryption key.
- Creating an image dataset with CMEK encryption.
- Train an AutoML model with CMEK encryption.
[Get started with Vertex AI Feature Store](get_started_vertex_feature_store.ipynb)
[Get started with Vertex AI Feature Store](community/ml_ops/stage2/get_started_vertex_feature_store.ipynb)
In this tutorial, you learn how to use `Vertex AI Feature Store` when training and predicting with `Vertex AI`.
```
The steps performed include:
- Creating a Vertex AI `Featurestore` resource.
- Creating `EntityType` resources for the `Featurestore` resource.
- Creating `Feature` resources for each `EntityType` resource.
@@ -167,96 +239,26 @@ The steps performed include:
- From a pandas DataFrame.
- Perform online serving from a `Featurestore` resource.
- Perform batch serving from a `Featurestore` resource.
```
[Get started with Vertex AI Training for R](get_started_vertex_training_r.ipynb)
[Get started with AutoML Training](community/ml_ops/stage2/get_started_automl_training.ipynb)
In this tutorial, you learn how to use `AutoML` for training with `Vertex AI`.
```
The steps performed include:
- Locally train an R model in a notebook using %%R magic commands
- Create a deployment image with trained R model and serving functions.
- Test the deployment image locally.
- Create a `Vertex AI Model` resource for the deployment image with embedded R model.
- Deploy the deployment image with embedded R model to a `Vertex AI Endpoint` resource.
- Test the deployment image with embedded R model.
- Create a R-to-Python training package.
- Create a training image for training the model.
- Train a R model using `Vertex AI Trainingh` service with the R-to-Python training package.
```
[Get started with logging](get_started_with_logging.ipynb)
```
The steps performed include:
- Use Python logging to log training configuration/results locally.
- Use Google Cloud Logging to log training configuration/results in cloud storage.
```
[Get started with Vertex AI Training for R using R Kernel](get_started_vertex_training_r_using_r_kernel.ipynb)
```
The steps performed include:
- Create a custom R training script
- Create a custom R serving script
- Create a custom R deployment (serving) container.
- Train the model using `Vertex AI` custom training.
- Create an `Endpoint` resouce.
- Deploy the `Model` resource (trained R model) to the `Endpoint` resource.
- Make an online prediction.
```
[Get started with BigQuery ML training](get_started_bqml_training.ipynb)
```
The steps performed include:
- Create a local BigQuery table in your project
- Train a BQML model
- Evaluate the BQML model
- Export the BQML model as a cloud model
- Upload the exported model as a `Vertex AI Model` resource
- Hyperparameter tune a BQML model with `Vertex AI Vizier`
- Automatically register a BQML model to `Vertex AI Model Registry`
```
[Get started with AutoML training](get_started_automl_training.ipynb)
```
The steps performed include:
- Train an image model
- Export the image model as an edge model
- Train a tabular model
- Export the tabular model as a cloud model
- Train a text model
- Train a video model
```
[Get started with Vertex AI Training for XGBoost](get_started_vertex_training_xgboost.ipynb)
[Get started with Vertex AI Training for LightGBM](community/ml_ops/stage2/get_started_vertex_training_lightgbm.ipynb)
In this tutorial, you learn how to use `Vertex AI Training` for training a LightGBM custom model.
```
The steps performed include:
- Training using a Python package.
- Report accuracy when hyperparameter tuning.
- Save the model artifacts to Cloud Storage using GCSFuse.
- Create a `Vertex AI Model` resource.
```
[Get started with Vertex AI Training](get_started_vertex_training.ipynb)
```
The steps performed include:
- Training using a single Python script.
- Training using a Python package.
- Training using a custom training image.
- Laying out a training package.
```
[Get started with Vertex AI Training for LightGBM](get_started_vertex_training_lightgbm.ipynb)
```
The steps performed include:
- Training using a Python package.
- Save the model artifacts to Cloud Storage using GCSFuse.
- Construct a FastAPI prediction server.
@@ -264,21 +266,51 @@ The steps performed include:
- Test the deployment image locally.
- Create a `Vertex AI Model` resource.
```
[Get started with Vertex AI Training for Scikit-Learn](community/ml_ops/stage2/get_started_vertex_training_sklearn.ipynb)
[Get started Vision API test preprocessing and AutoML text model generation](get_started_with_visionapi_and_automl.ipynb)
In this tutorial, you learn how to use `Vertex AI Training` for training a Scikit-Learn custom model.
```
The steps performed include:
- Preprocess training files using `Vision AI` APIs to extract the text from PDF files.
- Create a custom import file that includes annotation data based on the sample `BigQuery` dataset.
- Create a `Vertex AI Dataset` resource.
- Train the model.
- View the model evaluation.
- Deploy the `Vertex AI Model` resource to a serving `Endpoint` resource.
- Make a prediction.
- Undeploy the `Model`.
```
- Training using a Python package.
- Report accuracy when hyperparameter tuning.
- Save the model artifacts to Cloud Storage using GCSFuse.
- Create a `Vertex AI Model` resource.
[Get started with Vertex AI Training](community/ml_ops/stage2/get_started_vertex_training.ipynb)
In this tutorial, you learn how to use `Vertex AI Training` for custom models when training with `Vertex AI`.
The steps performed include:
- Training using a single Python script.
- Training using a Python package.
- Training using a custom training image.
- Laying out a training package.
[Get started with Vertex AI Training for Pytorch](community/ml_ops/stage2/get_started_vertex_training_pytorch.ipynb)
In this tutorial, you learn how to use `Vertex AI Training` for training a Pytorch custom model.
The steps performed include:
- Single node training using a Python package.
- Report accuracy when hyperparameter tuning.
- Save the model artifacts to Cloud Storage using GCSFuse.
- Create a `Vertex AI Model` resource.
[Get started with Vertex AI Distributed Training](community/ml_ops/stage2/get_started_vertex_distributed_training.ipynb)
In this tutorial, you learn how to use `Vertex AI Distributed Training` for when training with `Vertex AI`.
The steps performed include:
- `MirroredStrategy`: Train on a single VM with multiple GPUs.
- `MultiWorkerMirroredStrategy`: Train on multiple VMs with automatic setup of replicas.
- `MultiWorkerMirroredStrategy`: Train on multiple VMs with fine grain control of replicas.
- `ReductionServer`: Train on multiple VMS and sync updates across VMS with `Vertex AI Reduction Server`.
- `TPUTraining`: Train with multiple Cloud TPUs.
### E2E Stage Example
@@ -78,6 +78,7 @@
"This tutorial uses the following Google Cloud ML services:\n",
"\n",
"- `AutoML Training`\n",
"- `Vertex AI Datasets`\n",
"\n",
"The steps performed include:\n",
"\n",
@@ -498,7 +499,7 @@
},
{
"cell_type": "code",
"execution_count": null,
"execution_count": 1,
"metadata": {
"id": "import_aip:mbsdk"
},
@@ -568,6 +569,142 @@
"Learn more about [AutoML Model Types](https://cloud.google.com/vertex-ai/docs/start/automl-model-types)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "data_preparation:image,u_dataset"
},
"source": [
"### Data preparation\n",
"\n",
"The Vertex `Dataset` resource for images has some requirements for your data:\n",
"\n",
"- Images must be stored in a Cloud Storage bucket.\n",
"- Each image file must be in an image format (PNG, JPEG, BMP, ...).\n",
"- There must be an index file stored in your Cloud Storage bucket that contains the path and label for each image.\n",
"- The index file must be either CSV or JSONL.\n",
"\n",
"Learn more about [Preparing image data](https://cloud.google.com/vertex-ai/docs/datasets/prepare-image)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "data_import_format:icn,u_dataset,csv"
},
"source": [
"#### CSV\n",
"\n",
"For image classification, the CSV index file has the requirements:\n",
"\n",
"- No heading.\n",
"- First column is the Cloud Storage path to the image.\n",
"- Second column is the label.\n",
"- Any remaining columns are additional labels for multi-label image classification.\n",
"\n",
"For image object detection, the CSV index file has the requirements:\n",
"\n",
"- No heading.\n",
"- First column is the Cloud Storage path to the image.\n",
"- Second column is the label.\n",
"- Third/Fourth columns are the upper left corner of bounding box. Coordinates are normalized, between 0 and 1.\n",
"- Fifth/Sixth/Seventh columns are not used and should be 0.\n",
"- Eighth/Ninth columns are the lower right corner of the bounding box.\n",
"\n",
"##### ML_USE\n",
"\n",
"Each row may additionally specify which split to assign the data item to when the dataset is split for training; otherwise, the dataset will be randomly split: 80/10/10.\n",
"\n",
"The `ml_use` assignment is specified by prepending a column for specifying the assignment -- as the first column. The value may be one of: training, test, or validation."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "data_import_format:isg,u_dataset,jsonl"
},
"source": [
"#### JSONL\n",
"\n",
"For image classification, the JSONL index file has the requirements:\n",
"\n",
"- Each data item is a separate JSON object, on a separate line.\n",
"- The key/value pair `image_gcs_uri` is the Cloud Storage path to the image.\n",
"- The key/value pair `display_name` is the label for the image.\n",
"\n",
" { 'image_gcs_uri': image, \n",
" 'classification_annotations': \n",
" { 'display_name': label\n",
" }\n",
" }\n",
" \n",
"For multi-label, the labels are specified as a list of `display_name` key/value pairs:\n",
"\n",
" { 'image_gcs_uri': image, \n",
" 'classification_annotations': [\n",
" { 'display_name': label1\n",
" },\n",
" { 'display_name': labelN\n",
" },\n",
" ]\n",
" }\n",
" \n",
"For object detection, the JSONL index file has the requirements:\n",
"\n",
"- Each data item is a separate JSON object, on a separate line.\n",
"- The key/value pair `image_gcs_uri` is the Cloud Storage path to the image.\n",
"- The key/value pair `bounding_box_annotations` is a list of:\n",
" - `display_name`: The label of the object\n",
" - `x_min`, `y_min`, `x_max`, `y_max`: The coordinates for the bounding box\n",
"\n",
"{\n",
" \"image_gcs_uri\": image,\n",
" \"bounding_box_annotations\": [\n",
" {\n",
" \"display name\": label,\n",
" \"x_min\": \"X_MIN\",\n",
" \"y_min\": \"Y_MIN\",\n",
" \"x_max\": \"X_MAX\",\n",
" \"y_max\": \"Y_MAX\"\n",
" }\n",
" },\n",
" {\n",
" \"displayName\": \"OBJECT2_LABEL\",\n",
" \"x_min\": \"X_MIN\",\n",
" \"y_min\": \"Y_MIN\",\n",
" \"x_max\": \"X_MAX\",\n",
" \"y_max\": \"Y_MAX\"\n",
" }\n",
" ]\n",
"}\n",
"\n",
"\n",
"For image segmentation, the JSONL index file has the requirements:\n",
"\n",
"- Each data item is a separate JSON object, on a separate line.\n",
"- The key/value pair `image_gcs_uri` is the Cloud Storage path to the image.\n",
"- The key/value pair `category_mask_uri` is the Cloud Storage path to the mask image in PNG format.\n",
"- The key/value pair `'annotation_spec_colors'` is a list mapping mask colors to a label.\n",
" - The key/value pair pair `display_name` is the label for the pixel color mask.\n",
" - The key/value pair pair `color` are the RGB normalized pixel values (between 0 and 1) of the mask for the corresponding label.\n",
"\n",
" { 'image_gcs_uri': image, \n",
" 'segmentation_annotations': { 'category_mask_uri': mask_image, 'annotation_spec_colors' : [ \n",
" { 'display_name': label, 'color': {\"red\": value, \"blue\", value, \"green\": value} }, ...\n",
" ] \n",
" }\n",
" \n",
"##### ML_USE\n",
"\n",
"Each JSONL object may additionally specify which split to assign the data item to when the dataset is split for training; otherwise, the dataset will be randomly split: 80/10/10.\n",
"\n",
"\"data_item_resource_labels\": {\n",
" \"aiplatform.googleapis.com/ml_use\": \"training|test|validation\"\n",
" }\n",
"\n",
"*Note*: The dictionary key fields may alternatively be in camelCase. For example, 'image_gcs_uri' can also be 'imageGcsUri'."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -1068,6 +1205,42 @@
"Learn more about [AutoML Model Types](https://cloud.google.com/vertex-ai/docs/start/automl-model-types)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "data_preparation:tabular,u_dataset"
},
"source": [
"### Data preparation\n",
"\n",
"The Vertex AI `Dataset` resource for tabular has a couple of requirements for your tabular data.\n",
"\n",
"- Must be in a CSV file or a BigQuery table.\n",
"\n",
"Learn more about [Preparing tabular data](https://cloud.google.com/vertex-ai/docs/datasets/prepare-tabular)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "data_import_format:lbn,u_dataset,csv"
},
"source": [
"#### CSV\n",
"\n",
"For tabular models, the CSV file has a few requirements:\n",
"\n",
"- The first row must be the heading -- note how this is different from Image, Text and Video where the requirement is no heading.\n",
"- All but one column are features.\n",
"- One column is the label, which you will specify when you subsequently create the training pipeline.\n",
"\n",
"##### ML_USE\n",
"\n",
"Each row may additionally specify which split to assign the data item to when the dataset is split for training; otherwise, the dataset will be randomly split: 80/10/10.\n",
"\n",
"The `ml_use` assignment is specified by prepending a column for specifying the assignment -- as the first column. The value may be one of: training, test, or validation."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -1427,6 +1600,155 @@
"Learn more about [AutoML Model Types](https://cloud.google.com/vertex-ai/docs/start/automl-model-types)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "data_preparation:text,u_dataset"
},
"source": [
"### Data preparation\n",
"\n",
"The Vertex AI `Dataset` resource for text has a couple of requirements for your text data.\n",
"\n",
"- Text examples must be stored in a CSV or JSONL file.\n",
"\n",
"Learn more about [Preparing text data](https://cloud.google.com/vertex-ai/docs/datasets/prepare-text)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "data_import_format:tcn,u_dataset,csv"
},
"source": [
"#### CSV\n",
"\n",
"For text classification, the CSV file has a few requirements:\n",
"\n",
"- No heading.\n",
"- First column is the text example or Cloud Storage path to text file (.txt suffix).\n",
"- Second column the label.\n",
"- Any remaining columns are additional labels for multi-label text classification.\n",
"\n",
"For text sentiment analysis, the CSV file has a few requirements:\n",
"\n",
"- No heading.\n",
"- First column is the text example or Cloud Storage path to text file (.txt suffix).\n",
"- Second column is the sentiment value.\n",
"- Third column is the maximum possible sentiment value.\n",
"\n",
"##### ML_USE\n",
"\n",
"Each row may additionally specify which split to assign the data item to when the dataset is split for training; otherwise, the dataset will be randomly split: 80/10/10.\n",
"\n",
"The `ml_use` assignment is specified by prepending a column for specifying the assignment -- as the first column. The value may be one of: training, test, or validation."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "766c838de8a0"
},
"source": [
"#### JSONL \n",
"\n",
"For text classification, the JSONL file has a few requirements:\n",
"\n",
"- Each data item is a separate JSON object, on a separate line.\n",
"- The key/value pair `text_gcs_uri` is the Cloud Storage path to the text file.\n",
"- The key/value pair `text_content` is the alternate way of specifying the text as inlined.\n",
"- The key/value pair `display_name` is the label for the text.\n",
"\n",
"{\n",
" \"classification_annotation\": {\n",
" \"display_name\": label\n",
" },\n",
" \"text_content\": text\n",
"}\n",
"{\n",
" \"classification_annotation\": {\n",
" \"display_name\": label\n",
" },\n",
" \"text_gcs_uri\": \"gcs_uri_to_file\"\n",
"}\n",
"\n",
" \n",
"For multi-label, the labels are specified as a list of `display_name` key/value pairs:\n",
"\n",
" 'classification_annotations': [\n",
" { 'display_name': label1\n",
" },\n",
" { 'display_name': labelN\n",
" },\n",
" ]\n",
"\n",
"For text sentiment analysis, the JSONL file has a few requirements:\n",
"\n",
"- Each data item is a separate JSON object, on a separate line.\n",
"- The key/value pair `text_gcs_uri` is the Cloud Storage path to the text file.\n",
"- The key/value pair `text_content` is the alternate way of specifying the text as inlined.\n",
"- The key/value pair `sentiment` is the sentiment value as an integer value greater than 0.\n",
"- The key/value pair `sentiment_max`is the maximum possible value for the sentiment.\n",
"\n",
"{\n",
" \"sentiment_annotation\": {\n",
" \"sentiment\": number,\n",
" \"sentiment_max\": number\n",
" },\n",
" \"text_content\": text,\n",
"}\n",
"{\n",
" \"sentiment_annotation\": {\n",
" \"sentiment\": number,\n",
" \"sentiment_max\": number\n",
" },\n",
" \"text_gcs_uri\": \"gcs_uri_to_file\"\n",
"}\n",
"\n",
"\n",
"For text entity extraction, the JSONL file has a few requirements:\n",
"\n",
"- Each data item is a separate JSON object, on a separate line.\n",
"- The key/value pair `text_gcs_uri` is the Cloud Storage path to the text file.\n",
"- The key/value pair `text_content` is the alternate way of specifying the text as inlined.\n",
"- The key/value pair `start_offset` is the character offset of the start of the text.\n",
"- The key/value pair `end_offset` is the character offset of the end of the text.\n",
"- The key/value pair `display_name` is the label for the text.\n",
"\n",
"{\n",
" \"text_segment_annotations\": [\n",
" {\n",
" \"start_offset\":number,\n",
" \"end_offset\":number,\n",
" \"display_name\": label\n",
" },\n",
" ...\n",
" ],\n",
" \"textContent\": \"inline_text\"\n",
"}\n",
"{\n",
" \"textSegmentAnnotations\": [\n",
" {\n",
" \"start_offset\": number,\n",
" \"end_offset\": number,\n",
" \"displayName\": label\n",
" },\n",
" ...\n",
" ],\n",
" \"text_gcs_uri\": \"gcs_uri_to_file\"\n",
"}\n",
"\n",
"##### ML_USE\n",
"\n",
"Each JSONL object may additionally specify which split to assign the data item to when the dataset is split for training; otherwise, the dataset will be randomly split: 80/10/10.\n",
"\n",
"\"data_item_resource_labels\": {\n",
" \"aiplatform.googleapis.com/ml_use\": \"training|test|validation\"\n",
" }\n",
"\n",
"*Note*: The dictionary key fields may alternatively be in camelCase. For example, 'text_gcs_uri' can also be 'textGcsUri'."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -1749,6 +2071,144 @@
"Learn more about [AutoML Model Types](https://cloud.google.com/vertex-ai/docs/start/automl-model-types)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "data_preparation:text,u_dataset"
},
"source": [
"### Data preparation\n",
"\n",
"The Vertex AI `Dataset` resource for text has a couple of requirements for your text data.\n",
"\n",
"- Text examples must be stored in a CSV or JSONL file.\n",
"\n",
"Learn more about [Preparing video data](https://cloud.google.com/vertex-ai/docs/datasets/prepare-video)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "427212b48840"
},
"source": [
"#### CSV\n",
"\n",
"For video classification, the CSV file has a few requirements:\n",
"\n",
"- No heading.\n",
"- First column is the Cloud Storage path to video file.\n",
"- Second column the label.\n",
"- Third column is the start time (seconds) in the video to classify.\n",
"- Fourth column is the end time (seconds) in the video to classify.\n",
"\n",
"For multi-label classification, each label is a separate row entry.\n",
"\n",
"For video object tracking, the CSV file has a few requirements:\n",
"\n",
"- No heading.\n",
"- First column is the Cloud Storage path to video file.\n",
"- Second column the label.\n",
"- Third column is unused (blank).\n",
"- Fourth column is the start time (seconds) in the video to start tracking the object.\n",
"- The fifth through eighth columns are the vertices of the object to track.\n",
" - x_min\n",
" - y_min\n",
" - x_max\n",
" - y_max\n",
" \n",
"For action recognition, the CSV file has a few requirements:\n",
"\n",
"- No heading.\n",
"- Each row can be one of the following four formats:\n",
"\n",
"VIDEO_URI, TIME_SEGMENT_START, TIME_SEGMENT_END, LABEL, ANNOTATION_FRAME_TIMESTAMP\n",
"\n",
"VIDEO_URI, , , LABEL, ANNOTATION_FRAME_TIMESTAMP\n",
"\n",
"VIDEO_URI, TIME_SEGMENT_START, TIME_SEGMENT_END, LABEL, ANNOTATION_SEGMENT_START, ANNOTATION_SEGMENT_END\n",
"\n",
"VIDEO_URI, , , LABEL, ANNOTATION_SEGMENT_START, ANNOTATION_SEGMENT_END\n",
"\n",
"\n",
"##### ML_USE\n",
"\n",
"Each row may additionally specify which split to assign the data item to when the dataset is split for training; otherwise, the dataset will be randomly split: 80/10/10.\n",
"\n",
"The `ml_use` assignment is specified by prepending a column for specifying the assignment -- as the first column. The value may be one of: training, or test."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "461301339727"
},
"source": [
"#### JSONL\n",
"\n",
"For video classification, the CSV file has a few requirements:\n",
"\n",
"- Each data item is a separate JSON object, on a separate line.\n",
"- The key/value pair `video_gcs_uri` is the Cloud Storage path to the text file.\n",
"- The key/value pair `display_name` is the label for the text.\n",
"- The key/value pair `start_time` is the start time (seconds) for classifying.\n",
"- The key/value pair `end_time` is the end time (seconds) for classifying.\n",
"\n",
"\n",
" {\n",
" \"video_gcs_uri\": video,\n",
" \"time_segment_annotations\": [{\n",
" \"display_name\": label,\n",
" \"start_time\": \"start_time_of_segment\",\n",
" \"end_time\": \"end_time_of_segment\"\n",
" }]\n",
" }\n",
"\n",
"For video object tracking, the CSV file has a few requirements:\n",
"\n",
"- Each data item is a separate JSON object, on a separate line.\n",
"- The key/value pair `video_gcs_uri` is the Cloud Storage path to the text file.\n",
"\n",
" {\n",
" \"video_gcs_uri\": video,\n",
" \"temporal_bounding_box_annotations\": [{\n",
" \"display_name\": label,\n",
" \"x_min\": \"leftmost_coordinate_of_the_bounding box\",\n",
" \"x_max\": \"rightmost_coordinate_of_the_bounding box\",\n",
" \"y_min\": \"topmost_coordinate_of_the_bounding box\",\n",
" \"y_max\": \"bottommost_coordinate_of_the_bounding box\",\n",
" \"time_offset\": \"timeframe_object-detected\"\n",
" }]\n",
" }\n",
"\n",
"For video action recognition, the CSV file has a few requirements:\n",
"\n",
"- Each data item is a separate JSON object, on a separate line.\n",
"- The key/value pair `video_gcs_uri` is the Cloud Storage path to the text file.\n",
"\n",
" {\n",
" \"video_gcs_uri': video,\n",
" \"time_segments\": [{\n",
" \"start_time\": \"start_time_of_fully_annotated_segment\",\n",
" \"end_time\": \"end_time_of_segment\"}],\n",
" \"time_segment_annotations\": [{\n",
" \"display_name\": label,\n",
" \"start_time\": \"start_time_of_segment\",\n",
" \"end_time\": \"end_time_of_segment\"\n",
" }]\n",
" }\n",
"\n",
"##### ML_USE\n",
"\n",
"Each JSONL object may additionally specify which split to assign the data item to when the dataset is split for training; otherwise, the dataset will be randomly split: 80/20.\n",
"\n",
"\"data_item_resource_labels\": {\n",
" \"aiplatform.googleapis.com/ml_use\": \"training|test\"\n",
" }\n",
"\n",
"*Note*: The dictionary key fields may alternatively be in camelCase. For example, 'video_gcs_uri' can also be 'videoGcsUri'."
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -73,7 +73,7 @@
"source": [
"### Objective\n",
"\n",
"In this tutorial, you learn how to use `BigQueryML` (BQML) for training with `Vertex AI`.\n",
"In this tutorial, you learn how to use `BigQueryML` for training with `Vertex AI`.\n",
"\n",
"This tutorial uses the following Google Cloud ML services:\n",
"\n",
@@ -84,12 +84,12 @@
"The steps performed include:\n",
"\n",
"- Create a local BigQuery table in your project\n",
"- Train a BQML model\n",
"- Evaluate the BQML model\n",
"- Export the BQML model as a cloud model\n",
"- Train a BigQuery ML model\n",
"- Evaluate the BigQuery ML model\n",
"- Export the BigQuery ML model as a cloud model\n",
"- Upload the exported model as a `Vertex AI Model` resource\n",
"- Hyperparameter tune a BQML model with `Vertex AI Vizier`\n",
"- Automatically register a BQML model to `Vertex AI Model Registry`"
"- Hyperparameter tune a BigQuery ML model with `Vertex AI Vizier`\n",
"- Automatically register a BigQuery ML model to `Vertex AI Model Registry`"
]
},
{
@@ -749,9 +749,9 @@
"id": "bqml_create_model"
},
"source": [
"### Train BQML model\n",
"### Train BigQuery ML model\n",
"\n",
"Next, you create and train a BQML tabular classification model from the public dataset penguins and store the model in your project using the `CREATE MODEL` statement. The model configuration is specified in the `OPTIONS` statement as follows:\n",
"Next, you create and train a BigQuery ML tabular classification model from the public dataset penguins and store the model in your project using the `CREATE MODEL` statement. The model configuration is specified in the `OPTIONS` statement as follows:\n",
"\n",
"- `model_type`: The type and archictecture of tabular model to train, e.g., DNN classification.\n",
"- `labels`: The column which are the labels.\n",
@@ -800,9 +800,9 @@
"id": "bqml_eval_model"
},
"source": [
"### Evaluate the trained BQML model\n",
"### Evaluate the trained BigQuery ML model\n",
"\n",
"Next, retrieve the model evaluation for the trained BQML model.\n",
"Next, retrieve the model evaluation for the trained BigQuery ML model.\n",
"\n",
"Learn more about [The ML.EVALUATE function](https://cloud.google.com/bigquery-ml/docs/reference/standard-sql/bigqueryml-syntax-evaluate)."
]
@@ -833,9 +833,9 @@
"id": "bqml_export_model"
},
"source": [
"### Export the model from BQML\n",
"### Export the model from BigQuery ML\n",
"\n",
"The model you trained in BQML is a TensorFlow model. Next, you export the TensorFlow model artifacts in TF.SavedModel format."
"The model you trained in BigQuery ML is a TensorFlow model. Next, you export the TensorFlow model artifacts in TF.SavedModel format."
]
},
{
@@ -1028,9 +1028,9 @@
"id": "bqml_create_model:vizier"
},
"source": [
"### Hyperparameter Tune and train a BQML model\n",
"### Hyperparameter Tune and train a BigQuery ML model\n",
"\n",
"Next, you train a BQML tabular classification model with hyperparameter tuning using the `Vertex AI Vizier` service. The hyperparameter settings are specified in the `OPTIONS` statement as follows:\n",
"Next, you train a BigQuery ML tabular classification model with hyperparameter tuning using the `Vertex AI Vizier` service. The hyperparameter settings are specified in the `OPTIONS` statement as follows:\n",
"\n",
"- `HPARAM_TUNING_ALGORITHM`: The algorithm for selecting the next trial parameters.\n",
"- `num_trials`: The number of trials.\n",
@@ -1083,9 +1083,9 @@
"id": "bqml_eval_model"
},
"source": [
"### Evaluate the BQML trained model\n",
"### Evaluate the BigQuery ML trained model\n",
"\n",
"Next, retrieve the model evaluation results for the trained BQML model.\n",
"Next, retrieve the model evaluation results for the trained BigQuery ML model.\n",
"\n",
"Learn more about [The ML.EVALUATE function](https://cloud.google.com/bigquery-ml/docs/reference/standard-sql/bigqueryml-syntax-evaluate)."
]
@@ -1142,9 +1142,9 @@
"id": "bqml_create_model:xai"
},
"source": [
"### Train a BQML model with Explainability\n",
"### Train a BigQuery ML model with Explainability\n",
"\n",
"Next, you train the same BQML model, but this time you enable Vertex AI Explainability on the model predictions by adding the option:\n",
"Next, you train the same BigQuery ML model, but this time you enable Vertex AI Explainability on the model predictions by adding the option:\n",
"\n",
"- `ENABLE_GLOBAL_EXPLAIN`"
]
@@ -87,7 +87,7 @@
"This tutorial uses the following Google Cloud ML services:\n",
"\n",
"- `Vertex AI Experiments`\n",
"- `Vertex AI ML Metadata`\n",
"- `Vertex ML Metadata`\n",
"- `Vertex AI Training`\n",
"\n",
"The steps performed include:\n",
File diff suppressed because it is too large Load Diff
@@ -44,7 +44,7 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/notebook_template.ipynb\">\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/stage2/get_started_vertex_tensorboard.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
@@ -48,7 +48,7 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/tree/main/notebooks/community/ml_ops/stage2/get_started_vertex_training_lightgbm.ipynb\">\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_vertex_training_lightgbm.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
" View on GitHub\n",
" </a>\n",
@@ -29,7 +29,7 @@
"id": "title:generic,gcp"
},
"source": [
"# E2E ML on GCP: MLOps stage 2 : experimentation: get started with Vertex AI Training for Pytorch\n",
"# E2E ML on GCP: MLOps stage 2 : experimentation: get started with Vertex AI Training for PyTorch\n",
"\n",
"<table align=\"left\">\n",
" <td>\n",
@@ -44,7 +44,7 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/notebook_template.ipynb\">\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/stage2/get_started_vertex_training_pytorch.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
@@ -62,7 +62,7 @@
"## Overview\n",
"\n",
"\n",
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers stage 2 : experimentation: get started with Vertex AI Training for Pytorch."
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers stage 2 : experimentation: get started with Vertex AI Training for PyTorch."
]
},
{
@@ -73,7 +73,7 @@
"source": [
"### Objective\n",
"\n",
"In this tutorial, you learn how to use `Vertex AI Training` for training a Pytorch custom model.\n",
"In this tutorial, you learn how to use `Vertex AI Training` for training a PyTorch custom model.\n",
"\n",
"This tutorial uses the following Google Cloud ML services:\n",
"\n",
@@ -97,7 +97,7 @@
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is the [CIFAR10 dataset](https://pytorch.org/vision/stable/datasets.html#cifar) from [Pytorch Datasets](https://pytorch.org/vision/stable/datasets.html). The version of the dataset is built into TensorFlow. The trained model predicts which type of class an image is from ten classes: airplane, automobile, bird, cat, deer, dog, frog, horse, ship, or truck."
"The dataset used for this tutorial is the [CIFAR10 dataset](https://pytorch.org/vision/stable/datasets.html#cifar) from [PyTorch Datasets](https://pytorch.org/vision/stable/datasets.html). The version of the dataset is built into TensorFlow. The trained model predicts which type of class an image is from ten classes: airplane, automobile, bird, cat, deer, dog, frog, horse, ship, or truck."
]
},
{
@@ -672,17 +672,17 @@
"id": "pytorch_intro"
},
"source": [
"## Introduction to Pytorch training\n",
"## Introduction to PyTorch training\n",
"\n",
"The Pytorch package supports both single node and distributed model training.\n",
"The PyTorch package supports both single node and distributed model training.\n",
"\n",
"Once you have trained a Pytorch model, you will want to save it at a Cloud Storage location, so it can subsequently be uploaded to a `Vertex AI Model` resource.\n",
"The Pytorch package does not have support to save the model to a Cloud Storage location. Instead, you will do the following steps to save to a Cloud Storage location.\n",
"Once you have trained a PyTorch model, you will want to save it at a Cloud Storage location, so it can subsequently be uploaded to a `Vertex AI Model` resource.\n",
"The PyTorch package does not have support to save the model to a Cloud Storage location. Instead, you will do the following steps to save to a Cloud Storage location.\n",
"\n",
"1. Save the in-memory model to the local filesystem (e.g., model.pth).\n",
"2. Use gsutil to copy the local copy to the specified Cloud Storage location.\n",
"\n",
"*Note*: You can do hyperparameter tuning with a Pytorch model."
"*Note*: You can do hyperparameter tuning with a PyTorch model."
]
},
{
@@ -1069,9 +1069,9 @@
"id": "docker_write,prediction,pytorch"
},
"source": [
"### Make Pytorch container for prediction\n",
"### Make PyTorch container for prediction\n",
"\n",
"Currently, Vertex AI does not have a predefined container for making predictions with a deployed Pytorch model. No problem, you can assemble your own custom container. Typically, one would base the container on the `Torch Server`. For demonstration purpose, you build a placeholder container (not complete) that includes the latest `Torch Server` image, and push it to the `Container Registry`."
"Currently, Vertex AI does not have a predefined container for making predictions with a deployed PyTorch model. No problem, you can assemble your own custom container. Typically, one would base the container on the `Torch Server`. For demonstration purpose, you build a placeholder container (not complete) that includes the latest `Torch Server` image, and push it to the `Container Registry`."
]
},
{
@@ -43,7 +43,7 @@
"<table align=\"left\">\n",
"\n",
" <td>\n",
" <a href=\"https://colab.sandbox.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_vertex_training_r_using_r_kernel.ipynb\">\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/get_started_vertex_training_r_using_r_kernel.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
@@ -109,7 +109,7 @@
"source": [
"### Dataset\n",
"\n",
"The dataset used for this tutorial is [California Housing Dataset](https://www.dcc.fc.up.pt/~ltorgo/Regression/cal_housing.html). The data contains information from the 1990 California census. The data set is publicly available from Google Cloud Storage at `gs://cloud-samples-data/ai-platform-unified/datasets/tabular/california-housing-tabular-regression.csv`. The dataset is used to train a Random Forest regressor to predict a median housing price, given a longitude and lattitude along with data from the corresponding census block group. A block group is the smallest geographical unit for which the U.S. Census Bureau publishes sample data (a block group typically has a population of 600 to 3,000 people).\n"
"The dataset used for this tutorial is [California Housing Dataset](https://www.dcc.fc.up.pt/~ltorgo/Regression/cal_housing.html). The data contains information from the 1990 California census. The data set is publicly available from Cloud Storage at `gs://cloud-samples-data/ai-platform-unified/datasets/tabular/california-housing-tabular-regression.csv`. The dataset is used to train a Random Forest regressor to predict a median housing price, given a longitude and lattitude along with data from the corresponding census block group. A block group is the smallest geographical unit for which the U.S. Census Bureau publishes sample data (a block group typically has a population of 600 to 3,000 people).\n"
]
},
{
@@ -44,7 +44,7 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/ai/platform/notebooks/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/stage2/get_started_vertex_training_sklearn.ipynb\">\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/stage2/get_started_vertex_training_sklearn.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
"Open in Vertex AI Workbench\n",
" </a>\n",
@@ -297,25 +297,32 @@
{
"cell_type": "markdown",
"metadata": {
"id": "timestamp"
"id": "06571eb4063b"
},
"source": [
"#### Timestamp\n",
"#### UUID\n",
"\n",
"If you are in a live tutorial session, you might be using a shared test account or project. To avoid name collisions between users on resources created, you create a timestamp for each instance session, and append the timestamp onto the name of resources you create in this tutorial."
"If you are in a live tutorial session, you might be using a shared test account or project. To avoid name collisions between users on resources created, you create a uuid for each instance session, and append it onto the name of resources you create in this tutorial."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "JYtXOocrox9Q"
"id": "4e166d927e36"
},
"outputs": [],
"source": [
"from datetime import datetime\n",
"import random\n",
"import string\n",
"\n",
"TIMESTAMP = datetime.now().strftime(\"%Y%m%d%H%M%S\")"
"\n",
"# Generate a uuid of a specifed length(default=8)\n",
"def generate_uuid(length: int = 8) -> str:\n",
" return \"\".join(random.choices(string.ascii_lowercase + string.digits, k=length))\n",
"\n",
"\n",
"UUID = generate_uuid()"
]
},
{
@@ -362,12 +369,11 @@
"import sys\n",
"\n",
"# If on Vertex AI Workbench, then don't execute this code\n",
"IS_COLAB = False\n",
"IS_COLAB = \"google.colab\" in sys.modules\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\") and not os.getenv(\n",
" \"DL_ANACONDA_HOME\"\n",
"):\n",
" if \"google.colab\" in sys.modules:\n",
" IS_COLAB = True\n",
" from google.colab import auth as google_auth\n",
"\n",
" google_auth.authenticate_user()\n",
@@ -402,7 +408,8 @@
},
"outputs": [],
"source": [
"BUCKET_URI = \"gs://[your-bucket-name]\" # @param {type:\"string\"}"
"BUCKET_NAME = \"[your-bucket-name]\" # @param {type:\"string\"}\n",
"BUCKET_URI = f\"gs://{BUCKET_NAME}\""
]
},
{
@@ -413,8 +420,9 @@
},
"outputs": [],
"source": [
"if BUCKET_URI == \"\" or BUCKET_URI is None or BUCKET_URI == \"gs://[your-bucket-name]\":\n",
" BUCKET_URI = \"gs://\" + PROJECT_ID + \"aip-\" + TIMESTAMP"
"if BUCKET_NAME == \"\" or BUCKET_NAME is None or BUCKET_NAME == \"[your-bucket-name]\":\n",
" BUCKET_NAME = PROJECT_ID + \"aip-\" + UUID\n",
" BUCKET_URI = \"gs://\" + BUCKET_NAME"
]
},
{
@@ -749,6 +757,7 @@
"import hypertune\n",
"import argparse\n",
"import logging\n",
"import numpy as np\n",
"\n",
"from sklearn.model_selection import train_test_split\n",
"from sklearn.metrics import accuracy_score\n",
@@ -790,16 +799,23 @@
"def train_model(dtrain):\n",
" logging.info(\"Start training ...\")\n",
" # Train XGBoost model\n",
" model = xgb.train({}, dtrain, num_boost_round=args.boost_rounds)\n",
" params = {\n",
" 'objective': 'multi:softprob',\n",
" 'num_class': 3\n",
" }\n",
" model = xgb.train(params, dtrain, num_boost_round=args.boost_rounds)\n",
" logging.info(\"Training completed\")\n",
" return model\n",
"\n",
"def evaluate_model(model, test_data, test_labels):\n",
" dtest = xgb.DMatrix(test_data)\n",
" pred = model.predict(dtest)\n",
" predictions = [round(value) for value in pred]\n",
" predictions = [np.around(value) for value in pred]\n",
" # evaluate predictions\n",
" accuracy = accuracy_score(test_labels, predictions)\n",
" try:\n",
" accuracy = accuracy_score(test_labels, predictions)\n",
" except:\n",
" accuracy = 0.0\n",
" logging.info(f\"Evaluation completed with model accuracy: {accuracy}\")\n",
"\n",
" # report metric for hyperparameter tuning\n",
@@ -893,7 +909,7 @@
},
"outputs": [],
"source": [
"DISPLAY_NAME = \"iris_\" + TIMESTAMP\n",
"DISPLAY_NAME = \"iris_\" + UUID\n",
"\n",
"job = aip.CustomPythonPackageTrainingJob(\n",
" display_name=DISPLAY_NAME,\n",
@@ -932,7 +948,7 @@
},
"outputs": [],
"source": [
"MODEL_DIR = \"{}/{}\".format(BUCKET_URI, TIMESTAMP)\n",
"MODEL_DIR = \"{}/{}\".format(BUCKET_URI, UUID)\n",
"DATASET_DIR = \"gs://cloud-samples-data/ai-platform/iris\"\n",
"\n",
"ROUNDS = 20\n",
@@ -983,7 +999,7 @@
"source": [
"if TRAIN_GPU:\n",
" model = job.run(\n",
" model_display_name=\"iris_\" + TIMESTAMP,\n",
" model_display_name=\"iris_\" + UUID,\n",
" args=CMDARGS,\n",
" replica_count=1,\n",
" machine_type=TRAIN_COMPUTE,\n",
@@ -994,7 +1010,7 @@
" )\n",
"else:\n",
" model = job.run(\n",
" model_display_name=\"iris_\" + TIMESTAMP,\n",
" model_display_name=\"iris_\" + UUID,\n",
" args=CMDARGS,\n",
" replica_count=1,\n",
" machine_type=TRAIN_COMPUTE,\n",
@@ -1095,7 +1111,7 @@
},
"outputs": [],
"source": [
"delete_bucket = False\n",
"delete_bucket = True\n",
"\n",
"if delete_bucket or os.getenv(\"IS_TESTING\"):\n",
" ! gsutil rm -r $BUCKET_URI"
@@ -84,7 +84,8 @@
"The steps performed include:\n",
"\n",
"- Hyperparameter tuning with Random algorithm.\n",
"- Hyperparameter tuning with Vizier (Bayesian) algorithm."
"- Hyperparameter tuning with Vizier (Bayesian) algorithm.\n",
"- Suggesting trials and updating results for Vizier study"
]
},
{
@@ -187,7 +188,8 @@
"if IS_WORKBENCH_NOTEBOOK:\n",
" USER_FLAG = \"--user\"\n",
"\n",
"! pip3 install --upgrade google-cloud-aiplatform[tensorboard] $USER_FLAG -q"
"! pip3 install --upgrade $USER_FLAG -q google-cloud-aiplatform \\\n",
" google-vizier==0.0.4"
]
},
{
@@ -329,25 +331,32 @@
{
"cell_type": "markdown",
"metadata": {
"id": "timestamp"
"id": "06571eb4063b"
},
"source": [
"#### Timestamp\n",
"#### UUID\n",
"\n",
"If you are in a live tutorial session, you might be using a shared test account or project. To avoid name collisions between users on resources created, you create a timestamp for each instance session, and append the timestamp onto the name of resources you create in this tutorial."
"If you are in a live tutorial session, you might be using a shared test account or project. To avoid name collisions between users on resources created, you create a uuid for each instance session, and append it onto the name of resources you create in this tutorial."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "timestamp"
"id": "4e166d927e36"
},
"outputs": [],
"source": [
"from datetime import datetime\n",
"import random\n",
"import string\n",
"\n",
"TIMESTAMP = datetime.now().strftime(\"%Y%m%d%H%M%S\")"
"\n",
"# Generate a uuid of a specifed length(default=8)\n",
"def generate_uuid(length: int = 8) -> str:\n",
" return \"\".join(random.choices(string.ascii_lowercase + string.digits, k=length))\n",
"\n",
"\n",
"UUID = generate_uuid()"
]
},
{
@@ -358,7 +367,7 @@
"source": [
"### Authenticate your Google Cloud account\n",
"\n",
"**If you are using Vertex AI Workbench Notebooks**, your environment is already authenticated. Skip this step.\n",
"**If you are using Vertex AI Workbench Notebooks**, your environment is already authenticated. \n",
"\n",
"**If you are using Colab**, run the cell below and follow the instructions when prompted to authenticate your account via oAuth.\n",
"\n",
@@ -446,7 +455,7 @@
"outputs": [],
"source": [
"if BUCKET_URI == \"\" or BUCKET_URI is None or BUCKET_URI == \"gs://[your-bucket-name]\":\n",
" BUCKET_URI = \"gs://\" + PROJECT_ID + \"aip-\" + TIMESTAMP"
" BUCKET_URI = \"gs://\" + PROJECT_ID + \"aip-\" + UUID"
]
},
{
@@ -509,7 +518,8 @@
},
"outputs": [],
"source": [
"import google.cloud.aiplatform as aip"
"import google.cloud.aiplatform as aip\n",
"from google.cloud.aiplatform.vizier import Study, pyvizier"
]
},
{
@@ -534,35 +544,6 @@
"aip.init(project=PROJECT_ID, staging_bucket=BUCKET_URI)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "aip_constants"
},
"source": [
"#### Vertex AI constants\n",
"\n",
"Setup up the following constants for Vertex AI:\n",
"\n",
"- `API_ENDPOINT`: The Vertex AI API service endpoint for `Dataset`, `Model`, `Job`, `Pipeline` and `Endpoint` services.\n",
"- `PARENT`: The Vertex AI location root path for `Dataset`, `Model`, `Job`, `Pipeline` and `Endpoint` resources."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "aip_constants"
},
"outputs": [],
"source": [
"# API service endpoint\n",
"API_ENDPOINT = \"{}-aiplatform.googleapis.com\".format(REGION)\n",
"\n",
"# Vertex location root path for your dataset, model and endpoint resources\n",
"PARENT = \"projects/\" + PROJECT_ID + \"/locations/\" + REGION"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -626,7 +607,7 @@
"if os.getenv(\"IS_TESTING_TF\"):\n",
" TF = os.getenv(\"IS_TESTING_TF\")\n",
"else:\n",
" TF = \"2.1\".replace(\".\", \"-\")\n",
" TF = \"2.5\".replace(\".\", \"-\")\n",
"\n",
"if TF[0] == \"2\":\n",
" if TRAIN_GPU:\n",
@@ -1031,7 +1012,7 @@
},
"outputs": [],
"source": [
"JOB_NAME = \"custom_job_\" + TIMESTAMP\n",
"JOB_NAME = \"custom_job_\" + UUID\n",
"MODEL_DIR = \"{}/{}\".format(BUCKET_URI, JOB_NAME)\n",
"\n",
"if not TRAIN_NGPU or TRAIN_NGPU < 2:\n",
@@ -1094,9 +1075,7 @@
},
"outputs": [],
"source": [
"job = aip.CustomJob(\n",
" display_name=\"boston_\" + TIMESTAMP, worker_pool_specs=worker_pool_spec\n",
")"
"job = aip.CustomJob(display_name=\"boston_\" + UUID, worker_pool_specs=worker_pool_spec)"
]
},
{
@@ -1128,7 +1107,7 @@
"from google.cloud.aiplatform import hyperparameter_tuning as hpt\n",
"\n",
"hpt_job = aip.HyperparameterTuningJob(\n",
" display_name=\"boston_\" + TIMESTAMP,\n",
" display_name=\"boston_\" + UUID,\n",
" custom_job=job,\n",
" metric_spec={\n",
" \"val_loss\": \"minimize\",\n",
@@ -1309,7 +1288,7 @@
"outputs": [],
"source": [
"job = aip.CustomJob(\n",
" display_name=\"boston_\" + TIMESTAMP,\n",
" display_name=\"boston_\" + UUID,\n",
" worker_pool_specs=worker_pool_spec,\n",
" base_output_dir=MODEL_DIR,\n",
")"
@@ -1344,7 +1323,7 @@
"from google.cloud.aiplatform import hyperparameter_tuning as hpt\n",
"\n",
"hpt_job = aip.HyperparameterTuningJob(\n",
" display_name=\"boston_\" + TIMESTAMP,\n",
" display_name=\"boston_\" + UUID,\n",
" custom_job=job,\n",
" metric_spec={\n",
" \"val_loss\": \"minimize\",\n",
@@ -1513,22 +1492,25 @@
"id": "vizier_client"
},
"source": [
"### Create Vizier client\n",
"### Specify the algorithm used to suggest trial parameters\n",
"\n",
"Create a client side connection to the Vertex AI Vizier service."
"First, you create a `StudyConfig`, and specify the algorithm to suggest the next trial.\n",
"\n",
" GRID_SEARCH: grid search\n",
" RANDOM_SEARCH: random search\n",
" ALGORIGTHM_UNSPECIFIED: Vizier bayesian algorithm"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "vizier_client"
"id": "d7dd26490358"
},
"outputs": [],
"source": [
"vizier_client = aip.gapic.VizierServiceClient(\n",
" client_options=dict(api_endpoint=API_ENDPOINT)\n",
")"
"problem = pyvizier.StudyConfig()\n",
"problem.algorithm = pyvizier.Algorithm.RANDOM_SEARCH"
]
},
{
@@ -1543,7 +1525,15 @@
"\n",
"In the following example, the goal is to maximize y = x^2 with x in the range of \\[-10. 10\\]. This example has only one parameter and uses an easily calculated function to help demonstrate how to use Vizier.\n",
"\n",
"First, you will create the study using the `create_study()` method."
"First, you specify the metrics to minimize or maximize in the study as a list to the property `metric_information`. Then you specify the parameters to the study using the `add_XXX_params()` method for the corresponding data type:\n",
"\n",
" - add_bool_param\n",
" - add_categorical_param\n",
" - add_discrete_param\n",
" - add_float_param\n",
" - add_int_param\n",
"\n",
"You create the study using the `create_or_load()` method."
]
},
{
@@ -1554,28 +1544,19 @@
},
"outputs": [],
"source": [
"STUDY_DISPLAY_NAME = \"xpow2\" + TIMESTAMP\n",
"STUDY_DISPLAY_NAME = \"xpow2\" + UUID\n",
"\n",
"param_x = {\n",
" \"parameter_id\": \"x\",\n",
" \"double_value_spec\": {\"min_value\": -10.0, \"max_value\": 10.0},\n",
"}\n",
"problem.metric_information.append(\n",
" pyvizier.MetricInformation(name=\"y\", goal=pyvizier.ObjectiveMetricGoal.MAXIMIZE)\n",
")\n",
"\n",
"metric_y = {\"metric_id\": \"y\", \"goal\": \"MAXIMIZE\"}\n",
"params = problem.search_space.select_root()\n",
"params.add_float_param(\"x\", -10.0, 10.0, scale_type=pyvizier.ScaleType.LINEAR)\n",
"\n",
"study = {\n",
" \"display_name\": STUDY_DISPLAY_NAME,\n",
" \"study_spec\": {\n",
" \"algorithm\": \"RANDOM_SEARCH\",\n",
" \"parameters\": [param_x],\n",
" \"metrics\": [metric_y],\n",
" },\n",
"}\n",
"study = Study.create_or_load(display_name=STUDY_DISPLAY_NAME, problem=problem)\n",
"\n",
"study = vizier_client.create_study(parent=PARENT, study=study)\n",
"STUDY_NAME = study.name\n",
"\n",
"print(STUDY_NAME)"
"print(\"STUDY_NAME: {}\".format(STUDY_NAME))"
]
},
{
@@ -1586,9 +1567,7 @@
"source": [
"### Get Vizier study\n",
"\n",
"You can get a study using the method `get_study()`, with the following key/value pairs:\n",
"\n",
"- `name`: The name of the study."
"You can get a study using the method `list()`."
]
},
{
@@ -1599,9 +1578,8 @@
},
"outputs": [],
"source": [
"study = vizier_client.get_study({\"name\": STUDY_NAME})\n",
"\n",
"print(study)"
"studies = Study.list()\n",
"print(studies[0].gca_resource)"
]
},
{
@@ -1612,11 +1590,9 @@
"source": [
"### Get suggested trial\n",
"\n",
"Next, query the Vizier service for a suggested trial(s) using the method `suggest_trials`, with the following key/value pairs:\n",
"Next, query the Vizier service for a suggested trial(s) using the method `suggest()`, with the following key/value pairs:\n",
"\n",
"- `parent`: The name of the study.\n",
"- `suggestion_count`: The number of trials to suggest.\n",
"- `client_id`: blah\n",
"- `count`: The number of trials to suggest.\n",
"\n",
"This call is a long running operation. The method `result()` from the response object will wait until the call has completed."
]
@@ -1625,18 +1601,13 @@
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "vizier_suggest_trial"
"id": "11ff2c4562cb"
},
"outputs": [],
"source": [
"SUGGEST_COUNT = 1\n",
"CLIENT_ID = \"1001\"\n",
"\n",
"response = vizier_client.suggest_trials(\n",
" {\"parent\": STUDY_NAME, \"suggestion_count\": SUGGEST_COUNT, \"client_id\": CLIENT_ID}\n",
")\n",
"\n",
"trials = response.result().trials\n",
"trials = study.suggest(count=SUGGEST_COUNT)\n",
"\n",
"print(trials)\n",
"\n",
@@ -1679,12 +1650,10 @@
"source": [
"RESULT = 0.01\n",
"\n",
"vizier_client.add_trial_measurement(\n",
" {\n",
" \"trial_name\": TRIAL_ID,\n",
" \"measurement\": {\"metrics\": [{\"metric_id\": \"y\", \"value\": RESULT}]},\n",
" }\n",
")"
"measurement = pyvizier.Measurement()\n",
"measurement.metrics[\"y\"] = RESULT\n",
"\n",
"trials[0].add_measurement(measurement)"
]
},
{
@@ -1695,7 +1664,7 @@
"source": [
"### Delete the Vizier study\n",
"\n",
"The method 'delete_study()' will delete the study."
"The method 'delete()' will delete the study."
]
},
{
@@ -1706,7 +1675,7 @@
},
"outputs": [],
"source": [
"vizier_client.delete_study({\"name\": STUDY_NAME})"
"study.delete()"
]
},
{
@@ -73,7 +73,7 @@
"source": [
"### Objective\n",
"\n",
"In this tutorial, you learn how to use Python and Cloud logging awhen training with `Vertex AI`.\n",
"In this tutorial, you learn how to use Python and Cloud logging when training with `Vertex AI`.\n",
"\n",
"This tutorial uses the following Google Cloud ML services:\n",
"\n",
@@ -116,7 +116,7 @@
"\n",
"The dataset used for this tutorial is the [Patent PDF Samples with Extracted Structured Data](https://console.cloud.google.com/marketplace/product/global-patents/labeled-patents) from Google Public Data Sets. \n",
"\n",
"This dataset includes data extracted from over 300 patent documents issued in the US and EU. The dataset includes links to Google Cloud Storage blobs for the first page of each patent, in addition to a number of extracted entities. \n",
"This dataset includes data extracted from over 300 patent documents issued in the US and EU. The dataset includes links to Cloud Storage blobs for the first page of each patent, in addition to a number of extracted entities. \n",
"\n",
"The data is published as a [public dataset](https://cloud.google.com/bigquery/public-data) on `BigQuery`."
]
@@ -39,18 +39,15 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage2/mlops_experimentation.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/stage2/mlops_experimentation.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
" </td>\n",
"</table>\n",
"<br/><br/><br/>"
"<br/><br/><br/>\n",
"\n",
"*Note: This notebook is not supported for execution in Colab*"
]
},
{
@@ -216,20 +213,18 @@
"\n",
"ONCE_ONLY = False\n",
"if ONCE_ONLY:\n",
" ! pip3 install -U tensorflow==2.5 $USER_FLAG -q\n",
" ! pip3 install -U tensorflow-data-validation==1.2 $USER_FLAG -q\n",
" ! pip3 install -U tensorflow-transform==1.2 $USER_FLAG -q\n",
" ! pip3 install -U tensorflow-io==0.18 $USER_FLAG -q\n",
" ! pip3 install --upgrade google-cloud-aiplatform[tensorboard] $USER_FLAG -q\n",
" ! pip3 install --upgrade google-cloud-pipeline-components $USER_FLAG -q\n",
" ! pip3 install --upgrade google-cloud-bigquery $USER_FLAG -q\n",
" ! pip3 install --upgrade google-cloud-logging $USER_FLAG -q\n",
" ! pip3 install --upgrade apache-beam[gcp] $USER_FLAG -q\n",
" ! pip3 install --upgrade pyarrow $USER_FLAG -q\n",
" ! pip3 install --upgrade cloudml-hypertune $USER_FLAG -q\n",
" ! pip3 install --upgrade kfp $USER_FLAG -q\n",
" ! pip3 install --upgrade torchvision $USER_FLAG -q\n",
" ! pip3 install --upgrade rpy2 $USER_FLAG -q"
" ! pip3 install -U {USER_FLAG} -q tensorflow==2.5 \\\n",
" tensorflow-data-validation==1.2 \\\n",
" tensorflow-transform==1.2 \\\n",
" tensorflow-io==0.18 \n",
" \n",
" ! pip3 install --upgrade {USER_FLAG} -q google-cloud-aiplatform[tensorboard] \\\n",
" google-cloud-pipeline-components \\\n",
" google-cloud-bigquery \\\n",
" google-cloud-logging \\\n",
" apache-beam[gcp] \\\n",
" pyarrow \\\n",
" cloudml-hypertune"
]
},
{
@@ -444,12 +439,11 @@
"import sys\n",
"\n",
"# If on Vertex AI Workbench, then don't execute this code\n",
"IS_COLAB = False\n",
"IS_COLAB = \"google.colab\" in sys.modules\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\") and not os.getenv(\n",
" \"DL_ANACONDA_HOME\"\n",
"):\n",
" if \"google.colab\" in sys.modules:\n",
" IS_COLAB = True\n",
" from google.colab import auth as google_auth\n",
"\n",
" google_auth.authenticate_user()\n",
+160 -147
View File
@@ -33,10 +33,144 @@ The third stage in MLOps is formalization to develop an automated pipeline proce
### Get Started
[Get started with AutoML Tabular Pipeline Workflows](get_started_with_automl_tabular_pipeline_workflow.ipynb)
```
[Get started with Vertex AI Model Registry](community/ml_ops/stage3/get_started_with_model_registry.ipynb)
In this tutorial, you learn how to use `Vertex AI Model Registry` to create and register multiple versions of a model.
The steps performed include:
- Create and register a first version of a model to `Vertex AI Model Registry`.
- Create and register a second version of a model to `Vertex AI Model Registry`.
- Updating the model version which is the default (blessed).
- Deleting a model version.
- Retraining the next model version.
[Get started with Dataflow pipeline components](community/ml_ops/stage3/get_started_with_dataflow_pipeline_components.ipynb)
In this tutorial, you learn how to use prebuilt `Google Cloud Pipeline Components` for `Dataflow`.
The steps performed include:
- Build an Apache Beam data pipeline.
- Encapsulate the Apache Beam data pipeline with a Dataflow component in a Vertex AI pipeline.
- Execute a Vertex AI pipeline.
[Get started with Apache Airflow and Vertex AI Pipelines](community/ml_ops/stage3/get_started_with_airflow_and_vertex_pipelines.ipynb)
In this tutorial, you learn how to use Apache Airflow with `Vertex AI Pipelines`.
The steps performed include:
- Create Cloud Composer environment.
- Upload Airflow DAG to Composer environment that performs data processing -- i.e., creates a BigQuery table from a CSV file.
- Create a `Vertex AI Pipeline` that triggers the Airflow DAG.
- Execute the `Vertex AI Pipeline`.
[Get started with Kubeflow Pipelines](community/ml_ops/stage3/get_started_with_kubeflow_pipelines.ipynb)
In this tutorial, you learn how to use `Kubeflow Pipelines`(KFP).
The steps performed include:
- Building KFP lightweight Python function components.
- Assembling and compiling KFP components into a pipeline.
- Executing a KFP pipeline using Vertex AI Pipelines.
- Loading component and pipeline definitions from a source code repository.
- Building sequential, parallel, multiple output components.
- Building control flow into pipelines.
[Get started with Vertex AI custom training pipeline components](community/ml_ops/stage3/get_started_with_custom_training_pipeline_components.ipynb)
In this tutorial, you learn how to use prebuilt `Google Cloud Pipeline Components` for `Vertex AI Training`.
The steps performed include:
- Construct a pipeline for:
- Training a Vertex AI custom trained model.
- Test the serving binary with a batch prediction job.
- Deploying a Vertex AI custom trained model.
- Execute a Vertex AI pipeline.
- Construct a pipeline for:
- Construct a custom training component.
- Convert custom training component to CustomTrainingJobOp.
- Training a Vertex AI custom trained model using the converted component.
- Deploying a Vertex AI custom trained model.
- Execute a Vertex AI pipeline.
[Get started with Dataproc Serverless pipeline components](community/ml_ops/stage3/get_started_with_dataproc_serverless_pipeline_components.ipynb)
In this tutorial, you learn how to use prebuilt `Google Cloud Pipeline Components` for `Dataproc Serverless` service.
The steps performed include:
- `DataprocPySparkBatchOp` for running PySpark batch workloads.
- `DataprocSparkBatchOp` for running Spark batch workloads.
- `DataprocSparkSqlBatchOp` for running Spark SQL batch workloads.
- `DataprocSparkRBatchOp` for running SparkR batch workloads.
[Get started with Vertex AI Hyperparameter Tuning pipeline components](community/ml_ops/stage3/get_started_with_hpt_pipeline_components.ipynb)
In this tutorial, you learn how to use prebuilt `Google Cloud Pipeline Components` for `Vertex AI Hyperparameter Tuning`.
The steps performed include:
- Construct a pipeline for:
- Hyperparameter tune/train a custom model.
- Retrieve the tuned hyperparameter values and metrics to optimize.
- If the metrics exceed a specified threshold.
- Get the location of the model artifacts for the best tuned model.
- Upload the model artifacts to a `Vertex AI Model` resource.
- Execute a Vertex AI pipeline.
[Get started with machine management for Vertex AI Pipelines](community/ml_ops/stage3/get_started_with_machine_management.ipynb)
In this tutorial, you convert a self-contained custom training component into a `Vertex AI CustomJob`, whereby:
- The training job and artifacts are trackable.
- Set machine resources, such as machine-type, cpu/gpu, memory, disk, etc.
The steps performed in this tutorial include:
- Create a custom component with a self-contained training job.
- Execute pipeline using component-level settings for machine resources
- Convert the self-contained training component into a `Vertex AI CustomJob`.
- Execute pipeline using customjob-level settings for machine resources
[Get started with TFX pipelines](community/ml_ops/stage3/get_started_with_tfx_pipeline.ipynb)
In this tutorial, you learn how to use TensorFlow Extended (TFX) with `Vertex AI Pipelines`.
The steps performed include:
- Create a TFX e2e pipeline.
- Execute the pipeline locally.
- Execute the pipeline on Google Cloud using `Vertex AI Training`
- Execute the pipeline using `Vertex AI Pipelines`.
[Get started with BigQuery ML pipeline components](community/ml_ops/stage3/get_started_with_bqml_pipeline_components.ipynb)
In this tutorial, you learn how to use prebuilt `Google Cloud Pipeline Components` for `BigQuery ML`.
The steps performed include:
- Construct a pipeline for:
- Training BigQuery ML model.
- Evaluating the BigQuery ML model.
- Exporting the BigQuery ML model.
- Importing the BigQuery ML model to a Vertex AI model.
- Deploy the Vertex AI model.
- Execute a Vertex AI pipeline.
- Make a prediction with the deployed Vertex AI model.
[Get started with AutoML tabular pipeline workflows](community/ml_ops/stage3/get_started_with_automl_tabular_pipeline_workflow.ipynb)
In this tutorial, you learn how to use `AutoML Tabular Pipeline Template` for training, exporting and tuning an AutoML tabular model.
The steps performed include:
- Define training specification.
- Dataset specification
- Hyperparameter overide specification
@@ -49,162 +183,41 @@ The steps performed include:
- Deploy exported OSS TF model.
- Make a prediction.
```
[Get started with rapid prototyping with AutoML and BigQuery ML](community/ml_ops/stage3/get_started_with_rapid_prototyping_bqml_automl.ipynb)
[Get started with Vertex AI Model Registry](get_started_with_model_registry.ipynb)
In this tutorial, you learn how to use `Vertex AI Predictions` for rapid prototyping a model.
```
The steps performed include:
- Create and register a first version of a model to `Vertex AI Model Registry`.
- Create and register a second version of a model to `Vertex AI Model Registry`.
- Updating the model version which is the default (blessed).
- Deleting a model version.
- Retraining the next model version.
```
[Get started with Dataproc serverless pipeline components](get_started_with_dataproc_serverless_pipeline_components.ipynb)
```
The steps performed include:
- `DataprocPySparkBatchOp` for running PySpark batch workloads.
- `DataprocSparkBatchOp` for running Spark batch workloads.
- `DataprocSparkSqlBatchOp` for running Spark SQL batch workloads.
- `DataprocSparkRBatchOp` for running SparkR batch workloads.
```
[Get started with TFX pipelines](get_started_with_tfx_pipeline.ipynb)
```
The steps performed include:
- Create a TFX e2e pipeline.
- Execute the pipeline locally.
- Execute the pipeline on Google Cloud using `Vertex AI Training`
- Execute the pipeline using `Vertex AI Pipelines`.
```
[Get started with Vertex AI Hyperparameter Tuning pipeline components](get_started_with_hpt_pipeline_components.ipynb)
```
The steps performed include:
- Construct a pipeline for:
- Hyperparameter tune/train a custom model.
- Retrieve the tuned hyperparameter values and metrics to optimize.
- If the metrics exceed a specified threshold.
- Get the location of the model artifacts for the best tuned model.
- Upload the model artifacts to a `Vertex AI Model` resource.
- Execute a Vertex AI pipeline.
```
[Get started with Apache Airflow and Vertex AI Pipelines](get_started_with_airflow_and_vertex_pipelines.ipynb)
```
The steps performed include:
- Create Cloud Composer environment.
- Upload Airflow DAG to Composer environment that performs data processing -- i.e., creates a BigQuery table from a CSV file.
- Create a `Vertex AI Pipeline` that triggers the Airflow DAG.
- Execute the `Vertex AI Pipeline`.
```
[Get started with Vertex AI custom training pipeline components](get_started_with_custom_training_pipeline_components.ipynb)
```
The steps performed include:
- Construct a pipeline for:
- Training a Vertex AI custom trained model.
- Test the serving binary with a batch prediction job.
- Deploying a Vertex AI custom trained model.
- Execute a Vertex AI pipeline.
- Construct a pipeline for:
- Construct a custom training component.
- Convert custom training component to CustomTrainingJobOp.
- Training a Vertex AI custom trained model using the converted component.
- Deploying a Vertex AI custom trained model.
- Execute a Vertex AI pipeline.
```
[Get started with AutoML pipeline components](get_started_with_automl_pipeline_components.ipynb)
```
The steps performed include:
- Construct a pipeline for:
- Training a Vertex AI AutoML trained model.
- Test the serving binary with a batch prediction job.
- Deploying a Vertex AI AutoML trained model.
- Execute a Vertex AI pipeline.
```
[Get started with Kubeflow pipelines](get_started_with_kubeflow_pipelines.ipynb)
```
The steps performed include:
- Building KFP lightweight Python function components.
- Assembling and compiling KFP components into a pipeline.
- Executing a KFP pipeline using Vertex AI Pipelines.
- Loading component and pipeline definitions from a source code repository.
- Building sequential, parallel, multiple output components.
- Building control flow into pipelines.
```
[Get started with machine management for Vertex AI Pipelines](get_started_with_machine_management.ipynb)
```
The steps performed in this tutorial include:
- Create a custom component with a self-contained training job.
- Execute pipeline using component-level settings for machine resources
- Convert the self-contained training component into a `Vertex AI CustomJob`.
- Execute pipeline using customjob-level settings for machine resources
```
[Get started with BigQuery and TFDV pipeline components](get_started_with_bq_tfdv_pipeline_components.ipynb)
```
The steps performed include:
- Build and execute a pipeline component for creating a Vertex AI Tabular Dataset from a BigQuery table.
- Build and execute a pipeline component for generating TFDV statistics and schema from a Vertex AI Tabular Dataset.
- Execute a Vertex AI pipeline.
```
[Get started with Dataflow pipeline components](get_started_with_dataflow_pipeline_components.ipynb)
```
The steps performed include:
- Build an Apache Beam data pipeline.
- Encapsulate the Apache Beam data pipeline with a Dataflow component in a Vertex AI pipeline.
- Execute a Vertex AI pipeline.
```
[Get started with BigQuery ML pipeline components](get_started_with_bqml_pipeline_components.ipynb)
```
The steps performed include:
- Construct a pipeline for:
- Training BigQuery ML model.
- Evaluating the BigQuery ML model.
- Exporting the BigQuery ML model.
- Importing the BigQuery ML model to a Vertex AI model.
- Deploy the Vertex AI model.
- Execute a Vertex AI pipeline.
- Make a prediction with the deployed Vertex AI model.
```
[Get started with rapid prototyping with AutoML and BigQuery ML](get_started_with_rapid_prototyping_bqml_automl.ipynb)
```
The steps performed include:
- Creating a BigQuery and Vertex AI training dataset.
- Training a BigQuery ML and AutoML model.
- Extracting evaluation metrics from the BigQueryML and AutoML models.
- Selecting the best trained model.
- Deploying the best trained model.
- Testing the deployed model infrastructure.
```
[Get started with AutoML pipeline components](community/ml_ops/stage3/get_started_with_automl_pipeline_components.ipynb)
In this tutorial, you learn how to use prebuilt `Google Cloud Pipeline Components` for `Vertex AI AutoML`.
The steps performed include:
- Construct a pipeline for:
- Training a Vertex AI AutoML trained model.
- Test the serving binary with a batch prediction job.
- Deploying a Vertex AI AutoML trained model.
- Execute a Vertex AI pipeline.
[Get started with BigQuery and TFDV pipeline components](community/ml_ops/stage3/get_started_with_bq_tfdv_pipeline_components.ipynb)
In this tutorial, you learn how to use build lightweight Python components for BigQuery and TensorFlow Data Validation.
The steps performed include:
- Build and execute a pipeline component for creating a Vertex AI Tabular Dataset from a BigQuery table.
- Build and execute a pipeline component for generating TFDV statistics and schema from a Vertex AI Tabular Dataset.
- Execute a Vertex AI pipeline.
### E2E Stage Example
@@ -568,7 +568,6 @@
},
"outputs": [],
"source": [
"import kfp\n",
"from google.cloud import aiplatform\n",
"from kfp import dsl\n",
"from kfp.v2 import compiler\n",
@@ -1000,11 +999,7 @@
" from google.auth.transport.requests import Request\n",
" from google.oauth2 import id_token\n",
"\n",
" IAM_SCOPE = \"https://www.googleapis.com/auth/iam\"\n",
" OAUTH_TOKEN_URI = \"https://www.googleapis.com/oauth2/v4/token\"\n",
"\n",
" data = '{\"replace_microseconds\":\"false\"}'\n",
" context = None\n",
"\n",
" \"\"\"Makes a POST request to the Composer DAG Trigger API\n",
"\n",
@@ -44,7 +44,7 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/notebooks/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage3/get_started_with_automl_tabular_pipeline_workflow.ipynb\">\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/stage3/get_started_with_automl_tabular_pipeline_workflow.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
@@ -39,9 +39,9 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/ai/platform/notebooks/deploy-notebook?download_url=https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage3/get_started_with_dataflow_pipeline_components.ipynb\">\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage3/get_started_with_dataflow_pipeline_components.ipynb\">\n",
"<img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> \n",
" Colab logo Run in Colab\n",
" Run in Colab\n",
" </a>\n",
" </td>\n",
" <td>\n",
@@ -81,7 +81,7 @@
"source": [
"### Objective\n",
"\n",
"In this tutorial, you convert a self-contained custom training component into a `Vertex AI CustomJob`, whereby:\n",
"In this tutorial, you learn how to convert a self-contained custom training component into a `Vertex AI CustomJob`, whereby:\n",
"\n",
" - The training job and artifacts are trackable.\n",
" - Set machine resources, such as machine-type, cpu/gpu, memory, disk, etc.\n",
@@ -569,7 +569,6 @@
"source": [
"import json\n",
"\n",
"import numpy as np\n",
"from google.cloud import aiplatform\n",
"from google_cloud_pipeline_components.v1.custom_job import \\\n",
" create_custom_training_job_from_component\n",
@@ -797,7 +796,6 @@
" epochs: int,\n",
") -> str:\n",
" import numpy as np\n",
" import tensorflow as tf\n",
"\n",
" def get_data():\n",
" from tensorflow.keras.datasets import mnist\n",
@@ -904,7 +902,7 @@
" },\n",
" ).after(training_job_task)\n",
"\n",
" model_upload = ModelUploadOp(\n",
" _ = ModelUploadOp(\n",
" project=project,\n",
" display_name=\"mnist_model\",\n",
" unmanaged_container_model=import_unmanaged_model_task.outputs[\"artifact\"],\n",
@@ -1180,7 +1178,7 @@
" },\n",
" ).after(training_job_task)\n",
"\n",
" model_upload = ModelUploadOp(\n",
" _ = ModelUploadOp(\n",
" project=project,\n",
" display_name=\"mnist_model\",\n",
" unmanaged_container_model=import_unmanaged_model_task.outputs[\"artifact\"],\n",
@@ -60,7 +60,7 @@
"source": [
"## Overview\n",
"\n",
"This tutorial demonstrates how to use Vertex AI Pipelines to rapid prototype a model using both AutoML and BQML, do an evaluation comparison, for a baseline, before progressing to a custom model.\n",
"This tutorial demonstrates how to use Vertex AI Pipelines to rapid prototype a model using both AutoML and BigQuery ML, do an evaluation comparison, for a baseline, before progressing to a custom model.\n",
"\n",
"<img src=\"https://storage.googleapis.com/rafacarv-public-bucket-do-not-delete/abalone/automl_and_bqml.png\" />"
]
@@ -834,7 +834,7 @@
"source": [
"### Create component: Split the dataset into train, test and eval\n",
"\n",
"For this pipeline, you set aside a portion of the dataset for test evaluation. While both AutoML and BQML will automatically split then datasets, in this example you will explicitly split the datasets into:\n",
"For this pipeline, you set aside a portion of the dataset for test evaluation. While both AutoML and BigQuery ML will automatically split then datasets, in this example you will explicitly split the datasets into:\n",
"\n",
"- TRAIN\n",
"- EVALUATE\n",
@@ -1000,11 +1000,11 @@
"- Construct the CREATE MODEL query using a static Python function `_create_model_query()`, which runs in the context of the pipeline.\n",
"- Call the prebuilt component `BigQueryCreateModelOp`, with the constructed query, to train the BigQuery ML model.\n",
"\n",
"For this tutorial, you use a simple linear regression model on BQML. \n",
"For this tutorial, you use a simple linear regression model on BigQuery ML. \n",
"\n",
"For a full list of models supported by BQML, look here: [End-to-end user journey for each model](https://cloud.google.com/bigquery-ml/docs/reference/standard-sql/bigqueryml-syntax-e2e-journey).\n",
"For a full list of models supported by BigQuery ML, look here: [End-to-end user journey for each model](https://cloud.google.com/bigquery-ml/docs/reference/standard-sql/bigqueryml-syntax-e2e-journey).\n",
"\n",
"As pointed out before, BQML and AutoML use different split terminologies, so we do an adaptation of the <i>split_col</i> column directly on the SELECT portion of the CREATE model query:\n",
"As pointed out before, BigQuery ML and AutoML use different split terminologies, so we do an adaptation of the <i>split_col</i> column directly on the SELECT portion of the CREATE model query:\n",
"\n",
"> When the value of DATA_SPLIT_METHOD is 'CUSTOM', the corresponding column should be of type BOOL. The rows with TRUE or NULL values are used as evaluation data. Rows with FALSE values are used as training data."
]
File diff suppressed because it is too large Load Diff
@@ -658,8 +658,6 @@
},
"outputs": [],
"source": [
"from typing import NamedTuple\n",
"\n",
"from kfp import dsl\n",
"from kfp.v2 import compiler\n",
"from kfp.v2.dsl import component"
@@ -1866,7 +1864,7 @@
" exported_tfrec_prefix=exported_tfrec_prefix,\n",
" ).after(dataflow_wait_op)\n",
"\n",
" dataset_op = gcc_aip.TabularDatasetCreateOp(\n",
" _ = gcc_aip.TabularDatasetCreateOp(\n",
" project=project,\n",
" display_name=display_name,\n",
" bq_source=bq_table,\n",
@@ -2285,7 +2283,7 @@
" },\n",
" ).after(model_build_op)\n",
"\n",
" model_upload = ModelUploadOp(\n",
" _ = ModelUploadOp(\n",
" project=project,\n",
" display_name=display_name,\n",
" unmanaged_container_model=import_unmanaged_model_task.outputs[\"artifact\"],\n",
@@ -3205,7 +3203,7 @@
"\n",
" with dsl.Condition(warmup == \"True\", name=\"warmup-model\"):\n",
"\n",
" warmup_op = gcc_aip.CustomPythonPackageTrainingJobRunOp(\n",
" _ = gcc_aip.CustomPythonPackageTrainingJobRunOp(\n",
" project=project,\n",
" display_name=display_name,\n",
" # Warmup Training\n",
@@ -3249,7 +3247,7 @@
" display_name=display_name,\n",
" ).after(training_op)\n",
"\n",
" deploy_op = ModelDeployOp(\n",
" _ = ModelDeployOp(\n",
" model=training_op.outputs[\"model\"],\n",
" endpoint=endpoint_op.outputs[\"endpoint\"],\n",
" dedicated_resources_min_replica_count=1,\n",
+171 -83
View File
@@ -42,104 +42,192 @@ This stage may be done entirely by MLOps. We recommend:
### Get Started
[Get started with Vertex Explainable AI](get_started_with_vertex_xai.ipynb)
```
[Get started with Vertex AI Model Registry](community/ml_ops/stage3/get_started_with_model_registry.ipynb)
In this tutorial, you learn how to use `Vertex AI Model Registry` to create and register multiple versions of a model.
The steps performed include:
- Train an AutoML tabular model.
- Do a batch prediction with explanations.
- Do an online prediction with explanations.
- Train an custom TensorFlow tabular model.
- Manually set configuration metadata.
- Do a batch prediction with explanations.
- Do an online prediction with explanations.
- Automatically set configuration metadata.
- Train an custom TensorFlow image model.
- Manually set configuration metadata.
- Do a batch prediction with explanations.
- Do an online prediction with explanations.
- Train an custom XGBoost tabular model.
- Manually set configuration metadata.
- Do an online prediction with explanations.
- Train an custom scikit-learn tabular model.
- Manually set configuration metadata.
- Do an online prediction with explanations.
```
- Create and register a first version of a model to `Vertex AI Model Registry`.
- Create and register a second version of a model to `Vertex AI Model Registry`.
- Updating the model version which is the default (blessed).
- Deleting a model version.
- Retraining the next model version.
[Get started with Google Artifact Registry](get_started_with_google_artifact_registry.ipynb)
[Get started with Dataflow pipeline components](community/ml_ops/stage3/get_started_with_dataflow_pipeline_components.ipynb)
In this tutorial, you learn how to use prebuilt `Google Cloud Pipeline Components` for `Dataflow`.
```
The steps performed include:
- Creating a private Docker repository.
- Tagging a container image, specific to the private Docker repository.
- Pushing a container image to the private Docker repository.
- Pulling a container image from the private Docker repository.
- Deleting a private Docker repository.
```
[Get started with AutoML training and ML Metadata](get_started_with_vertex_ml_metadata_and_automl.ipynb)
- Build an Apache Beam data pipeline.
- Encapsulate the Apache Beam data pipeline with a Dataflow component in a Vertex AI pipeline.
- Execute a Vertex AI pipeline.
[Get started with Apache Airflow and Vertex AI Pipelines](community/ml_ops/stage3/get_started_with_airflow_and_vertex_pipelines.ipynb)
In this tutorial, you learn how to use Apache Airflow with `Vertex AI Pipelines`.
```
The steps performed include:
- Create a `Dataset` resource.
- Create a corresponding `google.VertexDataset` artifact.
- Train a model using `AutoML`.
- Create a corresponding `google.VertexModel` artifact.
- Create an `Endpoint` resource.
- Create a corresponding `google.Endpoint` artifact.
- Deploy the train model to the `Endpoint`.
- Create an execution and context for the `AutoML` training job and deployment.
- Add the corresponding artifacts and context to the execution.
- Add artifact links (event) to the execution.
- Display the execution graph.
```
[Get started with Vertex AI ML Metadata](get_started_with_vertex_ml_metadata.ipynb)
- Create Cloud Composer environment.
- Upload Airflow DAG to Composer environment that performs data processing -- i.e., creates a BigQuery table from a CSV file.
- Create a `Vertex AI Pipeline` that triggers the Airflow DAG.
- Execute the `Vertex AI Pipeline`.
[Get started with Kubeflow Pipelines](community/ml_ops/stage3/get_started_with_kubeflow_pipelines.ipynb)
In this tutorial, you learn how to use `Kubeflow Pipelines`(KFP).
```
The steps performed include:
- Create a `Metadatastore` resource.
- Create (record)/List an `Artifact`, with artifacts and metadata.
- Create (record)/List an `Execution`.
- Create (record)/List a `Context`.
- Add `Artifact` to `Execution` as events.
- Add `Execution` and `Artifact` into the `Context`
- Delete `Artifact`, `Execution` and `Context`.
- Create and run a `Vertex AI Pipeline` ML workflow to train and deploy a scikit-learn model.
- Create custom pipeline components that generate artifacts and metadata.
- Compare Vertex AI Pipelines runs.
- Trace the lineage for pipeline-generated artifacts.
- Query your pipeline run metadata.
```
[Get started with Vertex AI Model Evaluation](get_started_with_model_evaluation.ipynb)
- Building KFP lightweight Python function components.
- Assembling and compiling KFP components into a pipeline.
- Executing a KFP pipeline using Vertex AI Pipelines.
- Loading component and pipeline definitions from a source code repository.
- Building sequential, parallel, multiple output components.
- Building control flow into pipelines.
[Get started with Vertex AI custom training pipeline components](community/ml_ops/stage3/get_started_with_custom_training_pipeline_components.ipynb)
In this tutorial, you learn how to use prebuilt `Google Cloud Pipeline Components` for `Vertex AI Training`.
```
The steps performed include:
- Evaluate an `AutoML` model.
- Train an `AutoML` image classification model.
- Retrieve the default evaluation metrics from training.
- Do a batch evaluation for a custom evaluation slice.
- Evaluate a BigQuery ML model.
- Train a `BigQuery ML` tabular classification model.
- Retrieve the default evaluation metrics from training.
- Do a batch evaluation for a custom evaluation slice.
- Evaluate a custom model.
- Do a batch evaluation for a custom evaluation slice.
- Add an evaluation to the `Model Registry` for the `Model` resource.
- Evaluate an `AutoML` model.
- Train an `AutoML` image classification model.
- Retrieve the default evaluation metrics from training.
- Do a batch evaluation for a custom evaluation slice.
- Evaluate a BigQuery ML model.
- Train a `BigQuery ML` tabular classification model.
- Retrieve the default evaluation metrics from training.
- Do a batch evaluation for a custom evaluation slice.
- Evaluate a custom model.
- Do a batch evaluation for a custom evaluation slice.
- Add an evaluation to the `Model Registry` for the `Model` resource.
```
- Construct a pipeline for:
- Training a Vertex AI custom trained model.
- Test the serving binary with a batch prediction job.
- Deploying a Vertex AI custom trained model.
- Execute a Vertex AI pipeline.
- Construct a pipeline for:
- Construct a custom training component.
- Convert custom training component to CustomTrainingJobOp.
- Training a Vertex AI custom trained model using the converted component.
- Deploying a Vertex AI custom trained model.
- Execute a Vertex AI pipeline.
[Get started with Dataproc Serverless pipeline components](community/ml_ops/stage3/get_started_with_dataproc_serverless_pipeline_components.ipynb)
In this tutorial, you learn how to use prebuilt `Google Cloud Pipeline Components` for `Dataproc Serverless` service.
The steps performed include:
- `DataprocPySparkBatchOp` for running PySpark batch workloads.
- `DataprocSparkBatchOp` for running Spark batch workloads.
- `DataprocSparkSqlBatchOp` for running Spark SQL batch workloads.
- `DataprocSparkRBatchOp` for running SparkR batch workloads.
[Get started with Vertex AI Hyperparameter Tuning pipeline components](community/ml_ops/stage3/get_started_with_hpt_pipeline_components.ipynb)
In this tutorial, you learn how to use prebuilt `Google Cloud Pipeline Components` for `Vertex AI Hyperparameter Tuning`.
The steps performed include:
- Construct a pipeline for:
- Hyperparameter tune/train a custom model.
- Retrieve the tuned hyperparameter values and metrics to optimize.
- If the metrics exceed a specified threshold.
- Get the location of the model artifacts for the best tuned model.
- Upload the model artifacts to a `Vertex AI Model` resource.
- Execute a Vertex AI pipeline.
[Get started with machine management for Vertex AI Pipelines](community/ml_ops/stage3/get_started_with_machine_management.ipynb)
In this tutorial, you convert a self-contained custom training component into a `Vertex AI CustomJob`, whereby:
- The training job and artifacts are trackable.
- Set machine resources, such as machine-type, cpu/gpu, memory, disk, etc.
The steps performed in this tutorial include:
- Create a custom component with a self-contained training job.
- Execute pipeline using component-level settings for machine resources
- Convert the self-contained training component into a `Vertex AI CustomJob`.
- Execute pipeline using customjob-level settings for machine resources
[Get started with TFX pipelines](community/ml_ops/stage3/get_started_with_tfx_pipeline.ipynb)
In this tutorial, you learn how to use TensorFlow Extended (TFX) with `Vertex AI Pipelines`.
The steps performed include:
- Create a TFX e2e pipeline.
- Execute the pipeline locally.
- Execute the pipeline on Google Cloud using `Vertex AI Training`
- Execute the pipeline using `Vertex AI Pipelines`.
[Get started with BigQuery ML pipeline components](community/ml_ops/stage3/get_started_with_bqml_pipeline_components.ipynb)
In this tutorial, you learn how to use prebuilt `Google Cloud Pipeline Components` for `BigQuery ML`.
The steps performed include:
- Construct a pipeline for:
- Training BigQuery ML model.
- Evaluating the BigQuery ML model.
- Exporting the BigQuery ML model.
- Importing the BigQuery ML model to a Vertex AI model.
- Deploy the Vertex AI model.
- Execute a Vertex AI pipeline.
- Make a prediction with the deployed Vertex AI model.
[Get started with AutoML tabular pipeline workflows](community/ml_ops/stage3/get_started_with_automl_tabular_pipeline_workflow.ipynb)
In this tutorial, you learn how to use `AutoML Tabular Pipeline Template` for training, exporting and tuning an AutoML tabular model.
The steps performed include:
- Define training specification.
- Dataset specification
- Hyperparameter overide specification
- machine specifications
- Construct tabular workflow pipeline.
- Compile and execute pipeline.
- View evaluation metrics artifact.
- Export AutoML model as an OSS TF model.
- Create `Endpoint` resource.
- Deploy exported OSS TF model.
- Make a prediction.
[Get started with rapid prototyping with AutoML and BigQuery ML](community/ml_ops/stage3/get_started_with_rapid_prototyping_bqml_automl.ipynb)
In this tutorial, you learn how to use `Vertex AI Predictions` for rapid prototyping a model.
The steps performed include:
- Creating a BigQuery and Vertex AI training dataset.
- Training a BigQuery ML and AutoML model.
- Extracting evaluation metrics from the BigQueryML and AutoML models.
- Selecting the best trained model.
- Deploying the best trained model.
- Testing the deployed model infrastructure.
[Get started with AutoML pipeline components](community/ml_ops/stage3/get_started_with_automl_pipeline_components.ipynb)
In this tutorial, you learn how to use prebuilt `Google Cloud Pipeline Components` for `Vertex AI AutoML`.
The steps performed include:
- Construct a pipeline for:
- Training a Vertex AI AutoML trained model.
- Test the serving binary with a batch prediction job.
- Deploying a Vertex AI AutoML trained model.
- Execute a Vertex AI pipeline.
[Get started with BigQuery and TFDV pipeline components](community/ml_ops/stage3/get_started_with_bq_tfdv_pipeline_components.ipynb)
In this tutorial, you learn how to use build lightweight Python components for BigQuery and TensorFlow Data Validation.
The steps performed include:
- Build and execute a pipeline component for creating a Vertex AI Tabular Dataset from a BigQuery table.
- Build and execute a pipeline component for generating TFDV statistics and schema from a Vertex AI Tabular Dataset.
- Execute a Vertex AI pipeline.
### E2E Stage Example
Stage 4: Evaluation
@@ -29,7 +29,7 @@
"id": "title:generic,gcp"
},
"source": [
"# E2E ML on GCP: MLOps stage 4 : formalization: get started with Vertex AI ML Metadata\n",
"# E2E ML on GCP: MLOps stage 4 : formalization: get started with Vertex ML Metadata\n",
"\n",
"<table align=\"left\">\n",
" <td>\n",
@@ -62,7 +62,7 @@
"## Overview\n",
"\n",
"\n",
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers stage 4 : formalization: get started with Vertex AI ML Metadata."
"This tutorial demonstrates how to use Vertex AI for E2E MLOps on Google Cloud in production. This tutorial covers stage 4 : formalization: get started with Vertex ML Metadata."
]
},
{
@@ -73,11 +73,11 @@
"source": [
"### Objective\n",
"\n",
"In this tutorial, you learn how to use `Vertex AI ML Metadata`.\n",
"In this tutorial, you learn how to use `Vertex ML Metadata`.\n",
"\n",
"This tutorial uses the following Google Cloud ML services:\n",
"\n",
"- `Vertex AI ML Metadata`\n",
"- `Vertex ML Metadata`\n",
"- `Vertex AI Pipelines`\n",
"\n",
"The steps performed include:\n",
@@ -657,7 +657,7 @@
"source": [
"## Introduction to Vertex AI Metadata\n",
"\n",
"The `Vertex AI ML Metadata` service provides you with the ability to record, and subsequently search and analyze, the artifacts and corresponding metadata produced by your ML workflows. For example, during experimentation one might desire to record the location of the model artifacts, as artifacts, and the training hyperparameters and evaluation metrics as the corresponding metadata.\n",
"The `Vertex ML Metadata` service provides you with the ability to record, and subsequently search and analyze, the artifacts and corresponding metadata produced by your ML workflows. For example, during experimentation one might desire to record the location of the model artifacts, as artifacts, and the training hyperparameters and evaluation metrics as the corresponding metadata.\n",
"\n",
"The service supports recording ML metadata both manually and automatically, with the later occurring when you use Vertex AI Pipelines.\n",
"\n",
@@ -675,9 +675,9 @@
"\n",
"### ML artifact lineage\n",
"\n",
"Vertex AI ML Metadata provides the ability to understand changes in the performance of your machine ML system, and analyze the metadata produced by your ML workflow and the lineage of its artifacts. An artifact's lineage includes all the factors that contributed to its creation, as well as artifacts and metadata that descend from this artifact.\n",
"Vertex ML Metadata provides the ability to understand changes in the performance of your machine ML system, and analyze the metadata produced by your ML workflow and the lineage of its artifacts. An artifact's lineage includes all the factors that contributed to its creation, as well as artifacts and metadata that descend from this artifact.\n",
"\n",
"Learn more about [Introduction to Vertex AI ML Metadata ](https://cloud.google.com/vertex-ai/docs/ml-metadata/introduction)"
"Learn more about [Introduction to Vertex ML Metadata ](https://cloud.google.com/vertex-ai/docs/ml-metadata/introduction)"
]
},
{
+40 -32
View File
@@ -25,10 +25,12 @@ The fifth stage in MLOps is deployment to production of the blessed model, which
### Get Started
[Get started with Vertex AI Endpoints](get_started_with_vertex_endpoints.ipynb)
[Get started with Vertex AI Endpoints](community/ml_ops/stage5/get_started_with_vertex_endpoints.ipynb)
In this tutorial, you learn how to use `Vertex AI Endpoint` resources.
```
The steps performed include:
- Creating an `Endpoint` resource.
- List all `Endpoint` resources.
- List `Endpoint` resources by query filter.
@@ -43,39 +45,13 @@ The steps performed include:
- Delete an `Endpoint` resource.
- In pipeline: Create an `Endpoint` resource and deploy an existing `Model` resource to the `Endpoint` resource.
- In pipeline: Deploy an existing `Model` resource to an existing `Endpoint` resource.
```
[Get started with configuring autoscaling for Vertex AI Endpoint deployment](get_started_with_autoscaling.ipynb)
[Get started with Vertex AI Endpoint and shared VM](community/ml_ops/stage5/get_started_with_vertex_endpoint_and_shared_vm.ipynb)
In this tutorial, you learn how to use deployment resource pools for deploying models. A deployment resouce pool provides one with the ability to co-host more than one model on the same (shared) VM.
```
The steps performed include:
- Download a pretrained image classification model from TensorFlow Hub.
- Upload the pretrained model as a `Model` resource.
- Create an `Endpoint` resource.
- Deploy `Model` resource for no-scaling (single node).
- Deploy `Model` resource for manual scaling.
- Deploy `Model` resource for auto-scaling.
- Fine-tune scaling thresholds for CPU utilization.
- Fine-tune scaling thresholds for GPU utilization.
- Deploy mix of CPU and GPU model instances with auto-scaling to an `Endpoint` resource.
```
[Get started with Vertex AI Private Endpoints](get_started_with_vertex_private_endpoints.ipynb)
```
The steps performed include:
- Creating a `Private Endpoint` resource.
- Configure a VPC peering connection.
- Configuring the serving binary of a `Model` resource for deployment to a `Private Endpoint` resource.
- Deploying a `Model` resource to a `Private Endpoint` resource.
- Send a prediction request to a `Private Endpoint`
```
[Get started with Vertex AI Endpoint and shared VM](get_started_with_vertex_endpoint_and_shared_vm.ipynb)
```
The steps performed include:
- Upload a pre-trained image classification model as a `Model` resource (model A).
- Upload a pre-trained text sentence encoder model as a `Model` resource (model B).
- Create a shared VM deployment resource pool.
@@ -85,4 +61,36 @@ The steps performed include:
- Deploy second model (model B) to second `Endpoint` resource using deployment resource pool.
- Make a prediction request with first deployed model (model A).
- Make a prediction request with second deployed model (model B).
```
[Get started with configuring autoscaling for Vertex AI Endpoint deployment](community/ml_ops/stage5/get_started_with_autoscaling.ipynb)
In this tutorial, you learn how to use fine-tune control auto-scaling configuration when deploying a `Model` resource to an `Endpoint` resource.
The steps performed include:
- Download a pretrained image classification model from TensorFlow Hub.
- Upload the pretrained model as a `Model` resource.
- Create an `Endpoint` resource.
- Deploy `Model` resource for no-scaling (single node).
- Deploy `Model` resource for manual scaling.
- Deploy `Model` resource for auto-scaling.
- Fine-tune scaling thresholds for CPU utilization.
- Fine-tune scaling thresholds for GPU utilization.
- Deploy mix of CPU and GPU model instances with auto-scaling to an `Endpoint` resource.
[Get started with Vertex AI Private Endpoints](community/ml_ops/stage5/get_started_with_vertex_private_endpoints.ipynb)
In this tutorial, you learn how to use `Vertex AI Private Endpoint` resources.
The steps performed include:
- Creating a `Private Endpoint` resource.
- Configure a VPC peering connection.
- Configuring the serving binary of a `Model` resource for deployment to a `Private Endpoint` resource.
- Deploying a `Model` resource to a `Private Endpoint` resource.
- Send a prediction request to a `Private Endpoint`
- Enable two additional APIs: Service Networking and Cloud DNS.
- Add Compute Admin Network role to your (default) service account.
- Issue two gcloud commands to setup the VPC peering for your service account.
- There is *currently* no SDK support yet, so private endpoint is created with GAPIC client and has an extra argument for the peering network.
- To send a request, you can't use SDK/GAPIC since they do a HTTP internet request. Instead, you use curl to send a peer-to-peer request.
@@ -340,7 +340,7 @@
"source": [
"### Authenticate your Google Cloud account\n",
"\n",
"**If you are using Vertex AI Workbench Notebooks**, your environment is already authenticated. Skip this step.\n",
"**If you are using Vertex AI Workbench Notebooks**, your environment is already authenticated. \n",
"\n",
"**If you are using Colab**, run the cell below and follow the instructions when prompted to authenticate your account via oAuth.\n",
"\n",
@@ -376,12 +376,11 @@
"import sys\n",
"\n",
"# If on Vertex AI Workbench, then don't execute this code\n",
"IS_COLAB = False\n",
"IS_COLAB = \"google.colab\" in sys.modules\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\") and not os.getenv(\n",
" \"DL_ANACONDA_HOME\"\n",
"):\n",
" if \"google.colab\" in sys.modules:\n",
" IS_COLAB = True\n",
" from google.colab import auth as google_auth\n",
"\n",
" google_auth.authenticate_user()\n",
@@ -428,8 +427,9 @@
},
"outputs": [],
"source": [
"if BUCKET_URI == \"\" or BUCKET_URI is None or BUCKET_URI == \"gs://[your-bucket-name]\":\n",
" BUCKET_URI = \"gs://\" + PROJECT_ID + \"aip-\" + TIMESTAMP"
"if BUCKET_NAME == \"\" or BUCKET_NAME is None or BUCKET_NAME == \"[your-bucket-name]\":\n",
" BUCKET_NAME = PROJECT_ID + \"aip-\" + TIMESTAMP\n",
" BUCKET_URI = f\"gs://{BUCKET_NAME}\""
]
},
{
@@ -785,7 +785,7 @@
},
"outputs": [],
"source": [
"endpoint.gca_resource"
"print(endpoint.gca_resource)"
]
},
{
@@ -908,7 +908,7 @@
},
"outputs": [],
"source": [
"endpoint.gca_resource.deployed_models[0]"
"print(endpoint.gca_resource.deployed_models[0])"
]
},
{
@@ -1203,12 +1203,10 @@
"\n",
"In this pipeline, you create an `Endpoint` resource, and then you deploy a `Model` resource to the `Endpoint` resource. The `Model` resource to deploy is your existing TFHub model which you previously imported as a `Model` resource. The steps are:\n",
"\n",
"- For pipeline parameters, pass the resource name and resource URI for the existing `Model` resource.\n",
"- Use the `importer_node()` component to create a `VertexModel` pipeline artifact for the model.\n",
"- For pipeline parameters, pass the resource name for the existing `Model` resource.\n",
"- Use the `GetVertexModelOp()` component to create a `VertexModel` pipeline artifact for the model.\n",
"- Create an `Endpoint` resource.\n",
"- Using the `VertexModel` pipeline artifact, deploy the `Model` resource to the `Endpoint` resource.\n",
"\n",
"*Note:* This example currently blocked by internal issue: b/219835305"
"- Using the `VertexModel` pipeline artifact, deploy the `Model` resource to the `Endpoint` resource."
]
},
{
@@ -1225,20 +1223,6 @@
"\n",
"PIPELINE_ROOT = \"{}/pipeline_root/endpoint_example\".format(BUCKET_URI)\n",
"\n",
"# (WORKAROUND b/219835305)\n",
"@component(\n",
" base_image=\"python:3.9\",\n",
" packages_to_install=[\"google-cloud-aiplatform\"],\n",
")\n",
"def return_unmanaged_model(\n",
" serving_image: str, artifact_uri: str, resource_name: str, model: Output[Artifact]\n",
"):\n",
" model.metadata[\"containerSpec\"] = {\"imageUri\": serving_image}\n",
"\n",
" model.metadata[\"resourceName\"] = resource_name\n",
"\n",
" model.uri = artifact_uri\n",
"\n",
"\n",
"@dsl.pipeline(\n",
" name=\"create-endpoint-deploy-model\",\n",
@@ -1246,34 +1230,16 @@
")\n",
"def pipeline(\n",
" display_name: str,\n",
" resource_uri: str,\n",
" resource_name: str,\n",
" # Model properties (WORKAROUND b/219835305)\n",
" serving_image: str,\n",
" artifact_uri: str,\n",
" project: str = PROJECT_ID,\n",
" region: str = REGION,\n",
"):\n",
" from google_cloud_pipeline_components.types import artifact_types\n",
" from google_cloud_pipeline_components.experimental.evaluation import \\\n",
" GetVertexModelOp\n",
" from google_cloud_pipeline_components.v1.endpoint import (EndpointCreateOp,\n",
" ModelDeployOp)\n",
" from kfp.v2.components import importer_node\n",
"\n",
" # Desired sequence: blocked by b/219835305\n",
" \"\"\"\n",
" model = importer_node.importer(\n",
" artifact_uri=resource_uri,\n",
" artifact_class=artifact_types.VertexModel,\n",
" metadata={\"resourceName\": resource_name},\n",
" )\n",
" \"\"\"\n",
"\n",
" # (WORKAROUND b/219835305)\n",
" model = return_unmanaged_model(\n",
" serving_image=serving_image,\n",
" artifact_uri=artifact_uri,\n",
" resource_name=resource_name,\n",
" )\n",
" model = GetVertexModelOp(model_resource_name=resource_name)\n",
"\n",
" endpoint_op = EndpointCreateOp(\n",
" project=project,\n",
@@ -1281,7 +1247,7 @@
" display_name=display_name,\n",
" )\n",
"\n",
" deploy_op = ModelDeployOp(\n",
" _ = ModelDeployOp(\n",
" model=model.outputs[\"model\"],\n",
" endpoint=endpoint_op.outputs[\"endpoint\"],\n",
" dedicated_resources_min_replica_count=1,\n",
@@ -1310,7 +1276,6 @@
"\n",
"- `display_name`: The display name for the generated Vertex AI resources.\n",
"- `resource_name`: The resource name of the existing `Model` resource.\n",
"- `resource_uri`: The resource uri of the existing `Model` resource.\n",
"- `project`: The project ID.\n",
"- `region`: The region."
]
@@ -1323,10 +1288,6 @@
},
"outputs": [],
"source": [
"# Model properties (WORKAROUND b/219835305)\n",
"SERVING_CONTAINER_URI = model.gca_resource.container_spec.image_uri\n",
"ARTIFACT_URI = model.gca_resource.artifact_uri\n",
"\n",
"try:\n",
" pipeline = aip.PipelineJob(\n",
" display_name=\"create-endpoint-deploy-pipeline\",\n",
@@ -1335,11 +1296,6 @@
" parameter_values={\n",
" \"display_name\": \"create_endpoint_and_deploy_model_\" + TIMESTAMP,\n",
" \"resource_name\": model.resource_name,\n",
" \"resource_uri\": \"https://us-central1-aiplatform.googleapis.com/v1/\"\n",
" + model.resource_name,\n",
" # Model properties (WORKAROUND b/219835305)\n",
" \"serving_image\": SERVING_CONTAINER_URI,\n",
" \"artifact_uri\": ARTIFACT_URI,\n",
" \"project\": PROJECT_ID,\n",
" \"region\": REGION,\n",
" },\n",
@@ -1488,7 +1444,7 @@
"\n",
"- For pipeline parameters, pass the resource names and resource URIs for the existing `Model` and `Endpoint` resource.\n",
"- Use the `importer_node()` component to create a `VertexModel` pipeline artifact for the model.\n",
"- Use the `importer_node()` component to create a `VertexEndpoint` pipeline artifact for the endpoint.\n",
"- Use the `GetVertexModelOp()` component to create a `VertexModel` pipeline artifact for the model.\n",
"- Using the `VertexModel` and `VertexEndpoint` pipeline artifacts, deploy the `Model` resource to the `Endpoint` resource.\n",
"\n",
"*Note:* This example currently blocked by internal issue: b/219835305"
@@ -1504,6 +1460,7 @@
"source": [
"PIPELINE_ROOT = \"{}/pipeline_root/endpoint_example_2\".format(BUCKET_URI)\n",
"\n",
"\n",
"# (WORKAROUND b/219835305)\n",
"@component(\n",
" base_image=\"python:3.9\",\n",
@@ -1520,35 +1477,23 @@
")\n",
"def pipeline(\n",
" display_name: str,\n",
" model_resource_uri: str,\n",
" model_resource_name: str,\n",
" endpoint_resource_uri: str,\n",
" endpoint_resource_name: str,\n",
" # Model properties (WORKAROUND b/219835305)\n",
" serving_image: str,\n",
" artifact_uri: str,\n",
" project: str = PROJECT_ID,\n",
" region: str = REGION,\n",
"):\n",
" from google_cloud_pipeline_components.types import artifact_types\n",
" from google_cloud_pipeline_components.experimental.evaluation import \\\n",
" GetVertexModelOp\n",
" from google_cloud_pipeline_components.v1.endpoint import ModelDeployOp\n",
" from kfp.v2.components import importer_node\n",
"\n",
" # Desired sequence: blocked by b/219835305\n",
" \"\"\"\n",
" model = importer_node.importer(\n",
" artifact_uri=resource_uri,\n",
" artifact_class=artifact_types.VertexModel,\n",
" metadata={\"resourceName\": resource_name},\n",
" )\n",
" from kfp.v2.components import importer_node\n",
" from google_cloud_pipeline_components.types import artifact_types\n",
" \"\"\"\n",
"\n",
" # (WORKAROUND b/219835305)\n",
" model = return_unmanaged_model(\n",
" serving_image=serving_image,\n",
" artifact_uri=artifact_uri,\n",
" resource_name=model_resource_name,\n",
" )\n",
" model = GetVertexModelOp(model_resource_name=model_resource_name)\n",
"\n",
" # Desired sequence: blocked by b/219835305\n",
" \"\"\"\n",
@@ -1562,7 +1507,7 @@
" # (WORKAROUND b/219835305)\n",
" endpoint = return_unmanaged_endpoint(resource_name=endpoint_resource_name)\n",
"\n",
" deploy_op = ModelDeployOp(\n",
" _ = ModelDeployOp(\n",
" model=model.outputs[\"model\"],\n",
" endpoint=endpoint.outputs[\"endpoint\"],\n",
" dedicated_resources_min_replica_count=1,\n",
@@ -1591,7 +1536,6 @@
"\n",
"- `display_name`: The display name for the generated Vertex AI resources.\n",
"- `model_resource_name`: The resource name of the existing `Model` resource.\n",
"- `model_resource_uri`: The resource uri of the existing `Model` resource.\n",
"- `endpoint_resource_name`: The resource name of the existing `Endpoint` resource.\n",
"- `endpoint_resource_uri`: The resource uri of the existing `Endpoint` resource.\n",
"- `project`: The project ID.\n",
@@ -1614,14 +1558,9 @@
" parameter_values={\n",
" \"display_name\": \"deploy_model_existing_endpoint_\" + TIMESTAMP,\n",
" \"model_resource_name\": model.resource_name,\n",
" \"model_resource_uri\": \"https://us-central1-aiplatform.googleapis.com/v1/\"\n",
" + model.resource_name,\n",
" \"endpoint_resource_name\": endpoint.resource_name,\n",
" \"endpoint_resource_uri\": \"https://us-central1-aiplatform.googleapis.com/v1/\"\n",
" + endpoint.resource_name,\n",
" # Model properties (WORKAROUND b/219835305)\n",
" \"serving_image\": SERVING_CONTAINER_URI,\n",
" \"artifact_uri\": ARTIFACT_URI,\n",
" \"project\": PROJECT_ID,\n",
" \"region\": REGION,\n",
" },\n",
@@ -385,12 +385,11 @@
"import sys\n",
"\n",
"# If on Vertex AI Workbench, then don't execute this code\n",
"IS_COLAB = False\n",
"IS_COLAB = \"google.colab\" in sys.modules\n",
"if not os.path.exists(\"/opt/deeplearning/metadata/env_version\") and not os.getenv(\n",
" \"DL_ANACONDA_HOME\"\n",
"):\n",
" if \"google.colab\" in sys.modules:\n",
" IS_COLAB = True\n",
" from google.colab import auth as google_auth\n",
"\n",
" google_auth.authenticate_user()\n",
@@ -1068,7 +1067,6 @@
"- `model`: The `Model` resource.\n",
"- `deployed_model_displayed_name`: The human readable name for the deployed model instance.\n",
"- `machine_type`: The machine type for each VM instance.\n",
"- `traffic_split`: Set to `{}` to indicate no traffic split.\n",
"\n",
"Do to the requirements to provision the resource, this may take upto a few minutes."
]
@@ -1085,7 +1083,6 @@
" model=model,\n",
" deployed_model_display_name=\"example_\" + TIMESTAMP,\n",
" machine_type=DEPLOY_COMPUTE,\n",
" traffic_split={}, # no traffic split\n",
")\n",
"\n",
"print(endpoint)"
@@ -1187,62 +1184,6 @@
" f.write(json.dumps({\"instances\": [{serving_input: {\"b64\": b64str}}]}))"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "23e995c35fd6"
},
"source": [
"#### Construct the `Private Endpoint` URI\n",
"\n",
"Next, you construct the URI for the `Private Endpoint`."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "97b248b2efb5"
},
"outputs": [],
"source": [
"endpoint_id = endpoint.resource_name\n",
"\n",
"ENDPOINT_URL = ! gcloud beta ai endpoints describe {endpoint_id} \\\n",
" --region={REGION} \\\n",
" --format=\"value(deployedModels.privateEndpoints.predictHttpUri)\"\n",
"\n",
"private_url = ENDPOINT_URL[1]\n",
"print(private_url)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "27605b5f0c3a"
},
"source": [
"### Make the prediction request using curl\n",
"\n",
"Use `curl` to make the prediction request to the private URI."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "6cb568e6bb49"
},
"outputs": [],
"source": [
"output = ! curl -X POST -d@instances.json $private_url\n",
"\n",
"predictions = output[5]\n",
"print(predictions)\n",
"\n",
"! rm test.jpg instances.json"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -1251,7 +1192,7 @@
"source": [
"### Make the prediction request using SDK\n",
"\n",
"Finally, use the `Vertex AI SDK` to make a prediction request."
"Next, use the `Vertex AI SDK` to make a prediction request."
]
},
{
+242 -123
View File
@@ -30,48 +30,232 @@ This stage may be done entirely by MLOps. We recommend:
### Get Started
[Get started with TensorFlow serving functions with Vertex AI Prediction](get_started_with_tf_serving_function.ipynb)
[Get started with Vertex AI Batch Prediction for AutoML image models](community/ml_ops/stage6/get_started_with_automl_image_model_batch.ipynb)
In this tutorial, you create an AutoML image classification model from a Python script, and then do a batch prediction using the Vertex AI SDK.
```
The steps performed include:
- Create a Vertex `Dataset` resource.
- Train an `AutoML` image classification model.
- Make a batch prediction with JSONL input.
[Get started with Vertex AI Matching Engine and Swivel builtin algorithm](community/ml_ops/stage6/get_started_with_matching_engine_swivel.ipynb)
In this notebook, you learn how to train custom embeddings using Vertex AI Pipelines and subsequently train and deploy a matching engine index using the embeddings.
The steps performed include:
1. Train the `Swivel` algorithm to generate embeddings (encoder) for the dataset.
2. Make example predictions (embeddings) from then trained encoder.
3. Generate embeddings using the trained `Swivel` builtin algorithm.
4. Store embeddings to format supported by `Matching Engine`.
5. Create a `Matching Engine Index` for the embeddings.
6. Deploy the `Matching Engine Index` to a `Index Endpoint`.
7. Make a matching engine prediction request.
[Get started with Vertex AI Matching Engine](community/ml_ops/stage6/get_started_with_matching_engine.ipynb)
In this notebook, you learn how to create Approximate Nearest Neighbor (ANN) Index, query against indexes.
The steps performed include:
- Create ANN Index.
- Create an IndexEndpoint with VPC Network
- Deploy ANN Index
- Perform online query
- Deploy brute force Index.
- Perform calibration between ANN and brute force index.
[Get started with Vertex AI Matching Engine and Two Towers builtin algorithm](community/ml_ops/stage6/get_started_with_matching_engine_twotowers.ipynb)
In this notebook, you learn how to use the `Two-Tower` builtin algorithms for generating embeddings for a dataset, for use with generating an `Matching Engine Index`, with the `Vertex AI Matching Engine` service.
The steps performed include:
1. Train the `Two-Tower` algorithm to generate embeddings (encoder) for the dataset.
2. Hyperparameter tune the trained `Two-Tower` encoder.
3. Make example predictions (embeddings) from then trained encoder.
4. Generate embeddings using the trained `Two-Tower` builtin algorithm.
5. Store embeddings to format supported by `Matching Engine`.
6. Create a `Matching Engine Index` for the embeddings.
7. Deploy the `Matching Engine Index` to a `Index Endpoint`.
8. Make a matching engine prediction request.
[Get started with Vertex AI Batch Prediction for custom tabular models](community/ml_ops/stage6/get_started_with_custom_tabular_model_batch.ipynb)
In this tutorial, you learn how to use `Vertex AI Batch Prediction` with a custom tabular model.
The steps performed include:
- Upload a pretrained tabular model as a `Vertex AI Model` resource.
- Make batch prediction to the `Model` resource, in JSONL format.
- Make batch prediction to the `Model` resource, in CSV format.
- Make batch prediction to the `Model` resource, in BigQuery format.
[Get started with Optimized TensorFlow Enterprise container with Vertex AI Prediction / text models](community/ml_ops/stage6/get_started_with_optimized_tfe_bert.ipynb)
In this tutorial, you learn how to use `TensorFlow Enterprise Optimized` container for TensorFlow models deployed to a `Vertex AI Endpoint` resource.
The steps performed include:
- Download a pretrained BERT model from TensorFlow Hub.
- Fine-tune (transfer learning) the BERT model as a binary classifier.
- Upload the TensorFlow Hub model as a `Vertex AI Model` resource, with standard TensorFlow serving container.
- Upload the TensorFlow Hub model as a `Vertex AI Model` resource, with TensorFlow Enterprise Optimized container
- Create two `Endpoint` resources.
- Deploying both `Model` resources to separate `Endpoint` resources.
- Make the same online prediction requests to both `Model` resource instances deployed to the `Endpoint` resources.
- Compare the prediction accuracy between the two deployed `Model` resources.
- Configuring container settings for fine-tune control of optimizations.
- Create a `Private Endpoint` resource.
- Deploy the `Model` resoure with then `TensorFlow Enterprise Optimized` to the `Private Endpoint` resource.
- Make an online prediction request to the `Private Endpoint` resource.
[Get started with Vertex AI Batch Prediction and Explainable AI for AutoML tabular models](community/ml_ops/stage6/get_started_with_automl_tabular_model_batch.ipynb)
In this tutorial, you create an AutoML tabular binary classification model from a Python script, and then do a batch prediction with Explainable AI using the Vertex AI SDK. You can alternatively create and deploy models using the `gcloud` command-line tool or online using the Cloud Console.
The steps performed include:
- Create a Vertex `Dataset` resource.
- Train an `AutoML` tabular model.
- Make a batch prediction with CSV input.
- Make a batch prediction with JSONL objects input.
- Make a batch prediction with JSONL list input.
- Make a batch prediction with BigQuery table input.
- Make a batch prediction with explanations.
[Get started with re-importing AutoML tabular models](community/ml_ops/stage6/get_started_with_automl_tabular_exported_deploy.ipynb)
In this tutorial, you learn how to use `AutoML Tabular` for re-importing exported model artifacts as a `Model` resource. This is useful for example, if one wants to move the exported model across projects.
The steps performed include:
- Importing a pretrained AutoML tabular exported model artifacts, as a `Model` resource.
- Create an `Endpoint` resource.
- Deploy the `Model` resource to the `Endpoint` resource.
- Make a prediction.
[Get started with Vertex AI Batch Prediction for AutoML text models](community/ml_ops/stage6/get_started_with_automl_text_model_batch.ipynb)
In this tutorial, you learn how to use `Vertex AI Batch Prediction` with a `AutoML` text model.
The steps performed include:
- Create a Vertex `Dataset` resource.
- Train an `AutoML` model.
- Make a batch prediction with JSONL input
[Get started with Vertex AI Prediction for AutoML text models](community/ml_ops/stage6/get_started_with_automl_text_model_online.ipynb)
In this tutorial, you learn how to use `Vertex AI Prediction` with a `AutoML` text model.
The steps performed include:
- Create a Vertex `Dataset` resource.
- Train an `AutoML` model.
- Deploy the model to an `Endpoint` resource.
- Make an online prediction.
[Get started with TensorFlow serving functions with Vertex AI Raw Prediction](community/ml_ops/stage6/get_started_with_raw_predict.ipynb)
In this tutorial, you learn how to use `Vertex AI Raw Prediction` on a `Vertex AI Endpoint` resource.
The steps performed include:
- Download a pretrained tabular classification model artifacts for a TensorFlow 1.x estimator.
- Upload the TensorFlow estimator model as a `Vertex AI Model` resource.
- Creating an `Endpoint` resource.
- Deploying the `Model` resource to an `Endpoint` resource.
- Make an online raw prediction to the `Model` resource instance deployed to the `Endpoint` resource.
[Get started with TensorFlow serving functions with Vertex AI Prediction](community/ml_ops/stage6/get_started_with_tf_serving_function.ipynb)
In this tutorial, you learn how to use `Vertex AI Prediction` on a `Vertex AI Endpoint` resource with a serving function.
The steps performed include:
- Download a pretrained image classification model from TensorFlow Hub.
- Create a serving function to receive compressed image data, and output decomopressed preprocessed data for the model input.
- Upload the TensorFlow Hub model and serving function as a `Vertex AI Model` resource.
- Creating an `Endpoint` resource.
- Deploying the `Model` resource to an `Endpoint` resource.
- Make an online prediction to the `Model` resource instance deployed to the `Endpoint` resource.
```
[Get started with FastAPI with Vertex AI Prediction](get_started_with_fastapi.ipynb)
[Get started with Vertex Explainable AI using custom deployment container](community/ml_ops/stage6/get_started_with_xai_and_custom_server.ipynb)
In this tutorial, you learn to build a custom container to serve a PyTorch model on `Vertex AI Endpoint`.
```
The steps performed include:
- Locally train a Pytorch tabular classifier.
- Locally test the trained model.
- Build a HTTP server using FastAPI.
- Create a custom serving container with the trained model and FastAPI server.
- Locally test the custom serving container.
- Push the custom serving container to the Artifact Registry.
- Upload the custom serving container as a `Model` resource.
- Deploy the `Model` resource to an `Endpoint` resource.
- Make a prediction request to the deployed custom serving container.
- Make an explanation request to the deployed custom serving container.
[Get started with Vertex AI Online Prediction for AutoML image models](community/ml_ops/stage6/get_started_with_automl_image_model_online.ipynb)
In this tutorial, you create an AutoML image classification model from a Python script, and then do an online prediction using the Vertex AI SDK.
The steps performed include:
- Create a Vertex `Dataset` resource.
- Train an `AutoML` image classification model.
- Make an online prediction.
[Get started with FastAPI with Vertex AI Prediction](community/ml_ops/stage6/get_started_with_fastapi.ipynb)
In this tutorial, you learn how to use `Vertex AI Prediction` on a `Vertex AI Endpoint` with a custom serving binary using `FastAPI`.
The steps performed include:
- Download a pretrained image classification model from TensorFlow Hub.
- Create a serving function to receive compressed image data, and output decomopressed preprocessed data for the model input.
- Upload the TensorFlow Hub model and serving function as a `Vertex AI Model` resource.
- Creating an `Endpoint` resource.
- Deploying the `Model` resource to an `Endpoint` resource with `FastAPI` custom serving binary.
- Make an online prediction to the `Model` resource instance deployed to the `Endpoint` resource.
```
[Get started with Nvidia Triton server](get_started_with_nvidia_triton_serving.ipynb)
[Get started with Vertex AI Online Prediction for AutoML tabular models](community/ml_ops/stage6/get_started_with_automl_tabular_model_online.ipynb)
```
The steps performed in this tutorial include:
- Download the model artifacts from TensorFlow Hub.
- Create Triton serving configuration file for the model.
- Construct a custom container, with Triton serving image, for model deployment.
- Upload the model as a `Vertex AI Model` resource.
- Deploy the `Vertex AI Model` resource to a `Vertex AI Endpoint` resource.
- Make a prediction request
- Undeploy the `Model` resource and delete the `Endpoint`
In this tutorial, you create an AutoML tabular binary classification model from a Python script, and then do an online prediction using the Vertex AI SDK.
```
[Get started with Custom Prediction Routine (CPR)](get_started_with_cpr.ipynb)
```
The steps performed include:
- Create a Vertex `Dataset` resource.
- Train an `AutoML` tabular model.
- Deploy the model to an `Endpoint` resource.
- Make an online prediction.
- Make an online prediction with explanations.
[Get started with TensorFlow Serving with Vertex AI Prediction](community/ml_ops/stage6/get_started_with_tf_serving.ipynb)
In this tutorial, you learn how to use `Vertex AI Prediction` on a `Vertex AI Endpoint` resource with `TensorFlow Serving` serving binary.
The steps performed include:
- Download a pretrained image classification model from TensorFlow Hub.
- Create a serving function to receive compressed image data, and output decomopressed preprocessed data for the model input.
- Upload the TensorFlow Hub model and serving function as a `Vertex AI Model` resource.
- Creating an `Endpoint` resource.
- Deploying the `Model` resource to an `Endpoint` resource with `TensorFlow Serving` serving binary.
- Make an online prediction to the `Model` resource instance deployed to the `Endpoint` resource.
- Make a batch prediction to the `Model` resource instance.
[Get started with Custom Prediction Routine (CPR)](community/ml_ops/stage6/get_started_with_cpr.ipynb)
In this tutorial, you learn how to use Custom Prediction Routine (CPR) for `Vertex AI Predictions`.
The steps performed include:
- Write a custom data preprocessor.
- Train the model.
- Build a custom scikit-learn serving container with custom data preprocessing using the Custom Prediction Routine model server.
@@ -93,115 +277,50 @@ The steps performed include:
- Test the model serving container locally.
- Upload and deploy the model serving container to Vertex AI Endpoint.
- Make a prediction request.
```
[Get started with re-importing AutoML tabular models](get_started_automl_tabular_exported_deploy.ipynb)
[Get started with Vertex AI Batch Prediction for custom text models](community/ml_ops/stage6/get_started_with_custom_text_model_batch.ipynb)
In this tutorial, you learn how to use `Vertex AI Batch Prediction` with a custom text model.
```
The steps performed include:
- Importing a pretrained AutoML tabular exported model artifacts, as a `Model` resource.
- Create an `Endpoint` resource.
- Deploy the `Model` resource to the `Endpoint` resource.
- Make a prediction.
```
[Get started with Vertex Explainable AI using custom deployment container](get_started_with_xai_and_custom_server.ipynb)
- Download a pretrained TensorFlow RNN model.
- Upload the pretrained model as a `Vertex AI Model` resource.
- Make batch prediction to the `Model` resource, in JSONL format.
[Get started with NVIDIA Triton server](community/ml_ops/stage6/get_started_with_nvidia_triton_serving.ipynb)
In this tutorial, you deploy a container running Nvidia Triton Server with a `Vertex AI Model` resource to a `Vertex AI Endpoint` for making online predictions.
The steps performed in this tutorial include:
- Download the model artifacts from TensorFlow Hub.
- Create Triton serving configuration file for the model.
- Construct a custom container, with Triton serving image, for model deployment.
- Upload the model as a `Vertex AI Model` resource.
- Deploy the `Vertex AI Model` resource to a `Vertex AI Endpoint` resource.
- Make a prediction request
- Undeploy the `Model` resource and delete the `Endpoint`
[Get started with Vertex AI Batch Prediction for custom image models](community/ml_ops/stage6/get_started_with_custom_image_model_batch.ipynb)
In this tutorial, you learn how to use `Vertex AI Batch Prediction` with a custom image model.
```
The steps performed include:
- Locally train a Pytorch tabular classifier.
- Locally test the trained model.
- Build a HTTP server using FastAPI.
- Create a custom serving container with the trained model and FastAPI server.
- Locally test the custom serving container.
- Push the custom serving container to the Artifact Registry.
- Upload the custom serving container as a `Model` resource.
- Deploy the `Model` resource to an `Endpoint` resource.
- Make a prediction request to the deployed custom serving container.
- Make an explanation request to the deployed custom serving container.
```
[Get started with TensorFlow serving functions with Vertex AI Raw Prediction](get_started_with_raw_predict.ipynb)
```
The steps performed include:
- Download a pretrained tabular classification model artifacts for a TensorFlow 1.x estimator.
- Upload the TensorFlow estimator model as a `Vertex AI Model` resource.
- Creating an `Endpoint` resource.
- Deploying the `Model` resource to an `Endpoint` resource.
- Make an online raw prediction to the `Model` resource instance deployed to the `Endpoint` resource.
```
[Get started with Vertex AI Matching Engine and Two Towers builtin algorithm](get_started_with_matching_engine_twotowers.ipynb)
```
The steps performed include:
1. Train the `Two-Tower` algorithm to generate embeddings (encoder) for the dataset.
2. Hyperparameter tune the trained `Two-Tower` encoder.
3. Make example predictions (embeddings) from then trained encoder.
4. Generate embeddings using the trained `Two-Tower` builtin algorithm.
5. Store embeddings to format supported by `Matching Engine`.
6. Create a `Matching Engine Index` for the embeddings.
7. Deploy the `Matching Engine Index` to a `Index Endpoint`.
8. Make a matching engine prediction request.
```
[Get started with Optimized TensorFlow Enterprise container with Vertex AI Prediction / text models](get_started_with_optimized_tfe_bert.ipynb)
```
The steps performed include:
- Download a pretrained BERT model from TensorFlow Hub.
- Fine-tune (transfer learning) the BERT model as a binary classifier.
- Upload the TensorFlow Hub model as a `Vertex AI Model` resource, with standard TensorFlow serving container.
- Upload the TensorFlow Hub model as a `Vertex AI Model` resource, with TensorFlow Enterprise Optimized container
- Create two `Endpoint` resources.
- Deploying both `Model` resources to separate `Endpoint` resources.
- Make the same online prediction requests to both `Model` resource instances deployed to the `Endpoint` resources.
- Compare the prediction accuracy between the two deployed `Model` resources.
- Configuring container settings for fine-tune control of optimizations.
- Create a `Private Endpoint` resource.
- Deploy the `Model` resoure with then `TensorFlow Enterprise Optimized` to the `Private Endpoint` resource.
- Make an online prediction request to the `Private Endpoint` resource.
```
[Get started with Vertex AI Matching Engine](get_started_with_matching_engine.ipynb)
```
The steps performed include:
- Create ANN Index.
- Create an IndexEndpoint with VPC Network
- Deploy ANN Index
- Perform online query
- Deploy brute force Index.
- Perform calibration between ANN and brute force index.
```
[Get started with Vertex AI Matching Engine and Swivel builtin algorithm](get_started_with_matching_engine_swivel.ipynb)
```
The steps performed include:
1. Train the `Swivel` algorithm to generate embeddings (encoder) for the dataset.
2. Make example predictions (embeddings) from then trained encoder.
3. Generate embeddings using the trained `Swivel` builtin algorithm.
4. Store embeddings to format supported by `Matching Engine`.
5. Create a `Matching Engine Index` for the embeddings.
6. Deploy the `Matching Engine Index` to a `Index Endpoint`.
7. Make a matching engine prediction request.
```
[Get started with TensorFlow serving with Vertex AI Prediction](get_started_with_tf_serving.ipynb)
```
The steps performed include:
- Download a pretrained image classification model from TensorFlow Hub.
- Upload the TensorFlow Hub model as a `Vertex AI Model` resource.
- Make batch prediction with raw (uncompressed) image data to the `Model` resource, in JSONL format.
- Create a serving function to receive compressed image data, and output decomopressed preprocessed data for the model input.
- Upload the TensorFlow Hub model and serving function as a `Vertex AI Model` resource.
- Creating an `Endpoint` resource.
- Deploying the `Model` resource to an `Endpoint` resource with `TensorFlow Serving` serving binary.
- Make an online prediction to the `Model` resource instance deployed to the `Endpoint` resource.
```
- Make batch prediction with compressed image data to the `Model` resource, in File-List format.
[Get started with Vertex AI Batch Prediction for AutoML video models](community/ml_ops/stage6/get_started_with_automl_video_model_batch.ipynb)
In this tutorial, you learn how to use `Vertex AI Batch Prediction` with a `AutoML` video model.
The steps performed include:
- Create a Vertex `Dataset` resource.
- Train an `AutoML` model.
- Make a batch prediction with JSONL input.
@@ -33,18 +33,18 @@
"\n",
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage6/get_started_automl_tabular_exported_deploy.ipynb\">\n",
" <a href=\"https://github.com/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage6/get_started_with_automl_tabular_exported_deploy.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
" View on GitHub\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage6/get_started_automl_tabular_exported_deploy.ipynb\">\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage6/get_started_with_automl_tabular_exported_deploy.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/stage6/get_started_automl_tabular_exported_deploy.ipynb\">\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/stage6/get_started_with_automl_tabular_exported_deploy.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
@@ -866,7 +866,7 @@
],
"metadata": {
"colab": {
"name": "get_started_automl_tabular_exported_deploy.ipynb",
"name": "get_started_with_automl_tabular_exported_deploy.ipynb",
"toc_visible": true
},
"kernelspec": {
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -81,7 +81,7 @@
"source": [
"### Objective\n",
"\n",
"In this tutorial, you deploy a container running Nvidia Triton Server with a `Vertex AI Model` resource to a `Vertex AI Endpoint` for making online predictions.\n",
"In this tutorial, you learn how to deploy a container running Nvidia Triton Server with a `Vertex AI Model` resource to a `Vertex AI Endpoint` for making online predictions.\n",
"\n",
"This tutorial uses the following Google Cloud ML services:\n",
"\n",
@@ -702,7 +702,7 @@
" + f\"/{PRIVATE_REPO}\"\n",
" + \"/tf_serving:gpu\"\n",
" )\n",
" TF_IMAGE = \"tensorflow/serving:latest-gpu\"\n",
" TF_IMAGE = \"tensorflow/serving:2.5.4-gpu\"\n",
"else:\n",
" DEPLOY_IMAGE = (\n",
" f\"{REGION}-docker.pkg.dev/\"\n",
@@ -710,15 +710,15 @@
" + f\"/{PRIVATE_REPO}\"\n",
" + \"/tf_serving:cpu\"\n",
" )\n",
" TF_IMAGE = \"tensorflow/serving:latest\"\n",
" TF_IMAGE = \"tensorflow/serving:2.5.4\"\n",
"\n",
"if not IS_COLAB:\n",
" if DEPLOY_GPU:\n",
" ! sudo docker pull tensorflow/serving:latest-gpu\n",
" ! sudo docker pull tensorflow/serving:2.5.4-gpu\n",
" else:\n",
" ! sudo docker pull tensorflow/serving:latest\n",
" ! sudo docker pull tensorflow/serving:2.5.4\n",
"\n",
" ! docker tag tensorflow/serving $DEPLOY_IMAGE\n",
" ! docker tag $TF_IMAGE $DEPLOY_IMAGE\n",
" ! docker push $DEPLOY_IMAGE\n",
"else:\n",
" # install docker daemon\n",
@@ -1434,7 +1434,7 @@
},
"outputs": [],
"source": [
"delete_bucket = False\n",
"delete_bucket = True\n",
"delete_model = True\n",
"delete_endpoint = True\n",
"delete_batch_job = True\n",
@@ -1054,36 +1054,17 @@
]
}
],
"metadata": {
"colab": {
"collapsed_sections": [],
"name": "get_started_with_tf_serving_function.ipynb",
"toc_visible": true
"metadata": {
"colab": {
"collapsed_sections": [],
"name": "get_started_with_tf_serving_function.ipynb",
"toc_visible": true
},
"kernelspec": {
"display_name": "Python 3",
"name": "python3"
}
},
"environment": {
"kernel": "python3",
"name": "tf2-gpu.2-6.m91",
"type": "gcloud",
"uri": "gcr.io/deeplearning-platform-release/tf2-gpu.2-6:m91"
},
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.7.12"
}
},
"nbformat": 4,
"nbformat_minor": 4
"nbformat": 4,
"nbformat_minor": 0
}
@@ -85,7 +85,7 @@
"\n",
"The steps performed include:\n",
"\n",
"- Locally train a Pytorch tabular classifier.\n",
"- Locally train a PyTorch tabular classifier.\n",
"- Locally test the trained model.\n",
"- Build a HTTP server using FastAPI.\n",
"- Create a custom serving container with the trained model and FastAPI server.\n",
File diff suppressed because it is too large Load Diff
@@ -34,3 +34,69 @@ This stage may be done entirely by MLOps. We recommend:
## Notebooks
### Get Started
[Vertex AI Model Monitoring for custom tabular models with TensorFlow Serving container](community/ml_ops/stage7/get_started_with_model_monitoring_custom_tf_serving.ipynb)
In this notebook, you learn to use the `Vertex AI Model Monitoring` service to detect feature skew and drift in the input predict requests, for custom tabular models, using a custom deployment container.
The steps performed include:
- Download a pre-trained custom tabular model.
- Upload the pre-trained model as a `Model` resource.
- Deploying the `Model` resource to an `Endpoint` resource with `TensorFlow Serving` serving binary.
- Configure the `Endpoint` resource for model monitoring.
- Generate synthetic prediction requests for skew.
- Wait for email alert notification.
- Generate synthetic prediction requests for drift.
- Wait for email alert notification.
[Vertex AI Model Monitoring for AutoML tabular models](community/ml_ops/stage7/get_started_with_model_monitoring_automl.ipynb)
In this notebook, you learn to use the `Vertex AI Model Monitoring` service to detect feature skew and drift in the input predict requests, for AutoML tabular models.
The steps performed include:
- Train an `AutoML` model.
- Deploy the `Model` resource to the `Endpoint` resource.
- Configure the `Endpoint` resource for model monitoring.
- Generate synthetic prediction requests for skew.
- Wait for email alert notification.
- Generate synthetic prediction requests for drift.
- Wait for email alert notification.
[Vertex AI Model Monitoring for custom tabular models](community/ml_ops/stage7/get_started_with_model_monitoring_custom.ipynb)
In this notebook, you learn to use the `Vertex AI Model Monitoring` service to detect feature skew and drift in the input predict requests, for custom tabular models.
The steps performed include:
- Download a pre-trained custom tabular model.
- Upload the pre-trained model as a `Model` resource.
- Deploy the `Model` resource to the `Endpoint` resource.
- Configure the `Endpoint` resource for model monitoring.
- Generate synthetic prediction requests for skew.
- Wait for email alert notification.
- Generate synthetic prediction requests for drift.
- Wait for email alert notification.
[Vertex AI Model Monitoring for setup for tabular models](community/ml_ops/stage7/get_started_with_model_monitoring_setup.ipynb)
In this notebook, you learn to setup the `Vertex AI Model Monitoring` service to detect feature skew and drift in the input predict requests.
The steps performed include:
- Download a pre-trained custom tabular model.
- Upload the pre-trained model as a `Model` resource.
- Deploy the `Model` resource to the `Endpoint` resource.
- Configure the `Endpoint` resource for model monitoring.
- Skew and drift detection for feature inputs.
- Skew and drift detection for feature attributions.
- Automatic generation of the `input schema` by sending 1000 prediction request.
- List, pause, resume and delete monitoring jobs.
- Restart monitoring job with predefined `input schema`.
- View logged monitored data.
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
@@ -31,17 +31,12 @@
"id": "fsv4jGuU89rX"
},
"source": [
"# Vertex AI Model Monitoring for setup for tabular models\n",
"# E2E ML on GCP: MLOps stage 7 : monitoring: Vertex AI Model Monitoring for setup for tabular models\n",
"\n",
"<table align=\"left\">\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/ai-platform/notebooks/deploy-notebook?name=Model%20Monitoring&download_url=https%3A%2F%2Fraw.githubusercontent.com%2FGoogleCloudPlatform%2Fvertex-ai-samples%2Fmain%2Fnotebooks%2Fcommunity%2Fml_ops%2Fstage7%2get_started_with_vertex_model_monitoring_setup.ipynb\">\n",
" <img src=\"https://www.gstatic.com/cloud/images/navigation/vertex-ai.svg\" alt=\"Google Cloud Notebooks\">Open in Workbench AI Notebook\n",
" </a>\n",
" </td> \n",
" <td>\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage7/get_started_with_vertex_model_monitoring_setup.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Open in Colab\n",
" <a href=\"https://colab.research.google.com/github/GoogleCloudPlatform/vertex-ai-samples/blob/main/notebooks/community/ml_ops/stage7/get_started_with_model_monitoring_setup.ipynb\">\n",
" <img src=\"https://cloud.google.com/ml-engine/images/colab-logo-32px.png\" alt=\"Colab logo\"> Run in Colab\n",
" </a>\n",
" </td>\n",
" <td>\n",
@@ -50,6 +45,12 @@
" View on GitHub\n",
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/ml_ops/stage7/get_started_with_model_monitoring_setup.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
" </td>\n",
"</table>"
]
},
@@ -110,7 +111,7 @@
"- identity - unique player identitity numbers\n",
"- demographic features - information about the player, such as the geographic region in which a player is located\n",
"- behavioral features - counts of the number of times a player has triggered certain game events, such as reaching a new level\n",
"- churn propensity - this is the label or target feature, it provides an estimated probability that this player will churn, i.e. stop being an active player."
"- churn propensity - this is the label or target feature, it provides an estimated probability that this player may churn, i.e. stop being an active player."
]
},
{
@@ -140,8 +141,6 @@
"id": "8yVpQt-JHKPF"
},
"source": [
"## Before you begin\n",
"\n",
"### Set up your local development environment\n",
"\n",
"**If you are using Colab or Vertex AI Workbench notebooks**, your environment already meets\n",
@@ -214,8 +213,9 @@
" USER_FLAG = \"--user\"\n",
"\n",
"# Install required packages.\n",
"! pip3 install {USER_FLAG} --quiet --upgrade google-cloud-aiplatform\n",
"! pip3 install {USER_FLAG} --quiet --upgrade google-cloud-bigquery"
"! pip3 install {USER_FLAG} --quiet --upgrade google-cloud-aiplatform \\\n",
" google-cloud-bigquery \\\n",
" tensorflow==2.7"
]
},
{
@@ -254,6 +254,8 @@
"id": "BF1j6f9HApxa"
},
"source": [
"## Before you begin\n",
"\n",
"### Set up your Google Cloud project\n",
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
@@ -264,7 +266,7 @@
"\n",
"1. [Enable the Vertex AI API and Compute Engine API](https://console.cloud.google.com/flows/enableapi?apiid=aiplatform.googleapis.com,compute_component).\n",
"\n",
"1. If you are running this notebook locally, you will need to install the [Cloud SDK](https://cloud.google.com/sdk).\n",
"1. If you are running this notebook locally, you need to install the [Cloud SDK](https://cloud.google.com/sdk).\n",
"\n",
"1. Enter your project ID in the cell below. Then run the cell to make sure the\n",
"Cloud SDK uses the right project for all the commands in this notebook.\n",
@@ -502,6 +504,86 @@
"- For the CSV data source, grant both service accounts the \"Storage Object Viewer\" role."
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "bucket:custom"
},
"source": [
"### Create a Cloud Storage bucket\n",
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"Set the name of your Cloud Storage bucket below, which you use in this tutorial to upload the `input schema` for the monitoring service.\n",
"\n",
"Bucket names must be globally unique across all Google Cloud projects, including those outside of your organization."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "bucket"
},
"outputs": [],
"source": [
"BUCKET_NAME = \"[your-bucket-name]\" # @param {type:\"string\"}\n",
"BUCKET_URI = f\"gs://{BUCKET_NAME}\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "autoset_bucket"
},
"outputs": [],
"source": [
"if BUCKET_NAME == \"\" or BUCKET_NAME is None or BUCKET_NAME == \"[your-bucket-name]\":\n",
" BUCKET_NAME = PROJECT_ID + \"aip-\" + UUID\n",
" BUCKET_URI = \"gs://\" + BUCKET_NAME"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "create_bucket"
},
"source": [
"**Only if your bucket doesn't already exist**: Run the following cell to create your Cloud Storage bucket."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "create_bucket"
},
"outputs": [],
"source": [
"! gsutil mb -l $REGION $BUCKET_URI"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "validate_bucket"
},
"source": [
"Finally, validate access to your Cloud Storage bucket by examining its contents:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "validate_bucket"
},
"outputs": [],
"source": [
"! gsutil ls -al $BUCKET_URI"
]
},
{
"cell_type": "markdown",
"metadata": {
@@ -686,7 +768,7 @@
"source": [
"## Introduction to Vertex AI Model Monitoring\n",
"\n",
"Vertex AI Model Monitoring is supported for AutoML tabular models and custom tabular model. You can monitor for skew and drift detection of the features in the inbound prediction requests or skew and drift detection of the feature attributions (Explainable AI) in the outbound prediction response -- that is, the distribution of the attributions on how they contributed to the output (predictions).\n",
"Vertex AI Model Monitoring is supported for AutoML tabular models and custom tabular models. You can monitor for skew and drift detection of the features in the inbound prediction requests or skew and drift detection of the feature attributions (Explainable AI) in the outbound prediction response -- that is, the distribution of the attributions on how they contributed to the output (predictions).\n",
"\n",
"The following are the basic steps to enable model monitoring:\n",
"\n",
@@ -694,16 +776,16 @@
"2. Configure a model monitoring specification.\n",
"3. Upload the model monitoring specification to the `Vertex AI Endpoint`.\n",
"4. Upload or automatic generation of the `input schema` for parsing.\n",
"5. For feature skew detection, upload the training data to automatic generation of the feature distribution.\n",
"5. For feature skew detection, upload the training data for automatic generation of the feature distribution.\n",
"6. For feature attributions, upload corresponding `Vertex AI Explainability` specification.\n",
"\n",
"Once configured, you can enable/disable monitoring, change alerts and update the model monitoring configuration. \n",
"\n",
"When model monitoring is enabled, incoming prediction requests are logged in a BigQuery table. The input feature values contained in the logged requests are then analyzed for skew or drift. You can set a sampling rate to monitor a subset of the production inputs to a model.\n",
"When model monitoring is enabled, the sampled incoming prediction requests are logged into a BigQuery table. The input feature values contained in the logged requests are then analyzed for skew or drift on an specified interval basis. You set a sampling rate to monitor a subset of the production inputs to a model, and the monitoring interval.\n",
"\n",
"The model monitoring service needs to know how to parse the feature values, which is referred to as the input schema. For AutoML tabular models, the input schema is automatically provided. For custom tabular models, the service will attempt to automatically derive the input schema from the first 1000 prediction requests. Alternatively, one can upload the input schema.\n",
"The model monitoring service needs to know how to parse the feature values, which is referred to as the input schema. For AutoML tabular models, the input schema is automatically generated. For custom tabular models, the service attempts to automatically derive the input schema from the first 1000 prediction requests. Alternatively, one can upload the input schema.\n",
"\n",
"For skew detection, requires a baseline for the statistical distribution of values in the training data. For AutoML tabular models this is automatically derived. For custom tabular models, you upload the training data to the service, and have the service automatically derived the distribution.\n",
"For skew detection, the monitoring service requires a baseline for the statistical distribution of values in the training data. For AutoML tabular models this is automatically derived. For custom tabular models, you upload the training data to the service, and have the service automatically derive the distribution.\n",
"\n",
"For feature attribution skew and drift detection, requires enabling your deployed model for `Vertex AI Explainability`\n",
"\n",
@@ -1144,7 +1226,11 @@
"source": [
"#### Monitoring Job State\n",
"\n",
"After you start the `Vertex AI Model Monitoring` job, it will be in a `PENDING` state until the `input schema` and `skew distribution baselines` are calculated. The process happens sequentially. In this example where we use automatic generation of the `input schema` will stay in a `PENDING` state until the 1000 prediction request (discussed subsequently) is sent. Once the `input schema` has been generated, then a batch job will be initiated to generate the distribution baseline from the training data. Once the baseline distribution is generated, then the monitoring job will enter `RUNNING` state."
"After you start the `Vertex AI Model Monitoring` job, it will be in a `PENDING` state until the `input schema` and `skew distribution baselines` are calculated. The process happens sequentially. In this example where you use automatic generation of the `input schema`, the service stays in a `PENDING` state until the 1000 prediction request (discussed subsequently) is sent. \n",
"\n",
"Once the `input schema` has been generated, then a batch job will be initiated to generate the distribution baseline from the training data. Again, the service stays in a `PENDING` state until the baseline distribution is calculated.\n",
"\n",
"Once the baseline distribution is generated, then the monitoring job will enter `OFFLINE` state. On the per interval basis -- e.g., once an hour, the monitoring job will enter `RUNNING` state while analyzing the sampled data. Once completed, it will return to an `OFFLINE` state while awaiting the next scheduled analysis."
]
},
{
@@ -1243,7 +1329,7 @@
"\n",
"### Automatic generation of the baseline distribution\n",
"\n",
"After the `input schema` is generated, the monitoring service creates a batch job to analyze for first 1000 predictions to generate the baseline distribution. Once completed, the monitoring service will be in `RUNNING` state."
"After the `input schema` is generated, the monitoring service creates a batch job to analyze the training data to determine the baseline distribution. "
]
},
{
@@ -1254,16 +1340,9 @@
},
"outputs": [],
"source": [
"import time\n",
"\n",
"while True:\n",
" time.sleep(60)\n",
" jobs = monitoring_job.list(filter=f\"display_name=churn_{UUID}\")\n",
" job = jobs[0]\n",
" print(job.state)\n",
" if job.state == aiplatform.gapic.JobState.JOB_STATE_PENDING:\n",
" continue\n",
" break"
"# Pause a bit for the baseline distribution to be calculated\n",
"if os.getenv(\"IS_TESTING\"):\n",
" time.sleep(120)"
]
},
{
@@ -1415,7 +1494,7 @@
"source": [
"# Delete the monitoring logged data BigQuery dataset\n",
"\n",
"! bq rm -r -f {PROJECT_ID}:model_deployment_monitoring_{ENDPOINT_ID}"
"! bq rm -r -f {PROJECT_ID}.model_deployment_monitoring_{ENDPOINT_ID}"
]
},
{
@@ -1430,7 +1509,7 @@
"\n",
"#### Create the predefined input schema\n",
"\n",
"The predefined `input schema` is specified as a YAML file. In this example, you retrieve the BigQuery schema for the training data, which includes the feature names and data types, to generate the YAML specification.\n",
"The predefined `input schema` is specified as a YAML file. In this example, you retrieve the BigQuery schema for the training data, which includes the feature names and data types, to generate the YAML specification. The predefined `input schema` must be loaded to a Cloud Storage location.\n",
"\n",
"Learn more about [Custom instance schemas for parsing input](https://cloud.google.com/vertex-ai/docs/model-monitoring/overview#custom-input-schemas)."
]
@@ -1475,7 +1554,9 @@
"print(yaml)\n",
"\n",
"with open(\"schema.yaml\", \"w\") as f:\n",
" f.write(yaml)"
" f.write(yaml)\n",
"\n",
"! gsutil cp schema.yaml {BUCKET_URI}/schema.yaml"
]
},
{
@@ -1508,7 +1589,7 @@
" schedule_config=schedule_config,\n",
" alert_config=alerting_config,\n",
" objective_configs=objective_config,\n",
" analysis_instance_schema_uri=\"schema.yaml\",\n",
" analysis_instance_schema_uri=f\"{BUCKET_URI}/schema.yaml\",\n",
")\n",
"\n",
"print(monitoring_job)"
@@ -1588,7 +1669,12 @@
"id": "18889460bd33"
},
"source": [
"### Cleanup"
"## Cleaning up\n",
"\n",
"To clean up all Google Cloud resources used in this project, you can [delete the Google Cloud\n",
"project](https://cloud.google.com/resource-manager/docs/creating-managing-projects#shutting_down_projects) you used for the tutorial.\n",
"\n",
"Otherwise, you can delete the individual resources you created in this tutorial."
]
},
{
@@ -1599,14 +1685,21 @@
},
"outputs": [],
"source": [
"! rm -f schema.yaml"
"delete_bucket = True\n",
"\n",
"if delete_bucket or os.getenv(\"IS_TESTING\"):\n",
" ! gsutil rm -rf {BUCKET_URI}\n",
"\n",
"! rm -f schema.yaml\n",
"\n",
"! bq rm -r -f {PROJECT_ID}.model_deployment_monitoring_{ENDPOINT_ID}"
]
}
],
"metadata": {
"colab": {
"collapsed_sections": [],
"name": "model_monitoring_setup.ipynb",
"name": "get_started_with_model_monitoring_setup.ipynb",
"toc_visible": true
},
"kernelspec": {
Binary file not shown.

After

Width:  |  Height:  |  Size: 55 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 46 KiB

@@ -3,7 +3,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "d3069d95",
"metadata": {
"cellView": "form",
"id": "d3069d95"
@@ -11,7 +10,7 @@
"outputs": [],
"source": [
"# @title Copyright & License (click to expand)\n",
"# Copyright 2021 Google LLC\n",
"# Copyright 2022 Google LLC\n",
"#\n",
"# Licensed under the Apache License, Version 2.0 (the \"License\");\n",
"# you may not use this file except in compliance with the License.\n",
@@ -28,7 +27,6 @@
},
{
"cell_type": "markdown",
"id": "546c53de",
"metadata": {
"id": "546c53de"
},
@@ -46,13 +44,16 @@
" <img src=\"https://cloud.google.com/ml-engine/images/github-logo-32px.png\" alt=\"GitHub logo\">\n",
" View on GitHub\n",
" </a>\n",
" </td>\n",
" </td><td>\n",
" <a href=\"https://console.cloud.google.com/ai-platform/notebooks/deploy-notebook?name=Model%20Monitoring&download_url=https%3A%2F%2Fraw.githubusercontent.com%2FGoogleCloudPlatform%2Fvertex-ai-samples%2Fmain%2Fnotebooks%2Fcommunity%2Fmodel_monitoring%2Fbatch_prediction_model_monitoring.ipynb\">\n",
" <img src=\"https://www.gstatic.com/cloud/images/navigation/vertex-ai.svg\" alt=\"Google Cloud Notebooks\">Open in Workbench AI Notebook\n",
" </a>\n",
" </td> \n",
"</table>"
]
},
{
"cell_type": "markdown",
"id": "53fd1070",
"metadata": {
"id": "53fd1070"
},
@@ -64,7 +65,6 @@
},
{
"cell_type": "markdown",
"id": "8b26c855",
"metadata": {
"id": "8b26c855"
},
@@ -98,7 +98,6 @@
},
{
"cell_type": "markdown",
"id": "d52ba95b",
"metadata": {
"id": "d52ba95b"
},
@@ -110,7 +109,6 @@
},
{
"cell_type": "markdown",
"id": "e64fb18a",
"metadata": {
"id": "e64fb18a"
},
@@ -123,7 +121,6 @@
},
{
"cell_type": "markdown",
"id": "9d839347",
"metadata": {
"id": "9d839347"
},
@@ -142,7 +139,6 @@
},
{
"cell_type": "markdown",
"id": "738fce1f",
"metadata": {
"id": "738fce1f"
},
@@ -155,7 +151,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "4536fe4e",
"metadata": {
"id": "4536fe4e"
},
@@ -178,14 +173,13 @@
" USER_FLAG = \"--user\"\n",
"\n",
"# Install Python package dependencies.\n",
"! pip3 install -q tensorflow-data-validation $USER_FLAG\n",
"! pip3 install -q google-api-core $USER_FLAG\n",
"! pip3 install -q google-cloud-aiplatform $USER_FLAG"
"! pip3 install -q {USER_FLAG} tensorflow-data-validation \\\n",
" google-api-core \\\n",
" google-cloud-aiplatform"
]
},
{
"cell_type": "markdown",
"id": "6e98402b",
"metadata": {
"id": "6e98402b"
},
@@ -198,7 +192,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "9775c9ff",
"metadata": {
"id": "9775c9ff"
},
@@ -217,13 +210,16 @@
},
{
"cell_type": "markdown",
"id": "d5737134",
"metadata": {
"id": "d5737134"
},
"source": [
"### Set up your Google Cloud project\n",
"\n",
"**_NOTE_**: This notebook has been tested in the following environment:\n",
"\n",
"* Python version = 3.7\n",
"\n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"1. [Select or create a Google Cloud project](https://console.cloud.google.com/cloud-resource-manager). When you first create an account, you get a $300 free credit towards your compute/storage costs.\n",
@@ -242,7 +238,6 @@
},
{
"cell_type": "markdown",
"id": "cfb1a1d5",
"metadata": {
"id": "cfb1a1d5"
},
@@ -255,50 +250,33 @@
{
"cell_type": "code",
"execution_count": null,
"id": "cf8535e4",
"metadata": {
"id": "cf8535e4"
},
"outputs": [],
"source": [
"import os\n",
"\n",
"PROJECT_ID = \"\"\n",
"\n",
"# Get your Google Cloud project ID from gcloud\n",
"if not os.getenv(\"IS_TESTING\"):\n",
" shell_output = ! gcloud config list --format 'value(core.project)' 2>/dev/null\n",
" PROJECT_ID = shell_output[0]\n",
" print(\"Project ID: \", PROJECT_ID)"
]
},
{
"cell_type": "markdown",
"id": "05a2d397",
"metadata": {
"id": "05a2d397"
},
"source": [
"Otherwise, set your project ID here.\n"
"PROJECT_ID = \"[your-project-id]\" # @param {type:\"string\"}"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "1c2be4bd",
"metadata": {
"id": "1c2be4bd"
},
"outputs": [],
"source": [
"if PROJECT_ID == \"\" or PROJECT_ID is None:\n",
" PROJECT_ID = \"python-docs-samples-tests\" # @param {type:\"string\"}"
"if PROJECT_ID == \"\" or not PROJECT_ID or PROJECT_ID == \"[your-project-id]\":\n",
" PROJECT_ID = \"[your-project-id]\" # @param {type:\"string\"}\n",
" # Get your GCP project id from gcloud\n",
" shell_output = ! gcloud config list --format 'value(core.project)' 2>/dev/null\n",
" PROJECT_ID = shell_output[0]\n",
" print(\"Project ID:\", PROJECT_ID)"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "c129705c",
"metadata": {
"id": "c129705c"
},
@@ -309,32 +287,6 @@
},
{
"cell_type": "markdown",
"id": "71404c9f",
"metadata": {
"id": "71404c9f"
},
"source": [
"#### Set your email address\n",
"This is used for delivering model monitoring notifications.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "4b1d2b69",
"metadata": {
"id": "4b1d2b69"
},
"outputs": [],
"source": [
"EMAIL_ADDRESS = \"[your-email-address]\" # @param {type:\"string\"}\n",
"if not EMAIL_ADDRESS or EMAIL_ADDRESS == \"[your-email-address]\":\n",
" print(\"EMAIL_ADDRESS not specified, please correct before proceeding.\")"
]
},
{
"cell_type": "markdown",
"id": "83340af4",
"metadata": {
"id": "83340af4"
},
@@ -356,18 +308,73 @@
{
"cell_type": "code",
"execution_count": null,
"id": "4814ea21",
"metadata": {
"id": "4814ea21"
},
"outputs": [],
"source": [
"REGION = \"us-central1\" # @param {type: \"string\"}"
"REGION = \"[your-region]\" # @param {type: \"string\"}\n",
"\n",
"if REGION == \"[your-region]\":\n",
" REGION = \"us-central1\""
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "06571eb4063b"
},
"source": [
"#### UUID\n",
"\n",
"If you are in a live tutorial session, you might be using a shared test account or project. To avoid name collisions between users on resources created, you create a uuid for each instance session, and append it onto the name of resources you create in this tutorial."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "4e166d927e36"
},
"outputs": [],
"source": [
"import random\n",
"import string\n",
"\n",
"\n",
"# Generate a uuid of a specifed length(default=8)\n",
"def generate_uuid(length: int = 8) -> str:\n",
" return \"\".join(random.choices(string.ascii_lowercase + string.digits, k=length))\n",
"\n",
"\n",
"UUID = generate_uuid()"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "71404c9f"
},
"source": [
"#### Set your email address\n",
"This is used for delivering model monitoring notifications.\n"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "4b1d2b69"
},
"outputs": [],
"source": [
"EMAIL_ADDRESS = \"[your-email-address]\" # @param {type:\"string\"}\n",
"if not EMAIL_ADDRESS or EMAIL_ADDRESS == \"[your-email-address]\":\n",
" print(\"EMAIL_ADDRESS not specified, please correct before proceeding.\")"
]
},
{
"cell_type": "markdown",
"id": "20a546c3",
"metadata": {
"id": "20a546c3"
},
@@ -375,16 +382,35 @@
"### Authenticate your Google Cloud account\n",
"\n",
"**If you are using Vertex AI Workbench notebooks**, your environment is already\n",
"authenticated. Skip this step.\n",
"authenticated.\n",
"\n",
"**If you are using Colab**, run the cell below and follow the instructions\n",
"when prompted to authenticate your account via oAuth.\n"
"when prompted to authenticate your account via oAuth.\n",
"\n",
"**Otherwise**, follow these steps:\n",
"\n",
"1. In the Cloud Console, go to the [**Create service account key**\n",
" page](https://console.cloud.google.com/apis/credentials/serviceaccountkey).\n",
"\n",
"2. Click **Create service account**.\n",
"\n",
"3. In the **Service account name** field, enter a name, and\n",
" click **Create**.\n",
"\n",
"4. In the **Grant this service account access to project** section, click the **Role** drop-down list. Type \"Vertex AI\"\n",
"into the filter box, and select\n",
" **Vertex AI Administrator**. Type \"Storage Object Admin\" into the filter box, and select **Storage Object Admin**.\n",
"\n",
"5. Click **Create**. A JSON file that contains your key downloads to your\n",
"local environment.\n",
"\n",
"6. Enter the path to your service account key as the\n",
"`GOOGLE_APPLICATION_CREDENTIALS` variable in the cell below and run the cell."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "06c51076",
"metadata": {
"id": "06c51076"
},
@@ -421,73 +447,284 @@
},
{
"cell_type": "markdown",
"id": "6b01af18",
"metadata": {
"id": "6b01af18"
"id": "bucket:custom"
},
"source": [
"### Upload the model\n",
"### Create a Cloud Storage bucket\n",
"\n",
"The churn propensity model you'll be using in this notebook has been trained in BigQuery ML and exported to a Google Cloud Storage bucket. This illustrates how you can easily export a trained model and move a model from one cloud service to another. \n",
"**The following steps are required, regardless of your notebook environment.**\n",
"\n",
"Next, import the model. **If you've already imported your model, you can skip this step.**"
]
},
{
"cell_type": "markdown",
"id": "9638ad2c",
"metadata": {
"id": "9638ad2c"
},
"source": [
"<span id=\"papermill-error-cell\" style=\"color:red; font-family:Helvetica Neue, Helvetica, Arial, sans-serif; font-size:2em;\">Execution using papermill encountered an exception here and stopped:</span>"
"Set the name of your Cloud Storage bucket below, which you use in this tutorial to upload the `input schema` for the monitoring service.\n",
"\n",
"Bucket names must be globally unique across all Google Cloud projects, including those outside of your organization."
]
},
{
"cell_type": "code",
"execution_count": null,
"id": "926e3ba8",
"metadata": {
"id": "926e3ba8"
"id": "bucket"
},
"outputs": [],
"source": [
"from datetime import datetime\n",
"import json\n",
"import time\n",
"import re\n",
"import tensorflow as tf\n",
"BUCKET_NAME = \"[your-bucket-name]\" # @param {type:\"string\"}\n",
"BUCKET_URI = f\"gs://{BUCKET_NAME}\""
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "autoset_bucket"
},
"outputs": [],
"source": [
"if BUCKET_NAME == \"\" or BUCKET_NAME is None or BUCKET_NAME == \"[your-bucket-name]\":\n",
" BUCKET_NAME = PROJECT_ID + \"aip-\" + UUID\n",
" BUCKET_URI = \"gs://\" + BUCKET_NAME"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "create_bucket"
},
"source": [
"**Only if your bucket doesn't already exist**: Run the following cell to create your Cloud Storage bucket."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "create_bucket"
},
"outputs": [],
"source": [
"! gsutil mb -l $REGION $BUCKET_URI"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "validate_bucket"
},
"source": [
"Finally, validate access to your Cloud Storage bucket by examining its contents:"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "validate_bucket"
},
"outputs": [],
"source": [
"! gsutil ls -al $BUCKET_URI"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "a0d294ff6d10"
},
"source": [
"### Import libraries"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "bd7a633296eb"
},
"outputs": [],
"source": [
"import google.cloud.aiplatform as aiplatform\n",
"import tensorflow_data_validation as tfdv\n",
"from tensorflow_data_validation.utils import io_util \n",
"from tensorflow_metadata.proto.v0 import statistics_pb2\n",
"\n",
"MODEL_DISPLAY_NAME=f\"batch_prediction_monitoring_test_model_{datetime.now().strftime('%Y%m%d%H%M%S')}\"\n",
"CONTAINER_IMAGE_URI=\"us-docker.pkg.dev/cloud-aiplatform/prediction/tf2-cpu.2-4:latest\"\n",
"ARTIFACT_URI=\"gs://mco-mm/churn\"\n",
"\n",
"output = ! gcloud ai models upload \\\n",
" --region=$REGION \\\n",
" --display-name=$MODEL_DISPLAY_NAME \\\n",
" --artifact-uri=$ARTIFACT_URI \\\n",
" --container-image-uri=$CONTAINER_IMAGE_URI \\\n",
" --format=\"value(model)\"\n",
"MODEL_ID = output[1].split(\"/\")[5]\n",
"print(f\"Model {MODEL_ID} created.\")"
"from tensorflow_data_validation.utils import io_util\n",
"from tensorflow_metadata.proto.v0 import statistics_pb2"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "init_aip:mbsdk,all"
},
"source": [
"### Initialize Vertex AI SDK for Python\n",
"\n",
"Initialize the Vertex AI SDK for Python for your project and corresponding bucket."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "init_aip:mbsdk,all"
},
"outputs": [],
"source": [
"aiplatform.init(project=PROJECT_ID, location=REGION)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "accelerators:training,prediction"
},
"source": [
"#### Set hardware accelerators\n",
"\n",
"You can set hardware accelerators for prediction (e.g., GPUs) or choose not to use any (CPU). Hardware accelertors lower the latency response for a prediction request. When choosing a hardware accelerators, consider the additional cost trade-off over latency.\n",
"\n",
"Set the variables `DEPLOY_GPU/DEPLOY_NGPU` to use a container image supporting a GPU and the number of GPUs allocated to the virtual machine (VM) instance. For example, to use a GPU container image with 4 Nvidia Tesla K80 GPUs allocated to each VM, you would specify:\n",
"\n",
" (aiplatform.gapic.AcceleratorType.NVIDIA_TESLA_K80, 4)\n",
"\n",
"See the [locations where accelerators are available](https://cloud.google.com/vertex-ai/docs/general/locations#accelerators).\n",
"\n",
"Otherwise specify `(None, None)` to use a container image to run on a CPU."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "xd5PLXDTlugv"
},
"outputs": [],
"source": [
"GPU = False\n",
"if GPU:\n",
" DEPLOY_GPU, DEPLOY_NGPU = (aiplatform.gapic.AcceleratorType.NVIDIA_TESLA_K80, 1)\n",
"else:\n",
" DEPLOY_GPU, DEPLOY_NGPU = (None, None)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "container:training,prediction"
},
"source": [
"#### Set pre-built containers\n",
"\n",
"Set the pre-built Docker container image for prediction.\n",
"\n",
"For the latest list, see [Pre-built containers for prediction](https://cloud.google.com/ai-platform-unified/docs/predictions/pre-built-containers)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "1u1mr18jlugv"
},
"outputs": [],
"source": [
"if GPU:\n",
" DEPLOY_VERSION = \"tf2-gpu.2-5\"\n",
"else:\n",
" DEPLOY_VERSION = \"tf2-cpu.2-5\"\n",
"\n",
"DEPLOY_IMAGE = \"{}-docker.pkg.dev/vertex-ai/prediction/{}:latest\".format(\n",
" REGION.split(\"-\")[0], DEPLOY_VERSION\n",
")\n",
"\n",
"print(\"Deployment:\", DEPLOY_IMAGE, DEPLOY_GPU, DEPLOY_NGPU)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "machine:training,prediction"
},
"source": [
"#### Set machine types\n",
"\n",
"Next, set the machine types to use for training and prediction.\n",
"\n",
"- Set the variable `DEPLOY_COMPUTE` to configure your compute resources for prediction.\n",
" - `machine type`\n",
" - `n1-standard`: 3.75GB of memory per vCPU\n",
" - `n1-highmem`: 6.5GB of memory per vCPU\n",
" - `n1-highcpu`: 0.9 GB of memory per vCPU\n",
" - `vCPUs`: number of \\[2, 4, 8, 16, 32, 64, 96 \\]\n",
"\n",
"*Note: You may also use n2 and e2 machine types for training and deployment, but they do not support GPUs*."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "YAXwbqKKlugv"
},
"outputs": [],
"source": [
"MACHINE_TYPE = \"n1-standard\"\n",
"\n",
"VCPU = \"4\"\n",
"TRAIN_COMPUTE = MACHINE_TYPE + \"-\" + VCPU\n",
"print(\"Train machine type\", TRAIN_COMPUTE)\n",
"\n",
"MACHINE_TYPE = \"n1-standard\"\n",
"\n",
"VCPU = \"4\"\n",
"DEPLOY_COMPUTE = MACHINE_TYPE + \"-\" + VCPU\n",
"print(\"Deploy machine type\", DEPLOY_COMPUTE)"
]
},
{
"cell_type": "markdown",
"metadata": {
"id": "9bf06cd476e9"
},
"source": [
"### Upload the model artifacts as a `Vertex AI Model` resource\n",
"\n",
"First, you upload the pre-trained custom tabular model artifacts as a `Vertex AI Model` resource using the `upload()` method, with the following parameters:\n",
"\n",
"- `display_name`: The human readable name for the `Model` resource.\n",
"- `artifact_uri`: The Cloud Storage location of the model artifacts.\n",
"- `serving_container_image`: The serving container image to use when the model is deployed to a `Vertex AI Endpoint` resource.\n",
"- `sync`: Whether to wait for the process to complete, or return immediately (async)."
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"id": "0193f247e216"
},
"outputs": [],
"source": [
"MODEL_ARTIFACT_URI = \"gs://mco-mm/churn\"\n",
"\n",
"model = aiplatform.Model.upload(\n",
" display_name=\"churn_\" + UUID,\n",
" artifact_uri=MODEL_ARTIFACT_URI,\n",
" serving_container_image_uri=DEPLOY_IMAGE,\n",
" sync=True,\n",
")\n",
"\n",
"print(model)"
]
},
{
"cell_type": "markdown",
"id": "a4305ddf",
"metadata": {
"id": "a4305ddf"
},
"source": [
"## Submit a batch prediction request with model monitoring enabled"
"## Submit a batch prediction request with model monitoring enabled\n"
]
},
{
"cell_type": "markdown",
"id": "053fde99",
"metadata": {
"id": "053fde99"
},
@@ -503,7 +740,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "b832ad31",
"metadata": {
"id": "b832ad31"
},
@@ -511,20 +747,17 @@
"source": [
"# Copy files to your projects gs bucket to avoid permission issues.\n",
"# Ignore any error(s) for bucket already exists.\n",
"OUTPUT_GS_PATH = f\"gs://{PROJECT_ID.replace('-', '_')}_bp_mm_output\"\n",
"INPUT_GS_PATH = f\"gs://{PROJECT_ID.replace('-', '_')}_bp_mm_input\"\n",
"OUTPUT_GS_PATH = f\"{BUCKET_URI}/bp_mm_output\"\n",
"INPUT_GS_PATH = f\"{BUCKET_URI}/bp_mm_input\"\n",
"PUBLIC_TRAINING_DATASET = \"gs://bp_mm_public_data/churn/churn_bp_insample.csv\"\n",
"TRAINING_DATASET = f\"{INPUT_GS_PATH}/churn_bp_insample.csv\"\n",
"TRAINING_DATASET_FORMAT = \"csv\"\n",
"\n",
"! gsutil mb -p {PROJECT_ID} -l {REGION} -b on {INPUT_GS_PATH}\n",
"! gsutil mb -p {PROJECT_ID} -l {REGION} -b on {OUTPUT_GS_PATH}\n",
"! gsutil copy $PUBLIC_TRAINING_DATASET $INPUT_GS_PATH"
]
},
{
"cell_type": "markdown",
"id": "34c95126",
"metadata": {
"id": "34c95126"
},
@@ -541,21 +774,18 @@
{
"cell_type": "code",
"execution_count": null,
"id": "3a54368a",
"metadata": {
"id": "3a54368a"
},
"outputs": [],
"source": [
"now = datetime.now()\n",
"INPUT_URI = \"gs://bp_mm_public_data/churn/churn_bp_outsample.jsonl\"\n",
"OUTPUT_URI = OUTPUT_GS_PATH\n",
"INSTANCES_FORMAT = \"jsonl\"\n",
"PREDICTIONS_FORMAT = \"jsonl\"\n",
"JOB_NAME_PREFIX = \"bp_mm_demo\"\n",
"MODEL_NAME = f\"projects/{PROJECT_ID}/locations/{REGION}/models/{MODEL_ID}\"\n",
"MACHINE_TYPE = \"n1-standard-8\"\n",
"BATCH_PREDICTION_JOB_NAME = JOB_NAME_PREFIX + \"_\" + now.strftime(\"%Y%m%d%H%M%S\")\n",
"MODEL_NAME = model.resource_name\n",
"BATCH_PREDICTION_JOB_NAME = JOB_NAME_PREFIX + \"_\" + UUID\n",
"\n",
"from google.cloud.aiplatform_v1beta1.types import (\n",
" BatchDedicatedResources, BatchPredictionJob, GcsDestination, GcsSource,\n",
@@ -573,7 +803,7 @@
" gcs_destination=GcsDestination(output_uri_prefix=OUTPUT_URI),\n",
" ),\n",
" dedicated_resources=BatchDedicatedResources(\n",
" machine_spec=MachineSpec(machine_type=MACHINE_TYPE),\n",
" machine_spec=MachineSpec(machine_type=DEPLOY_COMPUTE),\n",
" starting_replica_count=1,\n",
" max_replica_count=1,\n",
" ),\n",
@@ -604,7 +834,6 @@
},
{
"cell_type": "markdown",
"id": "cae39778",
"metadata": {
"id": "cae39778"
},
@@ -617,7 +846,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "bcdd4a47",
"metadata": {
"id": "bcdd4a47"
},
@@ -638,7 +866,6 @@
},
{
"cell_type": "markdown",
"id": "49ec90a0",
"metadata": {
"id": "49ec90a0"
},
@@ -651,7 +878,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "c30496b5",
"metadata": {
"id": "c30496b5"
},
@@ -664,7 +890,6 @@
},
{
"cell_type": "markdown",
"id": "831651c2",
"metadata": {
"id": "831651c2"
},
@@ -684,7 +909,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "a705c10b",
"metadata": {
"id": "a705c10b"
},
@@ -695,7 +919,6 @@
},
{
"cell_type": "markdown",
"id": "2bbdddac",
"metadata": {
"id": "2bbdddac"
},
@@ -708,7 +931,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "f6c674e9",
"metadata": {
"id": "f6c674e9"
},
@@ -746,7 +968,6 @@
},
{
"cell_type": "markdown",
"id": "233b1266",
"metadata": {
"id": "233b1266"
},
@@ -759,7 +980,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "4e8c00a7",
"metadata": {
"id": "4e8c00a7"
},
@@ -774,7 +994,6 @@
},
{
"cell_type": "markdown",
"id": "497a0016",
"metadata": {
"id": "497a0016"
},
@@ -790,7 +1009,6 @@
{
"cell_type": "code",
"execution_count": null,
"id": "eabc3f81",
"metadata": {
"id": "eabc3f81"
},
@@ -806,7 +1024,6 @@
},
{
"cell_type": "markdown",
"id": "0aa0219d",
"metadata": {
"id": "0aa0219d"
},
@@ -37,7 +37,7 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai-samples/main/notebooks/community/prediction/custom_prediction_routines/SDK_Custom_Predict_SDK_Integration.ipynb\">\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/prediction/custom_prediction_routines/SDK_Custom_Predict_SDK_Integration.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
@@ -53,7 +53,7 @@
"source": [
"## Overview\n",
"\n",
"This tutorial demonstrates how to use Vertex AI SDK to build a custom container that uses the Custom Prediction Routine model server to serve a scikit-learn model on Vertex AI Predictions. This is currently a **preview** feature. Pre-GA products and features might have limited support, and changes to pre-GA products and features might not be compatible with other pre-GA versions. For more information, see the [launch stage descriptions](https://cloud.google.com/products#product-launch-stages).\n",
"This tutorial demonstrates how to use Vertex AI SDK to build a custom container that uses the Custom Prediction Routine model server to serve a scikit-learn model on Vertex AI Predictions.\n",
"\n",
"\n",
"\n",
@@ -53,7 +53,7 @@
"source": [
"## Overview\n",
"\n",
"This tutorial demonstrates how to use Vertex AI SDK to build a custom container that uses the Custom Prediction Routine model server to serve a scikit-learn model on Vertex AI Predictions. This is currently a **preview** feature. Pre-GA products and features might have limited support, and changes to pre-GA products and features might not be compatible with other pre-GA versions. For more information, see the [launch stage descriptions](https://cloud.google.com/products#product-launch-stages).\n",
"This tutorial demonstrates how to use Vertex AI SDK to build a custom container that uses the Custom Prediction Routine model server to serve a scikit-learn model on Vertex AI Predictions.\n",
"\n",
"\n",
"\n",
@@ -53,7 +53,7 @@
"source": [
"## Overview\n",
"\n",
"This tutorial demonstrates how to use Vertex AI SDK to build a custom container that uses the Custom Prediction Routine model server to serve a scikit-learn model on Vertex AI Predictions. This is currently a **preview** feature. Pre-GA products and features might have limited support, and changes to pre-GA products and features might not be compatible with other pre-GA versions. For more information, see the [launch stage descriptions](https://cloud.google.com/products#product-launch-stages).\n",
"This tutorial demonstrates how to use Vertex AI SDK to build a custom container that uses the Custom Prediction Routine model server to serve a scikit-learn model on Vertex AI Predictions.\n",
"\n",
"\n",
"\n",
@@ -37,7 +37,7 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai-samples/main/notebooks/community/prediction/custom_prediction_routines/SDK_Pytorch_Custom_Predict.ipynb\">\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/prediction/custom_prediction_routines/SDK_Pytorch_Custom_Predict.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
@@ -53,7 +53,7 @@
"source": [
"## Overview\n",
"\n",
"This tutorial demonstrates how to use Vertex AI SDK to build a custom container that uses the Custom Prediction Routine model server to serve a PyTorch model on Vertex AI Predictions. This is currently a **preview** feature. Pre-GA products and features might have limited support, and changes to pre-GA products and features might not be compatible with other pre-GA versions. For more information, see the [launch stage descriptions](https://cloud.google.com/products#product-launch-stages).\n",
"This tutorial demonstrates how to use Vertex AI SDK to build a custom container that uses the Custom Prediction Routine model server to serve a PyTorch model on Vertex AI Predictions.\n",
"\n",
"\n",
"\n",
@@ -37,7 +37,7 @@
" </a>\n",
" </td>\n",
" <td>\n",
" <a href=\"https://console.cloud.google.com/vertex-ai-samples/main/notebooks/community/prediction/custom_prediction_routines/SDK_Triton_PyTorch_Local_Prediction.ipynb\">\n",
" <a href=\"https://console.cloud.google.com/vertex-ai/workbench/deploy-notebook?download_url=https://raw.githubusercontent.com/GoogleCloudPlatform/vertex-ai-samples/main/notebooks/community/prediction/custom_prediction_routines/SDK_Triton_PyTorch_Local_Prediction.ipynb\">\n",
" <img src=\"https://lh3.googleusercontent.com/UiNooY4LUgW_oTvpsNhPpQzsstV5W8F7rYgxgGBD85cWJoLmrOzhVs_ksK_vgx40SHs7jCqkTkCk=e14-rj-sc0xffffff-h130-w32\" alt=\"Vertex AI logo\">\n",
" Open in Vertex AI Workbench\n",
" </a>\n",
@@ -53,7 +53,7 @@
"source": [
"## Overview\n",
"\n",
"This tutorial demonstrates how to use Vertex AI SDK to locally test [NVIDIA Triton inference server](https://developer.nvidia.com/nvidia-triton-inference-server) to serve a PyTorch model and deploy it to Vertex AI Predictions. This is currently a **preview** feature. Pre-GA products and features might have limited support, and changes to pre-GA products and features might not be compatible with other pre-GA versions. For more information, see the [launch stage descriptions](https://cloud.google.com/products#product-launch-stages).\n",
"This tutorial demonstrates how to use Vertex AI SDK to locally test [NVIDIA Triton inference server](https://developer.nvidia.com/nvidia-triton-inference-server) to serve a PyTorch model and deploy it to Vertex AI Predictions.\n",
"\n",
"\n",
"### Dataset\n",
File diff suppressed because it is too large Load Diff

Some files were not shown because too many files have changed in this diff Show More