Skip to content

Commit 50646be

Browse files
vertex-sdk-botcopybara-github
authored andcommitted
feat: Add tunable parameters for Model Garden model training to the "AutoMLImageTrainingJob" in SDK.
PiperOrigin-RevId: 538999389
1 parent b4eba68 commit 50646be

File tree

5 files changed

+834
-374
lines changed

5 files changed

+834
-374
lines changed

google/cloud/aiplatform/constants/base.py

+2
Original file line numberDiff line numberDiff line change
@@ -79,12 +79,14 @@
7979

8080
MODEL_GARDEN_ICN_MODEL_TYPES = {
8181
"EFFICIENTNET",
82+
"MAXVIT",
8283
"VIT",
8384
"COCA",
8485
}
8586

8687
MODEL_GARDEN_IOD_MODEL_TYPES = {
8788
"SPINENET",
89+
"YOLO",
8890
}
8991

9092
# TODO(b/177079208): Use EPCL Enums for validating Model Types

google/cloud/aiplatform/hyperparameter_tuning.py

+14
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,20 @@
2222

2323
from google.cloud.aiplatform.compat.types import study as gca_study_compat
2424

25+
SEARCH_ALGORITHM_TO_PROTO_VALUE = {
26+
"random": gca_study_compat.StudySpec.Algorithm.RANDOM_SEARCH,
27+
"grid": gca_study_compat.StudySpec.Algorithm.GRID_SEARCH,
28+
None: gca_study_compat.StudySpec.Algorithm.ALGORITHM_UNSPECIFIED,
29+
}
30+
31+
MEASUREMENT_SELECTION_TO_PROTO_VALUE = {
32+
"best": (gca_study_compat.StudySpec.MeasurementSelectionType.BEST_MEASUREMENT),
33+
"last": (gca_study_compat.StudySpec.MeasurementSelectionType.LAST_MEASUREMENT),
34+
None: (
35+
gca_study_compat.StudySpec.MeasurementSelectionType.MEASUREMENT_SELECTION_TYPE_UNSPECIFIED
36+
),
37+
}
38+
2539
_SCALE_TYPE_MAP = {
2640
"linear": gca_study_compat.StudySpec.ParameterSpec.ScaleType.UNIT_LINEAR_SCALE,
2741
"log": gca_study_compat.StudySpec.ParameterSpec.ScaleType.UNIT_LOG_SCALE,

google/cloud/aiplatform/jobs.py

+4-14
Original file line numberDiff line numberDiff line change
@@ -1998,18 +1998,6 @@ def job_spec(self):
19981998
return self._gca_resource.job_spec
19991999

20002000

2001-
_SEARCH_ALGORITHM_TO_PROTO_VALUE = {
2002-
"random": gca_study_compat.StudySpec.Algorithm.RANDOM_SEARCH,
2003-
"grid": gca_study_compat.StudySpec.Algorithm.GRID_SEARCH,
2004-
None: gca_study_compat.StudySpec.Algorithm.ALGORITHM_UNSPECIFIED,
2005-
}
2006-
2007-
_MEASUREMENT_SELECTION_TO_PROTO_VALUE = {
2008-
"best": gca_study_compat.StudySpec.MeasurementSelectionType.BEST_MEASUREMENT,
2009-
"last": gca_study_compat.StudySpec.MeasurementSelectionType.LAST_MEASUREMENT,
2010-
}
2011-
2012-
20132001
class HyperparameterTuningJob(_RunnableJob):
20142002
"""Vertex AI Hyperparameter Tuning Job."""
20152003

@@ -2215,8 +2203,10 @@ def __init__(
22152203
study_spec = gca_study_compat.StudySpec(
22162204
metrics=metrics,
22172205
parameters=parameters,
2218-
algorithm=_SEARCH_ALGORITHM_TO_PROTO_VALUE[search_algorithm],
2219-
measurement_selection_type=_MEASUREMENT_SELECTION_TO_PROTO_VALUE[
2206+
algorithm=hyperparameter_tuning.SEARCH_ALGORITHM_TO_PROTO_VALUE[
2207+
search_algorithm
2208+
],
2209+
measurement_selection_type=hyperparameter_tuning.MEASUREMENT_SELECTION_TO_PROTO_VALUE[
22202210
measurement_selection
22212211
],
22222212
)

0 commit comments

Comments
 (0)