
software.amazon.awssdk.services.sagemaker.model.HyperParameterTuningJobWarmStartConfig Maven / Gradle / Ivy
Show all versions of sagemaker Show documentation
/*
* 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.io.Serializable;
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.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;
/**
*
* Specifies the configuration for a hyperparameter tuning job that uses one or more previous hyperparameter 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, and the
* training job that performs the best 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.
*
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class HyperParameterTuningJobWarmStartConfig implements SdkPojo, Serializable,
ToCopyableBuilder {
private static final SdkField> PARENT_HYPER_PARAMETER_TUNING_JOBS_FIELD = SdkField
.> builder(MarshallingType.LIST)
.memberName("ParentHyperParameterTuningJobs")
.getter(getter(HyperParameterTuningJobWarmStartConfig::parentHyperParameterTuningJobs))
.setter(setter(Builder::parentHyperParameterTuningJobs))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("ParentHyperParameterTuningJobs")
.build(),
ListTrait
.builder()
.memberLocationName(null)
.memberFieldInfo(
SdkField. builder(MarshallingType.SDK_POJO)
.constructor(ParentHyperParameterTuningJob::builder)
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD)
.locationName("member").build()).build()).build()).build();
private static final SdkField WARM_START_TYPE_FIELD = SdkField. builder(MarshallingType.STRING)
.memberName("WarmStartType").getter(getter(HyperParameterTuningJobWarmStartConfig::warmStartTypeAsString))
.setter(setter(Builder::warmStartType))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("WarmStartType").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(
PARENT_HYPER_PARAMETER_TUNING_JOBS_FIELD, WARM_START_TYPE_FIELD));
private static final long serialVersionUID = 1L;
private final List parentHyperParameterTuningJobs;
private final String warmStartType;
private HyperParameterTuningJobWarmStartConfig(BuilderImpl builder) {
this.parentHyperParameterTuningJobs = builder.parentHyperParameterTuningJobs;
this.warmStartType = builder.warmStartType;
}
/**
* Returns true if the ParentHyperParameterTuningJobs property was specified by the sender (it may be empty), or
* false if the sender did not specify the value (it will be empty). For responses returned by the SDK, the sender
* is the AWS service.
*/
public final boolean hasParentHyperParameterTuningJobs() {
return parentHyperParameterTuningJobs != null && !(parentHyperParameterTuningJobs instanceof SdkAutoConstructList);
}
/**
*
* An array of hyperparameter tuning jobs that are used as the starting point for the new hyperparameter tuning job.
* For more information about warm starting a hyperparameter tuning job, see Using a Previous
* Hyperparameter Tuning Job as a Starting Point.
*
*
* Hyperparameter tuning jobs created before October 1, 2018 cannot be used as parent jobs for warm start tuning
* jobs.
*
*
* Attempts to modify the collection returned by this method will result in an UnsupportedOperationException.
*
*
* You can use {@link #hasParentHyperParameterTuningJobs()} to see if a value was sent in this field.
*
*
* @return An array of hyperparameter tuning jobs that are used as the starting point for the new hyperparameter
* tuning job. For more information about warm starting a hyperparameter tuning job, see Using a
* Previous Hyperparameter Tuning Job as a Starting Point.
*
* Hyperparameter tuning jobs created before October 1, 2018 cannot be used as parent jobs for warm start
* tuning jobs.
*/
public final List parentHyperParameterTuningJobs() {
return parentHyperParameterTuningJobs;
}
/**
*
* Specifies one of the following:
*
*
* - IDENTICAL_DATA_AND_ALGORITHM
* -
*
* The new hyperparameter tuning job uses the same input data and training image as the parent tuning jobs. You can
* change the hyperparameter ranges to search and the maximum number of training jobs that the hyperparameter tuning
* job launches. You cannot use a new version of the training algorithm, unless the changes in the new version do
* not affect the algorithm itself. For example, changes that improve logging or adding support for a different data
* format are allowed. You can also change hyperparameters from tunable to static, and from static to tunable, but
* the total number of static plus tunable hyperparameters must remain the same as it is in all parent jobs. The
* objective metric for the new tuning job must be the same as for all parent jobs.
*
*
* - TRANSFER_LEARNING
* -
*
* The new hyperparameter tuning job can include input data, hyperparameter ranges, maximum number of concurrent
* training jobs, and maximum number of training jobs that are different than those of its parent hyperparameter
* tuning jobs. The training image can also be a different version from the version used in the parent
* hyperparameter tuning job. You can also change hyperparameters from tunable to static, and from static to
* tunable, but the total number of static plus tunable hyperparameters must remain the same as it is in all parent
* jobs. The objective metric for the new tuning job must be the same as for all parent jobs.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #warmStartType}
* will return {@link HyperParameterTuningJobWarmStartType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the
* service is available from {@link #warmStartTypeAsString}.
*
*
* @return Specifies one of the following:
*
* - IDENTICAL_DATA_AND_ALGORITHM
* -
*
* The new hyperparameter tuning job uses the same input data and training image as the parent tuning jobs.
* You can change the hyperparameter ranges to search and the maximum number of training jobs that the
* hyperparameter tuning job launches. You cannot use a new version of the training algorithm, unless the
* changes in the new version do not affect the algorithm itself. For example, changes that improve logging
* or adding support for a different data format are allowed. You can also change hyperparameters from
* tunable to static, and from static to tunable, but the total number of static plus tunable
* hyperparameters must remain the same as it is in all parent jobs. The objective metric for the new tuning
* job must be the same as for all parent jobs.
*
*
* - TRANSFER_LEARNING
* -
*
* The new hyperparameter tuning job can include input data, hyperparameter ranges, maximum number of
* concurrent training jobs, and maximum number of training jobs that are different than those of its parent
* hyperparameter tuning jobs. The training image can also be a different version from the version used in
* the parent hyperparameter tuning job. You can also change hyperparameters from tunable to static, and
* from static to tunable, but the total number of static plus tunable hyperparameters must remain the same
* as it is in all parent jobs. The objective metric for the new tuning job must be the same as for all
* parent jobs.
*
*
* @see HyperParameterTuningJobWarmStartType
*/
public final HyperParameterTuningJobWarmStartType warmStartType() {
return HyperParameterTuningJobWarmStartType.fromValue(warmStartType);
}
/**
*
* Specifies one of the following:
*
*
* - IDENTICAL_DATA_AND_ALGORITHM
* -
*
* The new hyperparameter tuning job uses the same input data and training image as the parent tuning jobs. You can
* change the hyperparameter ranges to search and the maximum number of training jobs that the hyperparameter tuning
* job launches. You cannot use a new version of the training algorithm, unless the changes in the new version do
* not affect the algorithm itself. For example, changes that improve logging or adding support for a different data
* format are allowed. You can also change hyperparameters from tunable to static, and from static to tunable, but
* the total number of static plus tunable hyperparameters must remain the same as it is in all parent jobs. The
* objective metric for the new tuning job must be the same as for all parent jobs.
*
*
* - TRANSFER_LEARNING
* -
*
* The new hyperparameter tuning job can include input data, hyperparameter ranges, maximum number of concurrent
* training jobs, and maximum number of training jobs that are different than those of its parent hyperparameter
* tuning jobs. The training image can also be a different version from the version used in the parent
* hyperparameter tuning job. You can also change hyperparameters from tunable to static, and from static to
* tunable, but the total number of static plus tunable hyperparameters must remain the same as it is in all parent
* jobs. The objective metric for the new tuning job must be the same as for all parent jobs.
*
*
*
*
* If the service returns an enum value that is not available in the current SDK version, {@link #warmStartType}
* will return {@link HyperParameterTuningJobWarmStartType#UNKNOWN_TO_SDK_VERSION}. The raw value returned by the
* service is available from {@link #warmStartTypeAsString}.
*
*
* @return Specifies one of the following:
*
* - IDENTICAL_DATA_AND_ALGORITHM
* -
*
* The new hyperparameter tuning job uses the same input data and training image as the parent tuning jobs.
* You can change the hyperparameter ranges to search and the maximum number of training jobs that the
* hyperparameter tuning job launches. You cannot use a new version of the training algorithm, unless the
* changes in the new version do not affect the algorithm itself. For example, changes that improve logging
* or adding support for a different data format are allowed. You can also change hyperparameters from
* tunable to static, and from static to tunable, but the total number of static plus tunable
* hyperparameters must remain the same as it is in all parent jobs. The objective metric for the new tuning
* job must be the same as for all parent jobs.
*
*
* - TRANSFER_LEARNING
* -
*
* The new hyperparameter tuning job can include input data, hyperparameter ranges, maximum number of
* concurrent training jobs, and maximum number of training jobs that are different than those of its parent
* hyperparameter tuning jobs. The training image can also be a different version from the version used in
* the parent hyperparameter tuning job. You can also change hyperparameters from tunable to static, and
* from static to tunable, but the total number of static plus tunable hyperparameters must remain the same
* as it is in all parent jobs. The objective metric for the new tuning job must be the same as for all
* parent jobs.
*
*
* @see HyperParameterTuningJobWarmStartType
*/
public final String warmStartTypeAsString() {
return warmStartType;
}
@Override
public Builder toBuilder() {
return new BuilderImpl(this);
}
public static Builder builder() {
return new BuilderImpl();
}
public static Class extends Builder> serializableBuilderClass() {
return BuilderImpl.class;
}
@Override
public final int hashCode() {
int hashCode = 1;
hashCode = 31 * hashCode
+ Objects.hashCode(hasParentHyperParameterTuningJobs() ? parentHyperParameterTuningJobs() : null);
hashCode = 31 * hashCode + Objects.hashCode(warmStartTypeAsString());
return hashCode;
}
@Override
public final boolean equals(Object obj) {
return equalsBySdkFields(obj);
}
@Override
public final boolean equalsBySdkFields(Object obj) {
if (this == obj) {
return true;
}
if (obj == null) {
return false;
}
if (!(obj instanceof HyperParameterTuningJobWarmStartConfig)) {
return false;
}
HyperParameterTuningJobWarmStartConfig other = (HyperParameterTuningJobWarmStartConfig) obj;
return hasParentHyperParameterTuningJobs() == other.hasParentHyperParameterTuningJobs()
&& Objects.equals(parentHyperParameterTuningJobs(), other.parentHyperParameterTuningJobs())
&& Objects.equals(warmStartTypeAsString(), other.warmStartTypeAsString());
}
/**
* 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("HyperParameterTuningJobWarmStartConfig")
.add("ParentHyperParameterTuningJobs",
hasParentHyperParameterTuningJobs() ? parentHyperParameterTuningJobs() : null)
.add("WarmStartType", warmStartTypeAsString()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "ParentHyperParameterTuningJobs":
return Optional.ofNullable(clazz.cast(parentHyperParameterTuningJobs()));
case "WarmStartType":
return Optional.ofNullable(clazz.cast(warmStartTypeAsString()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function