amazonka-sagemaker-2.0: gen/Amazonka/SageMaker/Types/TrainingSpecification.hs
{-# LANGUAGE DeriveGeneric #-}
{-# LANGUAGE DuplicateRecordFields #-}
{-# LANGUAGE NamedFieldPuns #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE RecordWildCards #-}
{-# LANGUAGE StrictData #-}
{-# LANGUAGE NoImplicitPrelude #-}
{-# OPTIONS_GHC -fno-warn-unused-imports #-}
{-# OPTIONS_GHC -fno-warn-unused-matches #-}
-- Derived from AWS service descriptions, licensed under Apache 2.0.
-- |
-- Module : Amazonka.SageMaker.Types.TrainingSpecification
-- Copyright : (c) 2013-2023 Brendan Hay
-- License : Mozilla Public License, v. 2.0.
-- Maintainer : Brendan Hay
-- Stability : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SageMaker.Types.TrainingSpecification where
import qualified Amazonka.Core as Core
import qualified Amazonka.Core.Lens.Internal as Lens
import qualified Amazonka.Data as Data
import qualified Amazonka.Prelude as Prelude
import Amazonka.SageMaker.Types.ChannelSpecification
import Amazonka.SageMaker.Types.HyperParameterSpecification
import Amazonka.SageMaker.Types.HyperParameterTuningJobObjective
import Amazonka.SageMaker.Types.MetricDefinition
import Amazonka.SageMaker.Types.TrainingInstanceType
-- | Defines how the algorithm is used for a training job.
--
-- /See:/ 'newTrainingSpecification' smart constructor.
data TrainingSpecification = TrainingSpecification'
{ -- | A list of @MetricDefinition@ objects, which are used for parsing metrics
-- generated by the algorithm.
metricDefinitions :: Prelude.Maybe [MetricDefinition],
-- | A list of the @HyperParameterSpecification@ objects, that define the
-- supported hyperparameters. This is required if the algorithm supports
-- automatic model tuning.>
supportedHyperParameters :: Prelude.Maybe [HyperParameterSpecification],
-- | A list of the metrics that the algorithm emits that can be used as the
-- objective metric in a hyperparameter tuning job.
supportedTuningJobObjectiveMetrics :: Prelude.Maybe [HyperParameterTuningJobObjective],
-- | Indicates whether the algorithm supports distributed training. If set to
-- false, buyers can\'t request more than one instance during training.
supportsDistributedTraining :: Prelude.Maybe Prelude.Bool,
-- | An MD5 hash of the training algorithm that identifies the Docker image
-- used for training.
trainingImageDigest :: Prelude.Maybe Prelude.Text,
-- | The Amazon ECR registry path of the Docker image that contains the
-- training algorithm.
trainingImage :: Prelude.Text,
-- | A list of the instance types that this algorithm can use for training.
supportedTrainingInstanceTypes :: [TrainingInstanceType],
-- | A list of @ChannelSpecification@ objects, which specify the input
-- sources to be used by the algorithm.
trainingChannels :: Prelude.NonEmpty ChannelSpecification
}
deriving (Prelude.Eq, Prelude.Read, Prelude.Show, Prelude.Generic)
-- |
-- Create a value of 'TrainingSpecification' with all optional fields omitted.
--
-- Use <https://hackage.haskell.org/package/generic-lens generic-lens> or <https://hackage.haskell.org/package/optics optics> to modify other optional fields.
--
-- The following record fields are available, with the corresponding lenses provided
-- for backwards compatibility:
--
-- 'metricDefinitions', 'trainingSpecification_metricDefinitions' - A list of @MetricDefinition@ objects, which are used for parsing metrics
-- generated by the algorithm.
--
-- 'supportedHyperParameters', 'trainingSpecification_supportedHyperParameters' - A list of the @HyperParameterSpecification@ objects, that define the
-- supported hyperparameters. This is required if the algorithm supports
-- automatic model tuning.>
--
-- 'supportedTuningJobObjectiveMetrics', 'trainingSpecification_supportedTuningJobObjectiveMetrics' - A list of the metrics that the algorithm emits that can be used as the
-- objective metric in a hyperparameter tuning job.
--
-- 'supportsDistributedTraining', 'trainingSpecification_supportsDistributedTraining' - Indicates whether the algorithm supports distributed training. If set to
-- false, buyers can\'t request more than one instance during training.
--
-- 'trainingImageDigest', 'trainingSpecification_trainingImageDigest' - An MD5 hash of the training algorithm that identifies the Docker image
-- used for training.
--
-- 'trainingImage', 'trainingSpecification_trainingImage' - The Amazon ECR registry path of the Docker image that contains the
-- training algorithm.
--
-- 'supportedTrainingInstanceTypes', 'trainingSpecification_supportedTrainingInstanceTypes' - A list of the instance types that this algorithm can use for training.
--
-- 'trainingChannels', 'trainingSpecification_trainingChannels' - A list of @ChannelSpecification@ objects, which specify the input
-- sources to be used by the algorithm.
newTrainingSpecification ::
-- | 'trainingImage'
Prelude.Text ->
-- | 'trainingChannels'
Prelude.NonEmpty ChannelSpecification ->
TrainingSpecification
newTrainingSpecification
pTrainingImage_
pTrainingChannels_ =
TrainingSpecification'
{ metricDefinitions =
Prelude.Nothing,
supportedHyperParameters = Prelude.Nothing,
supportedTuningJobObjectiveMetrics = Prelude.Nothing,
supportsDistributedTraining = Prelude.Nothing,
trainingImageDigest = Prelude.Nothing,
trainingImage = pTrainingImage_,
supportedTrainingInstanceTypes = Prelude.mempty,
trainingChannels =
Lens.coerced Lens.# pTrainingChannels_
}
-- | A list of @MetricDefinition@ objects, which are used for parsing metrics
-- generated by the algorithm.
trainingSpecification_metricDefinitions :: Lens.Lens' TrainingSpecification (Prelude.Maybe [MetricDefinition])
trainingSpecification_metricDefinitions = Lens.lens (\TrainingSpecification' {metricDefinitions} -> metricDefinitions) (\s@TrainingSpecification' {} a -> s {metricDefinitions = a} :: TrainingSpecification) Prelude.. Lens.mapping Lens.coerced
-- | A list of the @HyperParameterSpecification@ objects, that define the
-- supported hyperparameters. This is required if the algorithm supports
-- automatic model tuning.>
trainingSpecification_supportedHyperParameters :: Lens.Lens' TrainingSpecification (Prelude.Maybe [HyperParameterSpecification])
trainingSpecification_supportedHyperParameters = Lens.lens (\TrainingSpecification' {supportedHyperParameters} -> supportedHyperParameters) (\s@TrainingSpecification' {} a -> s {supportedHyperParameters = a} :: TrainingSpecification) Prelude.. Lens.mapping Lens.coerced
-- | A list of the metrics that the algorithm emits that can be used as the
-- objective metric in a hyperparameter tuning job.
trainingSpecification_supportedTuningJobObjectiveMetrics :: Lens.Lens' TrainingSpecification (Prelude.Maybe [HyperParameterTuningJobObjective])
trainingSpecification_supportedTuningJobObjectiveMetrics = Lens.lens (\TrainingSpecification' {supportedTuningJobObjectiveMetrics} -> supportedTuningJobObjectiveMetrics) (\s@TrainingSpecification' {} a -> s {supportedTuningJobObjectiveMetrics = a} :: TrainingSpecification) Prelude.. Lens.mapping Lens.coerced
-- | Indicates whether the algorithm supports distributed training. If set to
-- false, buyers can\'t request more than one instance during training.
trainingSpecification_supportsDistributedTraining :: Lens.Lens' TrainingSpecification (Prelude.Maybe Prelude.Bool)
trainingSpecification_supportsDistributedTraining = Lens.lens (\TrainingSpecification' {supportsDistributedTraining} -> supportsDistributedTraining) (\s@TrainingSpecification' {} a -> s {supportsDistributedTraining = a} :: TrainingSpecification)
-- | An MD5 hash of the training algorithm that identifies the Docker image
-- used for training.
trainingSpecification_trainingImageDigest :: Lens.Lens' TrainingSpecification (Prelude.Maybe Prelude.Text)
trainingSpecification_trainingImageDigest = Lens.lens (\TrainingSpecification' {trainingImageDigest} -> trainingImageDigest) (\s@TrainingSpecification' {} a -> s {trainingImageDigest = a} :: TrainingSpecification)
-- | The Amazon ECR registry path of the Docker image that contains the
-- training algorithm.
trainingSpecification_trainingImage :: Lens.Lens' TrainingSpecification Prelude.Text
trainingSpecification_trainingImage = Lens.lens (\TrainingSpecification' {trainingImage} -> trainingImage) (\s@TrainingSpecification' {} a -> s {trainingImage = a} :: TrainingSpecification)
-- | A list of the instance types that this algorithm can use for training.
trainingSpecification_supportedTrainingInstanceTypes :: Lens.Lens' TrainingSpecification [TrainingInstanceType]
trainingSpecification_supportedTrainingInstanceTypes = Lens.lens (\TrainingSpecification' {supportedTrainingInstanceTypes} -> supportedTrainingInstanceTypes) (\s@TrainingSpecification' {} a -> s {supportedTrainingInstanceTypes = a} :: TrainingSpecification) Prelude.. Lens.coerced
-- | A list of @ChannelSpecification@ objects, which specify the input
-- sources to be used by the algorithm.
trainingSpecification_trainingChannels :: Lens.Lens' TrainingSpecification (Prelude.NonEmpty ChannelSpecification)
trainingSpecification_trainingChannels = Lens.lens (\TrainingSpecification' {trainingChannels} -> trainingChannels) (\s@TrainingSpecification' {} a -> s {trainingChannels = a} :: TrainingSpecification) Prelude.. Lens.coerced
instance Data.FromJSON TrainingSpecification where
parseJSON =
Data.withObject
"TrainingSpecification"
( \x ->
TrainingSpecification'
Prelude.<$> ( x
Data..:? "MetricDefinitions"
Data..!= Prelude.mempty
)
Prelude.<*> ( x
Data..:? "SupportedHyperParameters"
Data..!= Prelude.mempty
)
Prelude.<*> ( x
Data..:? "SupportedTuningJobObjectiveMetrics"
Data..!= Prelude.mempty
)
Prelude.<*> (x Data..:? "SupportsDistributedTraining")
Prelude.<*> (x Data..:? "TrainingImageDigest")
Prelude.<*> (x Data..: "TrainingImage")
Prelude.<*> ( x
Data..:? "SupportedTrainingInstanceTypes"
Data..!= Prelude.mempty
)
Prelude.<*> (x Data..: "TrainingChannels")
)
instance Prelude.Hashable TrainingSpecification where
hashWithSalt _salt TrainingSpecification' {..} =
_salt
`Prelude.hashWithSalt` metricDefinitions
`Prelude.hashWithSalt` supportedHyperParameters
`Prelude.hashWithSalt` supportedTuningJobObjectiveMetrics
`Prelude.hashWithSalt` supportsDistributedTraining
`Prelude.hashWithSalt` trainingImageDigest
`Prelude.hashWithSalt` trainingImage
`Prelude.hashWithSalt` supportedTrainingInstanceTypes
`Prelude.hashWithSalt` trainingChannels
instance Prelude.NFData TrainingSpecification where
rnf TrainingSpecification' {..} =
Prelude.rnf metricDefinitions
`Prelude.seq` Prelude.rnf supportedHyperParameters
`Prelude.seq` Prelude.rnf supportedTuningJobObjectiveMetrics
`Prelude.seq` Prelude.rnf supportsDistributedTraining
`Prelude.seq` Prelude.rnf trainingImageDigest
`Prelude.seq` Prelude.rnf trainingImage
`Prelude.seq` Prelude.rnf supportedTrainingInstanceTypes
`Prelude.seq` Prelude.rnf trainingChannels
instance Data.ToJSON TrainingSpecification where
toJSON TrainingSpecification' {..} =
Data.object
( Prelude.catMaybes
[ ("MetricDefinitions" Data..=)
Prelude.<$> metricDefinitions,
("SupportedHyperParameters" Data..=)
Prelude.<$> supportedHyperParameters,
("SupportedTuningJobObjectiveMetrics" Data..=)
Prelude.<$> supportedTuningJobObjectiveMetrics,
("SupportsDistributedTraining" Data..=)
Prelude.<$> supportsDistributedTraining,
("TrainingImageDigest" Data..=)
Prelude.<$> trainingImageDigest,
Prelude.Just ("TrainingImage" Data..= trainingImage),
Prelude.Just
( "SupportedTrainingInstanceTypes"
Data..= supportedTrainingInstanceTypes
),
Prelude.Just
("TrainingChannels" Data..= trainingChannels)
]
)