/
api_op_CreateHyperParameterTuningJob.go
214 lines (184 loc) · 8.35 KB
/
api_op_CreateHyperParameterTuningJob.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
// Code generated by private/model/cli/gen-api/main.go. DO NOT EDIT.
package sagemaker
import (
"context"
"fmt"
"github.com/aws/aws-sdk-go-v2/aws"
"github.com/aws/aws-sdk-go-v2/internal/awsutil"
)
type CreateHyperParameterTuningJobInput struct {
_ struct{} `type:"structure"`
// The HyperParameterTuningJobConfig object that describes the tuning job, including
// the search strategy, the objective metric used to evaluate training jobs,
// ranges of parameters to search, and resource limits for the tuning job. For
// more information, see How Hyperparameter Tuning Works (https://docs.aws.amazon.com/sagemaker/latest/dg/automatic-model-tuning-how-it-works.html).
//
// HyperParameterTuningJobConfig is a required field
HyperParameterTuningJobConfig *HyperParameterTuningJobConfig `type:"structure" required:"true"`
// The name of the tuning job. This name is the prefix for the names of all
// training jobs that this tuning job launches. The name must be unique within
// the same AWS account and AWS Region. The name must have { } to { } characters.
// Valid characters are a-z, A-Z, 0-9, and : + = @ _ % - (hyphen). The name
// is not case sensitive.
//
// HyperParameterTuningJobName is a required field
HyperParameterTuningJobName *string `min:"1" type:"string" required:"true"`
// An array of key-value pairs. You can use tags to categorize your AWS resources
// in different ways, for example, by purpose, owner, or environment. For more
// information, see AWS Tagging Strategies (https://aws.amazon.com/answers/account-management/aws-tagging-strategies/).
//
// Tags that you specify for the tuning job are also added to all training jobs
// that the tuning job launches.
Tags []Tag `type:"list"`
// The HyperParameterTrainingJobDefinition object that describes the training
// jobs that this tuning job launches, including static hyperparameters, input
// data configuration, output data configuration, resource configuration, and
// stopping condition.
TrainingJobDefinition *HyperParameterTrainingJobDefinition `type:"structure"`
// A list of the HyperParameterTrainingJobDefinition objects launched for this
// tuning job.
TrainingJobDefinitions []HyperParameterTrainingJobDefinition `min:"1" type:"list"`
// Specifies the configuration for starting the hyperparameter tuning job using
// one or more previous tuning jobs as a starting point. The results of previous
// tuning jobs are used to inform which combinations of hyperparameters to search
// over in the new tuning job.
//
// All training jobs launched by the new hyperparameter tuning job are evaluated
// by using the objective metric. If you specify IDENTICAL_DATA_AND_ALGORITHM
// as the WarmStartType value for the warm start configuration, the training
// job that performs the best in the new tuning job is compared to the best
// training jobs from the parent tuning jobs. From these, the training job that
// performs the best as measured by the objective metric is returned as the
// overall best training job.
//
// All training jobs launched by parent hyperparameter tuning jobs and the new
// hyperparameter tuning jobs count against the limit of training jobs for the
// tuning job.
WarmStartConfig *HyperParameterTuningJobWarmStartConfig `type:"structure"`
}
// String returns the string representation
func (s CreateHyperParameterTuningJobInput) String() string {
return awsutil.Prettify(s)
}
// Validate inspects the fields of the type to determine if they are valid.
func (s *CreateHyperParameterTuningJobInput) Validate() error {
invalidParams := aws.ErrInvalidParams{Context: "CreateHyperParameterTuningJobInput"}
if s.HyperParameterTuningJobConfig == nil {
invalidParams.Add(aws.NewErrParamRequired("HyperParameterTuningJobConfig"))
}
if s.HyperParameterTuningJobName == nil {
invalidParams.Add(aws.NewErrParamRequired("HyperParameterTuningJobName"))
}
if s.HyperParameterTuningJobName != nil && len(*s.HyperParameterTuningJobName) < 1 {
invalidParams.Add(aws.NewErrParamMinLen("HyperParameterTuningJobName", 1))
}
if s.TrainingJobDefinitions != nil && len(s.TrainingJobDefinitions) < 1 {
invalidParams.Add(aws.NewErrParamMinLen("TrainingJobDefinitions", 1))
}
if s.HyperParameterTuningJobConfig != nil {
if err := s.HyperParameterTuningJobConfig.Validate(); err != nil {
invalidParams.AddNested("HyperParameterTuningJobConfig", err.(aws.ErrInvalidParams))
}
}
if s.Tags != nil {
for i, v := range s.Tags {
if err := v.Validate(); err != nil {
invalidParams.AddNested(fmt.Sprintf("%s[%v]", "Tags", i), err.(aws.ErrInvalidParams))
}
}
}
if s.TrainingJobDefinition != nil {
if err := s.TrainingJobDefinition.Validate(); err != nil {
invalidParams.AddNested("TrainingJobDefinition", err.(aws.ErrInvalidParams))
}
}
if s.TrainingJobDefinitions != nil {
for i, v := range s.TrainingJobDefinitions {
if err := v.Validate(); err != nil {
invalidParams.AddNested(fmt.Sprintf("%s[%v]", "TrainingJobDefinitions", i), err.(aws.ErrInvalidParams))
}
}
}
if s.WarmStartConfig != nil {
if err := s.WarmStartConfig.Validate(); err != nil {
invalidParams.AddNested("WarmStartConfig", err.(aws.ErrInvalidParams))
}
}
if invalidParams.Len() > 0 {
return invalidParams
}
return nil
}
type CreateHyperParameterTuningJobOutput struct {
_ struct{} `type:"structure"`
// The Amazon Resource Name (ARN) of the tuning job. Amazon SageMaker assigns
// an ARN to a hyperparameter tuning job when you create it.
//
// HyperParameterTuningJobArn is a required field
HyperParameterTuningJobArn *string `type:"string" required:"true"`
}
// String returns the string representation
func (s CreateHyperParameterTuningJobOutput) String() string {
return awsutil.Prettify(s)
}
const opCreateHyperParameterTuningJob = "CreateHyperParameterTuningJob"
// CreateHyperParameterTuningJobRequest returns a request value for making API operation for
// Amazon SageMaker Service.
//
// Starts a hyperparameter tuning job. A hyperparameter tuning job finds the
// best version of a model by running many training jobs on your dataset using
// the algorithm you choose and values for hyperparameters within ranges that
// you specify. It then chooses the hyperparameter values that result in a model
// that performs the best, as measured by an objective metric that you choose.
//
// // Example sending a request using CreateHyperParameterTuningJobRequest.
// req := client.CreateHyperParameterTuningJobRequest(params)
// resp, err := req.Send(context.TODO())
// if err == nil {
// fmt.Println(resp)
// }
//
// Please also see https://docs.aws.amazon.com/goto/WebAPI/sagemaker-2017-07-24/CreateHyperParameterTuningJob
func (c *Client) CreateHyperParameterTuningJobRequest(input *CreateHyperParameterTuningJobInput) CreateHyperParameterTuningJobRequest {
op := &aws.Operation{
Name: opCreateHyperParameterTuningJob,
HTTPMethod: "POST",
HTTPPath: "/",
}
if input == nil {
input = &CreateHyperParameterTuningJobInput{}
}
req := c.newRequest(op, input, &CreateHyperParameterTuningJobOutput{})
return CreateHyperParameterTuningJobRequest{Request: req, Input: input, Copy: c.CreateHyperParameterTuningJobRequest}
}
// CreateHyperParameterTuningJobRequest is the request type for the
// CreateHyperParameterTuningJob API operation.
type CreateHyperParameterTuningJobRequest struct {
*aws.Request
Input *CreateHyperParameterTuningJobInput
Copy func(*CreateHyperParameterTuningJobInput) CreateHyperParameterTuningJobRequest
}
// Send marshals and sends the CreateHyperParameterTuningJob API request.
func (r CreateHyperParameterTuningJobRequest) Send(ctx context.Context) (*CreateHyperParameterTuningJobResponse, error) {
r.Request.SetContext(ctx)
err := r.Request.Send()
if err != nil {
return nil, err
}
resp := &CreateHyperParameterTuningJobResponse{
CreateHyperParameterTuningJobOutput: r.Request.Data.(*CreateHyperParameterTuningJobOutput),
response: &aws.Response{Request: r.Request},
}
return resp, nil
}
// CreateHyperParameterTuningJobResponse is the response type for the
// CreateHyperParameterTuningJob API operation.
type CreateHyperParameterTuningJobResponse struct {
*CreateHyperParameterTuningJobOutput
response *aws.Response
}
// SDKResponseMetdata returns the response metadata for the
// CreateHyperParameterTuningJob request.
func (r *CreateHyperParameterTuningJobResponse) SDKResponseMetdata() *aws.Response {
return r.response
}