All Downloads are FREE. Search and download functionalities are using the official Maven repository.

software.amazon.awssdk.services.sagemaker.model.CreateHyperParameterTuningJobRequest Maven / Gradle / Ivy

Go to download

The AWS Java SDK for Amazon SageMaker module holds the client classes that are used for communicating with Amazon SageMaker Service

There is a newer version: 2.30.1
Show newest version
/*
 * Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"). You may not use this file except in compliance with
 * the License. A copy of the License is located at
 * 
 * http://aws.amazon.com/apache2.0
 * 
 * or in the "license" file accompanying this file. This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
 * CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions
 * and limitations under the License.
 */

package software.amazon.awssdk.services.sagemaker.model;

import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import software.amazon.awssdk.annotations.Generated;
import software.amazon.awssdk.awscore.AwsRequestOverrideConfiguration;
import software.amazon.awssdk.core.SdkField;
import software.amazon.awssdk.core.SdkPojo;
import software.amazon.awssdk.core.protocol.MarshallLocation;
import software.amazon.awssdk.core.protocol.MarshallingType;
import software.amazon.awssdk.core.traits.ListTrait;
import software.amazon.awssdk.core.traits.LocationTrait;
import software.amazon.awssdk.core.util.DefaultSdkAutoConstructList;
import software.amazon.awssdk.core.util.SdkAutoConstructList;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;

/**
 */
