
software.amazon.awssdk.services.sagemaker.model.ShuffleConfig Maven / Gradle / Ivy
/*
* 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.Collections;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import java.util.function.BiConsumer;
import java.util.function.Function;
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.LocationTrait;
import software.amazon.awssdk.utils.ToString;
import software.amazon.awssdk.utils.builder.CopyableBuilder;
import software.amazon.awssdk.utils.builder.ToCopyableBuilder;
/**
*
* A configuration for a shuffle option for input data in a channel. If you use S3Prefix
for
* S3DataType
, the results of the S3 key prefix matches are shuffled. If you use ManifestFile
,
* the order of the S3 object references in the ManifestFile
is shuffled. If you use
* AugmentedManifestFile
, the order of the JSON lines in the AugmentedManifestFile
is
* shuffled. The shuffling order is determined using the Seed
value.
*
*
* For Pipe input mode, when ShuffleConfig
is specified shuffling is done at the start of every epoch. With
* large datasets, this ensures that the order of the training data is different for each epoch, and it helps reduce
* bias and possible overfitting. In a multi-node training job when ShuffleConfig
is combined with
* S3DataDistributionType
of ShardedByS3Key
, the data is shuffled across nodes so that the
* content sent to a particular node on the first epoch might be sent to a different node on the second epoch.
*
*/
@Generated("software.amazon.awssdk:codegen")
public final class ShuffleConfig implements SdkPojo, Serializable, ToCopyableBuilder {
private static final SdkField SEED_FIELD = SdkField. builder(MarshallingType.LONG).memberName("Seed")
.getter(getter(ShuffleConfig::seed)).setter(setter(Builder::seed))
.traits(LocationTrait.builder().location(MarshallLocation.PAYLOAD).locationName("Seed").build()).build();
private static final List> SDK_FIELDS = Collections.unmodifiableList(Arrays.asList(SEED_FIELD));
private static final long serialVersionUID = 1L;
private final Long seed;
private ShuffleConfig(BuilderImpl builder) {
this.seed = builder.seed;
}
/**
*
* Determines the shuffling order in ShuffleConfig
value.
*
*
* @return Determines the shuffling order in ShuffleConfig
value.
*/
public final Long seed() {
return seed;
}
@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(seed());
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 ShuffleConfig)) {
return false;
}
ShuffleConfig other = (ShuffleConfig) obj;
return Objects.equals(seed(), other.seed());
}
/**
* 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("ShuffleConfig").add("Seed", seed()).build();
}
public final Optional getValueForField(String fieldName, Class clazz) {
switch (fieldName) {
case "Seed":
return Optional.ofNullable(clazz.cast(seed()));
default:
return Optional.empty();
}
}
@Override
public final List> sdkFields() {
return SDK_FIELDS;
}
private static Function