@Generated("software.amazon.awssdk:codegen")
public final class CreateHyperParameterTuningJobRequest extends SageMakerRequest implements
        ToCopyableBuilder {
    private static final SdkField HYPER_PARAMETER_TUNING_JOB_NAME_FIELD = SdkField
            . builder(MarshallingType.STRING)
            .memberName("HyperParameterTuningJobName")
            .getter(getter(CreateHyperParameterTuningJobRequest::hyperParameterTuningJobName))
            .setter(setter(Builder::hyperParameterTuningJobName))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("HyperParameterTuningJobName")
                    .build()).build();

    private static final SdkField HYPER_PARAMETER_TUNING_JOB_CONFIG_FIELD = SdkField
            . builder(MarshallingType.SDK_POJO)
            .memberName("HyperParameterTuningJobConfig")
            .getter(getter(CreateHyperParameterTuningJobRequest::hyperParameterTuningJobConfig))
            .setter(setter(Builder::hyperParameterTuningJobConfig))
            .constructor(HyperParameterTuningJobConfig::builder)
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("HyperParameterTuningJobConfig")
                    .build()).build();

    private static final SdkField TRAINING_JOB_DEFINITION_FIELD = SdkField
            . builder(MarshallingType.SDK_POJO).memberName("TrainingJobDefinition")
            .getter(getter(CreateHyperParameterTuningJobRequest::trainingJobDefinition))
            .setter(setter(Builder::trainingJobDefinition)).constructor(HyperParameterTrainingJobDefinition::builder)
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TrainingJobDefinition").build())
            .build();

    private static final SdkField> TRAINING_JOB_DEFINITIONS_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .memberName("TrainingJobDefinitions")
            .getter(getter(CreateHyperParameterTuningJobRequest::trainingJobDefinitions))
            .setter(setter(Builder::trainingJobDefinitions))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("TrainingJobDefinitions").build(),
                    ListTrait
                            .builder()
                            .memberLocationName(null)
                            .memberFieldInfo(
                                    SdkField. builder(MarshallingType.SDK_POJO)
                                            .constructor(HyperParameterTrainingJobDefinition::builder)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("member").build()).build()).build()).build();

    private static final SdkField WARM_START_CONFIG_FIELD = SdkField
            . builder(MarshallingType.SDK_POJO).memberName("WarmStartConfig")
            .getter(getter(CreateHyperParameterTuningJobRequest::warmStartConfig)).setter(setter(Builder::warmStartConfig))
            .constructor(HyperParameterTuningJobWarmStartConfig::builder)
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("WarmStartConfig").build()).build();

    private static final SdkField> TAGS_FIELD = SdkField
            .> builder(MarshallingType.LIST)
            .memberName("Tags")
            .getter(getter(CreateHyperParameterTuningJobRequest::tags))
            .setter(setter(Builder::tags))
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Tags").build(),
                    ListTrait
                            .builder()
                            .memberLocationName(null)
                            .memberFieldInfo(
                                    SdkField. builder(MarshallingType.SDK_POJO)
                                            .constructor(Tag::builder)
                                            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
                                                    .locationName("member").build()).build()).build()).build();

    private static final SdkField AUTOTUNE_FIELD = SdkField. builder(MarshallingType.SDK_POJO)
            .memberName("Autotune").getter(getter(CreateHyperParameterTuningJobRequest::autotune))
            .setter(setter(Builder::autotune)).constructor(Autotune::builder)
            .traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Autotune").build()).build();

    private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(
            HYPER_PARAMETER_TUNING_JOB_NAME_FIELD, HYPER_PARAMETER_TUNING_JOB_CONFIG_FIELD, TRAINING_JOB_DEFINITION_FIELD,
            TRAINING_JOB_DEFINITIONS_FIELD, WARM_START_CONFIG_FIELD, TAGS_FIELD, AUTOTUNE_FIELD));

    private final String hyperParameterTuningJobName;

    private final HyperParameterTuningJobConfig hyperParameterTuningJobConfig;

    private final HyperParameterTrainingJobDefinition trainingJobDefinition;

    private final List trainingJobDefinitions;

    private final HyperParameterTuningJobWarmStartConfig warmStartConfig;

    private final List tags;

    private final Autotune autotune;

    private CreateHyperParameterTuningJobRequest(BuilderImpl builder) {
        super(builder);
        this.hyperParameterTuningJobName = builder.hyperParameterTuningJobName;
        this.hyperParameterTuningJobConfig = builder.hyperParameterTuningJobConfig;
        this.trainingJobDefinition = builder.trainingJobDefinition;
        this.trainingJobDefinitions = builder.trainingJobDefinitions;
        this.warmStartConfig = builder.warmStartConfig;
        this.tags = builder.tags;
        this.autotune = builder.autotune;
    }

    /**
     * 

* 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 Amazon Web Services account and Amazon Web Services Region. The * name must have 1 to 32 characters. Valid characters are a-z, A-Z, 0-9, and : + = @ _ % - (hyphen). The name is * not case sensitive. *

* * @return 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 Amazon Web Services account and Amazon Web Services * Region. The name must have 1 to 32 characters. Valid characters are a-z, A-Z, 0-9, and : + = @ _ % - * (hyphen). The name is not case sensitive. */ public final String hyperParameterTuningJobName() { return hyperParameterTuningJobName; } /** *

* 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. *

* * @return 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. */ public final HyperParameterTuningJobConfig hyperParameterTuningJobConfig() { return hyperParameterTuningJobConfig; } /** *

* 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. *

* * @return 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. */ public final HyperParameterTrainingJobDefinition trainingJobDefinition() { return trainingJobDefinition; } /** * For responses, this returns true if the service returned a value for the TrainingJobDefinitions property. This * DOES NOT check that the value is non-empty (for which, you should check the {@code isEmpty()} method on the * property). This is useful because the SDK will never return a null collection or map, but you may need to * differentiate between the service returning nothing (or null) and the service returning an empty collection or * map. For requests, this returns true if a value for the property was specified in the request builder, and false * if a value was not specified. */ public final boolean hasTrainingJobDefinitions() { return trainingJobDefinitions != null && !(trainingJobDefinitions instanceof SdkAutoConstructList); } /** *

* A list of the HyperParameterTrainingJobDefinition objects launched for this tuning job. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasTrainingJobDefinitions} method. *

* * @return A list of the HyperParameterTrainingJobDefinition objects launched for this tuning job. */ public final List trainingJobDefinitions() { return trainingJobDefinitions; } /** *

* 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. *

*
* * @return 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. *

*/ public final HyperParameterTuningJobWarmStartConfig warmStartConfig() { return warmStartConfig; } /** * For responses, this returns true if the service returned a value for the Tags property. This DOES NOT check that * the value is non-empty (for which, you should check the {@code isEmpty()} method on the property). This is useful * because the SDK will never return a null collection or map, but you may need to differentiate between the service * returning nothing (or null) and the service returning an empty collection or map. For requests, this returns true * if a value for the property was specified in the request builder, and false if a value was not specified. */ public final boolean hasTags() { return tags != null && !(tags instanceof SdkAutoConstructList); } /** *

* An array of key-value pairs. You can use tags to categorize your Amazon Web Services resources in different ways, * for example, by purpose, owner, or environment. For more information, see Tagging Amazon Web Services Resources. *

*

* Tags that you specify for the tuning job are also added to all training jobs that the tuning job launches. *

*

* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException. *

*

* This method will never return null. If you would like to know whether the service returned this field (so that * you can differentiate between null and empty), you can use the {@link #hasTags} method. *

* * @return An array of key-value pairs. You can use tags to categorize your Amazon Web Services resources in * different ways, for example, by purpose, owner, or environment. For more information, see Tagging Amazon Web Services * Resources.

*

* Tags that you specify for the tuning job are also added to all training jobs that the tuning job * launches. */ public final List tags() { return tags; } /** *

* Configures SageMaker Automatic model tuning (AMT) to automatically find optimal parameters for the following * fields: *

*
    *
  • *

    * ParameterRanges: The names and ranges of parameters that a hyperparameter tuning job can optimize. *

    *
  • *
  • *

    * ResourceLimits: * The maximum resources that can be used for a training job. These resources include the maximum number of training * jobs, the maximum runtime of a tuning job, and the maximum number of training jobs to run at the same time. *

    *
  • *
  • *

    * TrainingJobEarlyStoppingType: A flag that specifies whether or not to use early stopping for training jobs * launched by a hyperparameter tuning job. *

    *
  • *
  • *

    * RetryStrategy: The number of times to retry a training job. *

    *
  • *
  • *

    * * Strategy: Specifies how hyperparameter tuning chooses the combinations of hyperparameter values to use for * the training jobs that it launches. *

    *
  • *
  • *

    * * ConvergenceDetected: A flag to indicate that Automatic model tuning (AMT) has detected model convergence. *

    *
  • *
* * @return Configures SageMaker Automatic model tuning (AMT) to automatically find optimal parameters for the * following fields:

*
    *
  • *

    * ParameterRanges: The names and ranges of parameters that a hyperparameter tuning job can optimize. *

    *
  • *
  • *

    * ResourceLimits * : The maximum resources that can be used for a training job. These resources include the maximum * number of training jobs, the maximum runtime of a tuning job, and the maximum number of training jobs to * run at the same time. *

    *
  • *
  • *

    * TrainingJobEarlyStoppingType: A flag that specifies whether or not to use early stopping for * training jobs launched by a hyperparameter tuning job. *

    *
  • *
  • *

    * RetryStrategy: The number of times to retry a training job. *

    *
  • *
  • *

    * Strategy: Specifies how hyperparameter tuning chooses the combinations of hyperparameter values to * use for the training jobs that it launches. *

    *
  • *
  • *

    * * ConvergenceDetected: A flag to indicate that Automatic model tuning (AMT) has detected model * convergence. *

    *
  • */ public final Autotune autotune() { return autotune; } @Override public Builder toBuilder() { return new BuilderImpl(this); } public static Builder builder() { return new BuilderImpl(); } public static Class serializableBuilderClass() { return BuilderImpl.class; } @Override public final int hashCode() { int hashCode = 1; hashCode = 31 * hashCode + super.hashCode(); hashCode = 31 * hashCode + Objects.hashCode(hyperParameterTuningJobName()); hashCode = 31 * hashCode + Objects.hashCode(hyperParameterTuningJobConfig()); hashCode = 31 * hashCode + Objects.hashCode(trainingJobDefinition()); hashCode = 31 * hashCode + Objects.hashCode(hasTrainingJobDefinitions() ? trainingJobDefinitions() : null); hashCode = 31 * hashCode + Objects.hashCode(warmStartConfig()); hashCode = 31 * hashCode + Objects.hashCode(hasTags() ? tags() : null); hashCode = 31 * hashCode + Objects.hashCode(autotune()); return hashCode; } @Override public final boolean equals(Object obj) { return super.equals(obj) && equalsBySdkFields(obj); } @Override public final boolean equalsBySdkFields(Object obj) { if (this == obj) { return true; } if (obj == null) { return false; } if (!(obj instanceof CreateHyperParameterTuningJobRequest)) { return false; } CreateHyperParameterTuningJobRequest other = (CreateHyperParameterTuningJobRequest) obj; return Objects.equals(hyperParameterTuningJobName(), other.hyperParameterTuningJobName()) && Objects.equals(hyperParameterTuningJobConfig(), other.hyperParameterTuningJobConfig()) && Objects.equals(trainingJobDefinition(), other.trainingJobDefinition()) && hasTrainingJobDefinitions() == other.hasTrainingJobDefinitions() && Objects.equals(trainingJobDefinitions(), other.trainingJobDefinitions()) && Objects.equals(warmStartConfig(), other.warmStartConfig()) && hasTags() == other.hasTags() && Objects.equals(tags(), other.tags()) && Objects.equals(autotune(), other.autotune()); } /** * Returns a string representation of this object. This is useful for testing and debugging. Sensitive data will be * redacted from this string using a placeholder value. */ @Override public final String toString() { return ToString.builder("CreateHyperParameterTuningJobRequest") .add("HyperParameterTuningJobName", hyperParameterTuningJobName()) .add("HyperParameterTuningJobConfig", hyperParameterTuningJobConfig()) .add("TrainingJobDefinition", trainingJobDefinition()) .add("TrainingJobDefinitions", hasTrainingJobDefinitions() ? trainingJobDefinitions() : null) .add("WarmStartConfig", warmStartConfig()).add("Tags", hasTags() ? tags() : null).add("Autotune", autotune()) .build(); } public final Optional getValueForField(String fieldName, Class clazz) { switch (fieldName) { case "HyperParameterTuningJobName": return Optional.ofNullable(clazz.cast(hyperParameterTuningJobName())); case "HyperParameterTuningJobConfig": return Optional.ofNullable(clazz.cast(hyperParameterTuningJobConfig())); case "TrainingJobDefinition": return Optional.ofNullable(clazz.cast(trainingJobDefinition())); case "TrainingJobDefinitions": return Optional.ofNullable(clazz.cast(trainingJobDefinitions())); case "WarmStartConfig": return Optional.ofNullable(clazz.cast(warmStartConfig())); case "Tags": return Optional.ofNullable(clazz.cast(tags())); case "Autotune": return Optional.ofNullable(clazz.cast(autotune())); default: return Optional.empty(); } } @Override public final List> sdkFields() { return SDK_FIELDS; } private static Function getter(Function g) { return obj -> g.apply((CreateHyperParameterTuningJobRequest) obj); } private static BiConsumer setter(BiConsumer s) { return (obj, val) -> s.accept((Builder) obj, val); } public interface Builder extends SageMakerRequest.Builder, SdkPojo, CopyableBuilder { /** *

    * 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 Amazon Web Services account and Amazon Web Services Region. * The name must have 1 to 32 characters. Valid characters are a-z, A-Z, 0-9, and : + = @ _ % - (hyphen). The * name is not case sensitive. *

    * * @param hyperParameterTuningJobName * 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 Amazon Web Services account and Amazon * Web Services Region. The name must have 1 to 32 characters. Valid characters are a-z, A-Z, 0-9, and : * + = @ _ % - (hyphen). The name is not case sensitive. * @return Returns a reference to this object so that method calls can be chained together. */ Builder hyperParameterTuningJobName(String hyperParameterTuningJobName); /** *

    * 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. *

    * * @param hyperParameterTuningJobConfig * 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. * @return Returns a reference to this object so that method calls can be chained together. */ Builder hyperParameterTuningJobConfig(HyperParameterTuningJobConfig hyperParameterTuningJobConfig); /** *

    * 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. *

    * This is a convenience method that creates an instance of the {@link HyperParameterTuningJobConfig.Builder} * avoiding the need to create one manually via {@link HyperParameterTuningJobConfig#builder()}. * *

    * When the {@link Consumer} completes, {@link HyperParameterTuningJobConfig.Builder#build()} is called * immediately and its result is passed to {@link #hyperParameterTuningJobConfig(HyperParameterTuningJobConfig)}. * * @param hyperParameterTuningJobConfig * a consumer that will call methods on {@link HyperParameterTuningJobConfig.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #hyperParameterTuningJobConfig(HyperParameterTuningJobConfig) */ default Builder hyperParameterTuningJobConfig( Consumer hyperParameterTuningJobConfig) { return hyperParameterTuningJobConfig(HyperParameterTuningJobConfig.builder() .applyMutation(hyperParameterTuningJobConfig).build()); } /** *

    * 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. *

    * * @param trainingJobDefinition * 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. * @return Returns a reference to this object so that method calls can be chained together. */ Builder trainingJobDefinition(HyperParameterTrainingJobDefinition trainingJobDefinition); /** *

    * 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. *

    * This is a convenience method that creates an instance of the * {@link HyperParameterTrainingJobDefinition.Builder} avoiding the need to create one manually via * {@link HyperParameterTrainingJobDefinition#builder()}. * *

    * When the {@link Consumer} completes, {@link HyperParameterTrainingJobDefinition.Builder#build()} is called * immediately and its result is passed to {@link #trainingJobDefinition(HyperParameterTrainingJobDefinition)}. * * @param trainingJobDefinition * a consumer that will call methods on {@link HyperParameterTrainingJobDefinition.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #trainingJobDefinition(HyperParameterTrainingJobDefinition) */ default Builder trainingJobDefinition(Consumer trainingJobDefinition) { return trainingJobDefinition(HyperParameterTrainingJobDefinition.builder().applyMutation(trainingJobDefinition) .build()); } /** *

    * A list of the HyperParameterTrainingJobDefinition objects launched for this tuning job. *

    * * @param trainingJobDefinitions * A list of the HyperParameterTrainingJobDefinition objects launched for this tuning job. * @return Returns a reference to this object so that method calls can be chained together. */ Builder trainingJobDefinitions(Collection trainingJobDefinitions); /** *

    * A list of the HyperParameterTrainingJobDefinition objects launched for this tuning job. *

    * * @param trainingJobDefinitions * A list of the HyperParameterTrainingJobDefinition objects launched for this tuning job. * @return Returns a reference to this object so that method calls can be chained together. */ Builder trainingJobDefinitions(HyperParameterTrainingJobDefinition... trainingJobDefinitions); /** *

    * A list of the HyperParameterTrainingJobDefinition objects launched for this tuning job. *

    * This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.sagemaker.model.HyperParameterTrainingJobDefinition.Builder} avoiding * the need to create one manually via * {@link software.amazon.awssdk.services.sagemaker.model.HyperParameterTrainingJobDefinition#builder()}. * *

    * When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.sagemaker.model.HyperParameterTrainingJobDefinition.Builder#build()} * is called immediately and its result is passed to {@link * #trainingJobDefinitions(List)}. * * @param trainingJobDefinitions * a consumer that will call methods on * {@link software.amazon.awssdk.services.sagemaker.model.HyperParameterTrainingJobDefinition.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #trainingJobDefinitions(java.util.Collection) */ Builder trainingJobDefinitions(Consumer... trainingJobDefinitions); /** *

    * 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. *

    *
    * * @param warmStartConfig * 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. *

    * @return Returns a reference to this object so that method calls can be chained together. */ Builder warmStartConfig(HyperParameterTuningJobWarmStartConfig warmStartConfig); /** *

    * 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. *

    *
    This is a convenience method that creates an instance of the * {@link HyperParameterTuningJobWarmStartConfig.Builder} avoiding the need to create one manually via * {@link HyperParameterTuningJobWarmStartConfig#builder()}. * *

    * When the {@link Consumer} completes, {@link HyperParameterTuningJobWarmStartConfig.Builder#build()} is called * immediately and its result is passed to {@link #warmStartConfig(HyperParameterTuningJobWarmStartConfig)}. * * @param warmStartConfig * a consumer that will call methods on {@link HyperParameterTuningJobWarmStartConfig.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #warmStartConfig(HyperParameterTuningJobWarmStartConfig) */ default Builder warmStartConfig(Consumer warmStartConfig) { return warmStartConfig(HyperParameterTuningJobWarmStartConfig.builder().applyMutation(warmStartConfig).build()); } /** *

    * An array of key-value pairs. You can use tags to categorize your Amazon Web Services resources in different * ways, for example, by purpose, owner, or environment. For more information, see Tagging Amazon Web Services * Resources. *

    *

    * Tags that you specify for the tuning job are also added to all training jobs that the tuning job launches. *

    * * @param tags * An array of key-value pairs. You can use tags to categorize your Amazon Web Services resources in * different ways, for example, by purpose, owner, or environment. For more information, see Tagging Amazon Web Services * Resources.

    *

    * Tags that you specify for the tuning job are also added to all training jobs that the tuning job * launches. * @return Returns a reference to this object so that method calls can be chained together. */ Builder tags(Collection tags); /** *

    * An array of key-value pairs. You can use tags to categorize your Amazon Web Services resources in different * ways, for example, by purpose, owner, or environment. For more information, see Tagging Amazon Web Services * Resources. *

    *

    * Tags that you specify for the tuning job are also added to all training jobs that the tuning job launches. *

    * * @param tags * An array of key-value pairs. You can use tags to categorize your Amazon Web Services resources in * different ways, for example, by purpose, owner, or environment. For more information, see Tagging Amazon Web Services * Resources.

    *

    * Tags that you specify for the tuning job are also added to all training jobs that the tuning job * launches. * @return Returns a reference to this object so that method calls can be chained together. */ Builder tags(Tag... tags); /** *

    * An array of key-value pairs. You can use tags to categorize your Amazon Web Services resources in different * ways, for example, by purpose, owner, or environment. For more information, see Tagging Amazon Web Services * Resources. *

    *

    * Tags that you specify for the tuning job are also added to all training jobs that the tuning job launches. *

    * This is a convenience method that creates an instance of the * {@link software.amazon.awssdk.services.sagemaker.model.Tag.Builder} avoiding the need to create one manually * via {@link software.amazon.awssdk.services.sagemaker.model.Tag#builder()}. * *

    * When the {@link Consumer} completes, * {@link software.amazon.awssdk.services.sagemaker.model.Tag.Builder#build()} is called immediately and its * result is passed to {@link #tags(List)}. * * @param tags * a consumer that will call methods on * {@link software.amazon.awssdk.services.sagemaker.model.Tag.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #tags(java.util.Collection) */ Builder tags(Consumer... tags); /** *

    * Configures SageMaker Automatic model tuning (AMT) to automatically find optimal parameters for the following * fields: *

    *
      *
    • *

      * ParameterRanges: The names and ranges of parameters that a hyperparameter tuning job can optimize. *

      *
    • *
    • *

      * ResourceLimits: * The maximum resources that can be used for a training job. These resources include the maximum number of * training jobs, the maximum runtime of a tuning job, and the maximum number of training jobs to run at the * same time. *

      *
    • *
    • *

      * TrainingJobEarlyStoppingType: A flag that specifies whether or not to use early stopping for training * jobs launched by a hyperparameter tuning job. *

      *
    • *
    • *

      * RetryStrategy: The number of times to retry a training job. *

      *
    • *
    • *

      * * Strategy: Specifies how hyperparameter tuning chooses the combinations of hyperparameter values to use * for the training jobs that it launches. *

      *
    • *
    • *

      * * ConvergenceDetected: A flag to indicate that Automatic model tuning (AMT) has detected model convergence. *

      *
    • *
    * * @param autotune * Configures SageMaker Automatic model tuning (AMT) to automatically find optimal parameters for the * following fields:

    *
      *
    • *

      * ParameterRanges: The names and ranges of parameters that a hyperparameter tuning job can * optimize. *

      *
    • *
    • *

      * * ResourceLimits: The maximum resources that can be used for a training job. These resources include * the maximum number of training jobs, the maximum runtime of a tuning job, and the maximum number of * training jobs to run at the same time. *

      *
    • *
    • *

      * TrainingJobEarlyStoppingType: A flag that specifies whether or not to use early stopping for * training jobs launched by a hyperparameter tuning job. *

      *
    • *
    • *

      * RetryStrategy: The number of times to retry a training job. *

      *
    • *
    • *

      * Strategy: Specifies how hyperparameter tuning chooses the combinations of hyperparameter values * to use for the training jobs that it launches. *

      *
    • *
    • *

      * * ConvergenceDetected: A flag to indicate that Automatic model tuning (AMT) has detected model * convergence. *

      *
    • * @return Returns a reference to this object so that method calls can be chained together. */ Builder autotune(Autotune autotune); /** *

      * Configures SageMaker Automatic model tuning (AMT) to automatically find optimal parameters for the following * fields: *

      *
        *
      • *

        * ParameterRanges: The names and ranges of parameters that a hyperparameter tuning job can optimize. *

        *
      • *
      • *

        * ResourceLimits: * The maximum resources that can be used for a training job. These resources include the maximum number of * training jobs, the maximum runtime of a tuning job, and the maximum number of training jobs to run at the * same time. *

        *
      • *
      • *

        * TrainingJobEarlyStoppingType: A flag that specifies whether or not to use early stopping for training * jobs launched by a hyperparameter tuning job. *

        *
      • *
      • *

        * RetryStrategy: The number of times to retry a training job. *

        *
      • *
      • *

        * * Strategy: Specifies how hyperparameter tuning chooses the combinations of hyperparameter values to use * for the training jobs that it launches. *

        *
      • *
      • *

        * * ConvergenceDetected: A flag to indicate that Automatic model tuning (AMT) has detected model convergence. *

        *
      • *
      * This is a convenience method that creates an instance of the {@link Autotune.Builder} avoiding the need to * create one manually via {@link Autotune#builder()}. * *

      * When the {@link Consumer} completes, {@link Autotune.Builder#build()} is called immediately and its result is * passed to {@link #autotune(Autotune)}. * * @param autotune * a consumer that will call methods on {@link Autotune.Builder} * @return Returns a reference to this object so that method calls can be chained together. * @see #autotune(Autotune) */ default Builder autotune(Consumer autotune) { return autotune(Autotune.builder().applyMutation(autotune).build()); } @Override Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration); @Override Builder overrideConfiguration(Consumer builderConsumer); } static final class BuilderImpl extends SageMakerRequest.BuilderImpl implements Builder { private String hyperParameterTuningJobName; private HyperParameterTuningJobConfig hyperParameterTuningJobConfig; private HyperParameterTrainingJobDefinition trainingJobDefinition; private List trainingJobDefinitions = DefaultSdkAutoConstructList.getInstance(); private HyperParameterTuningJobWarmStartConfig warmStartConfig; private List tags = DefaultSdkAutoConstructList.getInstance(); private Autotune autotune; private BuilderImpl() { } private BuilderImpl(CreateHyperParameterTuningJobRequest model) { super(model); hyperParameterTuningJobName(model.hyperParameterTuningJobName); hyperParameterTuningJobConfig(model.hyperParameterTuningJobConfig); trainingJobDefinition(model.trainingJobDefinition); trainingJobDefinitions(model.trainingJobDefinitions); warmStartConfig(model.warmStartConfig); tags(model.tags); autotune(model.autotune); } public final String getHyperParameterTuningJobName() { return hyperParameterTuningJobName; } public final void setHyperParameterTuningJobName(String hyperParameterTuningJobName) { this.hyperParameterTuningJobName = hyperParameterTuningJobName; } @Override public final Builder hyperParameterTuningJobName(String hyperParameterTuningJobName) { this.hyperParameterTuningJobName = hyperParameterTuningJobName; return this; } public final HyperParameterTuningJobConfig.Builder getHyperParameterTuningJobConfig() { return hyperParameterTuningJobConfig != null ? hyperParameterTuningJobConfig.toBuilder() : null; } public final void setHyperParameterTuningJobConfig(HyperParameterTuningJobConfig.BuilderImpl hyperParameterTuningJobConfig) { this.hyperParameterTuningJobConfig = hyperParameterTuningJobConfig != null ? hyperParameterTuningJobConfig.build() : null; } @Override public final Builder hyperParameterTuningJobConfig(HyperParameterTuningJobConfig hyperParameterTuningJobConfig) { this.hyperParameterTuningJobConfig = hyperParameterTuningJobConfig; return this; } public final HyperParameterTrainingJobDefinition.Builder getTrainingJobDefinition() { return trainingJobDefinition != null ? trainingJobDefinition.toBuilder() : null; } public final void setTrainingJobDefinition(HyperParameterTrainingJobDefinition.BuilderImpl trainingJobDefinition) { this.trainingJobDefinition = trainingJobDefinition != null ? trainingJobDefinition.build() : null; } @Override public final Builder trainingJobDefinition(HyperParameterTrainingJobDefinition trainingJobDefinition) { this.trainingJobDefinition = trainingJobDefinition; return this; } public final List getTrainingJobDefinitions() { List result = HyperParameterTrainingJobDefinitionsCopier .copyToBuilder(this.trainingJobDefinitions); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setTrainingJobDefinitions( Collection trainingJobDefinitions) { this.trainingJobDefinitions = HyperParameterTrainingJobDefinitionsCopier.copyFromBuilder(trainingJobDefinitions); } @Override public final Builder trainingJobDefinitions(Collection trainingJobDefinitions) { this.trainingJobDefinitions = HyperParameterTrainingJobDefinitionsCopier.copy(trainingJobDefinitions); return this; } @Override @SafeVarargs public final Builder trainingJobDefinitions(HyperParameterTrainingJobDefinition... trainingJobDefinitions) { trainingJobDefinitions(Arrays.asList(trainingJobDefinitions)); return this; } @Override @SafeVarargs public final Builder trainingJobDefinitions( Consumer... trainingJobDefinitions) { trainingJobDefinitions(Stream.of(trainingJobDefinitions) .map(c -> HyperParameterTrainingJobDefinition.builder().applyMutation(c).build()) .collect(Collectors.toList())); return this; } public final HyperParameterTuningJobWarmStartConfig.Builder getWarmStartConfig() { return warmStartConfig != null ? warmStartConfig.toBuilder() : null; } public final void setWarmStartConfig(HyperParameterTuningJobWarmStartConfig.BuilderImpl warmStartConfig) { this.warmStartConfig = warmStartConfig != null ? warmStartConfig.build() : null; } @Override public final Builder warmStartConfig(HyperParameterTuningJobWarmStartConfig warmStartConfig) { this.warmStartConfig = warmStartConfig; return this; } public final List getTags() { List result = TagListCopier.copyToBuilder(this.tags); if (result instanceof SdkAutoConstructList) { return null; } return result; } public final void setTags(Collection tags) { this.tags = TagListCopier.copyFromBuilder(tags); } @Override public final Builder tags(Collection tags) { this.tags = TagListCopier.copy(tags); return this; } @Override @SafeVarargs public final Builder tags(Tag... tags) { tags(Arrays.asList(tags)); return this; } @Override @SafeVarargs public final Builder tags(Consumer... tags) { tags(Stream.of(tags).map(c -> Tag.builder().applyMutation(c).build()).collect(Collectors.toList())); return this; } public final Autotune.Builder getAutotune() { return autotune != null ? autotune.toBuilder() : null; } public final void setAutotune(Autotune.BuilderImpl autotune) { this.autotune = autotune != null ? autotune.build() : null; } @Override public final Builder autotune(Autotune autotune) { this.autotune = autotune; return this; } @Override public Builder overrideConfiguration(AwsRequestOverrideConfiguration overrideConfiguration) { super.overrideConfiguration(overrideConfiguration); return this; } @Override public Builder overrideConfiguration(Consumer builderConsumer) { super.overrideConfiguration(builderConsumer); return this; } @Override public CreateHyperParameterTuningJobRequest build() { return new CreateHyperParameterTuningJobRequest(this); } @Override public List> sdkFields() { return SDK_FIELDS; } } }





© 2015 - 2025 Weber Informatics LLC | Privacy Policy