{-# 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.HyperParameterTuningJobWarmStartConfig
-- Copyright   : (c) 2013-2021 Brendan Hay
-- License     : Mozilla Public License, v. 2.0.
-- Maintainer  : Brendan Hay <brendan.g.hay+amazonka@gmail.com>
-- Stability   : auto-generated
-- Portability : non-portable (GHC extensions)
module Amazonka.SageMaker.Types.HyperParameterTuningJobWarmStartConfig where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SageMaker.Types.HyperParameterTuningJobWarmStartType
import Amazonka.SageMaker.Types.ParentHyperParameterTuningJob

-- | 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.
--
-- /See:/ 'newHyperParameterTuningJobWarmStartConfig' smart constructor.
data HyperParameterTuningJobWarmStartConfig = HyperParameterTuningJobWarmStartConfig'
  { -- | 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
    -- <https://docs.aws.amazon.com/sagemaker/latest/dg/automatic-model-tuning-warm-start.html 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.
    HyperParameterTuningJobWarmStartConfig
-> NonEmpty ParentHyperParameterTuningJob
parentHyperParameterTuningJobs :: Prelude.NonEmpty ParentHyperParameterTuningJob,
    -- | 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.
    HyperParameterTuningJobWarmStartConfig
-> HyperParameterTuningJobWarmStartType
warmStartType :: HyperParameterTuningJobWarmStartType
  }
  deriving (HyperParameterTuningJobWarmStartConfig
-> HyperParameterTuningJobWarmStartConfig -> Bool
(HyperParameterTuningJobWarmStartConfig
 -> HyperParameterTuningJobWarmStartConfig -> Bool)
-> (HyperParameterTuningJobWarmStartConfig
    -> HyperParameterTuningJobWarmStartConfig -> Bool)
-> Eq HyperParameterTuningJobWarmStartConfig
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HyperParameterTuningJobWarmStartConfig
-> HyperParameterTuningJobWarmStartConfig -> Bool
$c/= :: HyperParameterTuningJobWarmStartConfig
-> HyperParameterTuningJobWarmStartConfig -> Bool
== :: HyperParameterTuningJobWarmStartConfig
-> HyperParameterTuningJobWarmStartConfig -> Bool
$c== :: HyperParameterTuningJobWarmStartConfig
-> HyperParameterTuningJobWarmStartConfig -> Bool
Prelude.Eq, ReadPrec [HyperParameterTuningJobWarmStartConfig]
ReadPrec HyperParameterTuningJobWarmStartConfig
Int -> ReadS HyperParameterTuningJobWarmStartConfig
ReadS [HyperParameterTuningJobWarmStartConfig]
(Int -> ReadS HyperParameterTuningJobWarmStartConfig)
-> ReadS [HyperParameterTuningJobWarmStartConfig]
-> ReadPrec HyperParameterTuningJobWarmStartConfig
-> ReadPrec [HyperParameterTuningJobWarmStartConfig]
-> Read HyperParameterTuningJobWarmStartConfig
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HyperParameterTuningJobWarmStartConfig]
$creadListPrec :: ReadPrec [HyperParameterTuningJobWarmStartConfig]
readPrec :: ReadPrec HyperParameterTuningJobWarmStartConfig
$creadPrec :: ReadPrec HyperParameterTuningJobWarmStartConfig
readList :: ReadS [HyperParameterTuningJobWarmStartConfig]
$creadList :: ReadS [HyperParameterTuningJobWarmStartConfig]
readsPrec :: Int -> ReadS HyperParameterTuningJobWarmStartConfig
$creadsPrec :: Int -> ReadS HyperParameterTuningJobWarmStartConfig
Prelude.Read, Int -> HyperParameterTuningJobWarmStartConfig -> ShowS
[HyperParameterTuningJobWarmStartConfig] -> ShowS
HyperParameterTuningJobWarmStartConfig -> String
(Int -> HyperParameterTuningJobWarmStartConfig -> ShowS)
-> (HyperParameterTuningJobWarmStartConfig -> String)
-> ([HyperParameterTuningJobWarmStartConfig] -> ShowS)
-> Show HyperParameterTuningJobWarmStartConfig
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HyperParameterTuningJobWarmStartConfig] -> ShowS
$cshowList :: [HyperParameterTuningJobWarmStartConfig] -> ShowS
show :: HyperParameterTuningJobWarmStartConfig -> String
$cshow :: HyperParameterTuningJobWarmStartConfig -> String
showsPrec :: Int -> HyperParameterTuningJobWarmStartConfig -> ShowS
$cshowsPrec :: Int -> HyperParameterTuningJobWarmStartConfig -> ShowS
Prelude.Show, (forall x.
 HyperParameterTuningJobWarmStartConfig
 -> Rep HyperParameterTuningJobWarmStartConfig x)
-> (forall x.
    Rep HyperParameterTuningJobWarmStartConfig x
    -> HyperParameterTuningJobWarmStartConfig)
-> Generic HyperParameterTuningJobWarmStartConfig
forall x.
Rep HyperParameterTuningJobWarmStartConfig x
-> HyperParameterTuningJobWarmStartConfig
forall x.
HyperParameterTuningJobWarmStartConfig
-> Rep HyperParameterTuningJobWarmStartConfig x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep HyperParameterTuningJobWarmStartConfig x
-> HyperParameterTuningJobWarmStartConfig
$cfrom :: forall x.
HyperParameterTuningJobWarmStartConfig
-> Rep HyperParameterTuningJobWarmStartConfig x
Prelude.Generic)

-- |
-- Create a value of 'HyperParameterTuningJobWarmStartConfig' 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:
--
-- 'parentHyperParameterTuningJobs', 'hyperParameterTuningJobWarmStartConfig_parentHyperParameterTuningJobs' - 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
-- <https://docs.aws.amazon.com/sagemaker/latest/dg/automatic-model-tuning-warm-start.html 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.
--
-- 'warmStartType', 'hyperParameterTuningJobWarmStartConfig_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.
newHyperParameterTuningJobWarmStartConfig ::
  -- | 'parentHyperParameterTuningJobs'
  Prelude.NonEmpty ParentHyperParameterTuningJob ->
  -- | 'warmStartType'
  HyperParameterTuningJobWarmStartType ->
  HyperParameterTuningJobWarmStartConfig
newHyperParameterTuningJobWarmStartConfig :: NonEmpty ParentHyperParameterTuningJob
-> HyperParameterTuningJobWarmStartType
-> HyperParameterTuningJobWarmStartConfig
newHyperParameterTuningJobWarmStartConfig
  NonEmpty ParentHyperParameterTuningJob
pParentHyperParameterTuningJobs_
  HyperParameterTuningJobWarmStartType
pWarmStartType_ =
    HyperParameterTuningJobWarmStartConfig' :: NonEmpty ParentHyperParameterTuningJob
-> HyperParameterTuningJobWarmStartType
-> HyperParameterTuningJobWarmStartConfig
HyperParameterTuningJobWarmStartConfig'
      { $sel:parentHyperParameterTuningJobs:HyperParameterTuningJobWarmStartConfig' :: NonEmpty ParentHyperParameterTuningJob
parentHyperParameterTuningJobs =
          Tagged
  (NonEmpty ParentHyperParameterTuningJob)
  (Identity (NonEmpty ParentHyperParameterTuningJob))
-> Tagged
     (NonEmpty ParentHyperParameterTuningJob)
     (Identity (NonEmpty ParentHyperParameterTuningJob))
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced
            (Tagged
   (NonEmpty ParentHyperParameterTuningJob)
   (Identity (NonEmpty ParentHyperParameterTuningJob))
 -> Tagged
      (NonEmpty ParentHyperParameterTuningJob)
      (Identity (NonEmpty ParentHyperParameterTuningJob)))
-> NonEmpty ParentHyperParameterTuningJob
-> NonEmpty ParentHyperParameterTuningJob
forall t b. AReview t b -> b -> t
Lens.# NonEmpty ParentHyperParameterTuningJob
pParentHyperParameterTuningJobs_,
        $sel:warmStartType:HyperParameterTuningJobWarmStartConfig' :: HyperParameterTuningJobWarmStartType
warmStartType = HyperParameterTuningJobWarmStartType
pWarmStartType_
      }

-- | 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
-- <https://docs.aws.amazon.com/sagemaker/latest/dg/automatic-model-tuning-warm-start.html 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.
hyperParameterTuningJobWarmStartConfig_parentHyperParameterTuningJobs :: Lens.Lens' HyperParameterTuningJobWarmStartConfig (Prelude.NonEmpty ParentHyperParameterTuningJob)
hyperParameterTuningJobWarmStartConfig_parentHyperParameterTuningJobs :: (NonEmpty ParentHyperParameterTuningJob
 -> f (NonEmpty ParentHyperParameterTuningJob))
-> HyperParameterTuningJobWarmStartConfig
-> f HyperParameterTuningJobWarmStartConfig
hyperParameterTuningJobWarmStartConfig_parentHyperParameterTuningJobs = (HyperParameterTuningJobWarmStartConfig
 -> NonEmpty ParentHyperParameterTuningJob)
-> (HyperParameterTuningJobWarmStartConfig
    -> NonEmpty ParentHyperParameterTuningJob
    -> HyperParameterTuningJobWarmStartConfig)
-> Lens
     HyperParameterTuningJobWarmStartConfig
     HyperParameterTuningJobWarmStartConfig
     (NonEmpty ParentHyperParameterTuningJob)
     (NonEmpty ParentHyperParameterTuningJob)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HyperParameterTuningJobWarmStartConfig' {NonEmpty ParentHyperParameterTuningJob
parentHyperParameterTuningJobs :: NonEmpty ParentHyperParameterTuningJob
$sel:parentHyperParameterTuningJobs:HyperParameterTuningJobWarmStartConfig' :: HyperParameterTuningJobWarmStartConfig
-> NonEmpty ParentHyperParameterTuningJob
parentHyperParameterTuningJobs} -> NonEmpty ParentHyperParameterTuningJob
parentHyperParameterTuningJobs) (\s :: HyperParameterTuningJobWarmStartConfig
s@HyperParameterTuningJobWarmStartConfig' {} NonEmpty ParentHyperParameterTuningJob
a -> HyperParameterTuningJobWarmStartConfig
s {$sel:parentHyperParameterTuningJobs:HyperParameterTuningJobWarmStartConfig' :: NonEmpty ParentHyperParameterTuningJob
parentHyperParameterTuningJobs = NonEmpty ParentHyperParameterTuningJob
a} :: HyperParameterTuningJobWarmStartConfig) ((NonEmpty ParentHyperParameterTuningJob
  -> f (NonEmpty ParentHyperParameterTuningJob))
 -> HyperParameterTuningJobWarmStartConfig
 -> f HyperParameterTuningJobWarmStartConfig)
-> ((NonEmpty ParentHyperParameterTuningJob
     -> f (NonEmpty ParentHyperParameterTuningJob))
    -> NonEmpty ParentHyperParameterTuningJob
    -> f (NonEmpty ParentHyperParameterTuningJob))
-> (NonEmpty ParentHyperParameterTuningJob
    -> f (NonEmpty ParentHyperParameterTuningJob))
-> HyperParameterTuningJobWarmStartConfig
-> f HyperParameterTuningJobWarmStartConfig
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. (NonEmpty ParentHyperParameterTuningJob
 -> f (NonEmpty ParentHyperParameterTuningJob))
-> NonEmpty ParentHyperParameterTuningJob
-> f (NonEmpty ParentHyperParameterTuningJob)
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | 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.
hyperParameterTuningJobWarmStartConfig_warmStartType :: Lens.Lens' HyperParameterTuningJobWarmStartConfig HyperParameterTuningJobWarmStartType
hyperParameterTuningJobWarmStartConfig_warmStartType :: (HyperParameterTuningJobWarmStartType
 -> f HyperParameterTuningJobWarmStartType)
-> HyperParameterTuningJobWarmStartConfig
-> f HyperParameterTuningJobWarmStartConfig
hyperParameterTuningJobWarmStartConfig_warmStartType = (HyperParameterTuningJobWarmStartConfig
 -> HyperParameterTuningJobWarmStartType)
-> (HyperParameterTuningJobWarmStartConfig
    -> HyperParameterTuningJobWarmStartType
    -> HyperParameterTuningJobWarmStartConfig)
-> Lens
     HyperParameterTuningJobWarmStartConfig
     HyperParameterTuningJobWarmStartConfig
     HyperParameterTuningJobWarmStartType
     HyperParameterTuningJobWarmStartType
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HyperParameterTuningJobWarmStartConfig' {HyperParameterTuningJobWarmStartType
warmStartType :: HyperParameterTuningJobWarmStartType
$sel:warmStartType:HyperParameterTuningJobWarmStartConfig' :: HyperParameterTuningJobWarmStartConfig
-> HyperParameterTuningJobWarmStartType
warmStartType} -> HyperParameterTuningJobWarmStartType
warmStartType) (\s :: HyperParameterTuningJobWarmStartConfig
s@HyperParameterTuningJobWarmStartConfig' {} HyperParameterTuningJobWarmStartType
a -> HyperParameterTuningJobWarmStartConfig
s {$sel:warmStartType:HyperParameterTuningJobWarmStartConfig' :: HyperParameterTuningJobWarmStartType
warmStartType = HyperParameterTuningJobWarmStartType
a} :: HyperParameterTuningJobWarmStartConfig)

instance
  Core.FromJSON
    HyperParameterTuningJobWarmStartConfig
  where
  parseJSON :: Value -> Parser HyperParameterTuningJobWarmStartConfig
parseJSON =
    String
-> (Object -> Parser HyperParameterTuningJobWarmStartConfig)
-> Value
-> Parser HyperParameterTuningJobWarmStartConfig
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"HyperParameterTuningJobWarmStartConfig"
      ( \Object
x ->
          NonEmpty ParentHyperParameterTuningJob
-> HyperParameterTuningJobWarmStartType
-> HyperParameterTuningJobWarmStartConfig
HyperParameterTuningJobWarmStartConfig'
            (NonEmpty ParentHyperParameterTuningJob
 -> HyperParameterTuningJobWarmStartType
 -> HyperParameterTuningJobWarmStartConfig)
-> Parser (NonEmpty ParentHyperParameterTuningJob)
-> Parser
     (HyperParameterTuningJobWarmStartType
      -> HyperParameterTuningJobWarmStartConfig)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (NonEmpty ParentHyperParameterTuningJob)
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"ParentHyperParameterTuningJobs")
            Parser
  (HyperParameterTuningJobWarmStartType
   -> HyperParameterTuningJobWarmStartConfig)
-> Parser HyperParameterTuningJobWarmStartType
-> Parser HyperParameterTuningJobWarmStartConfig
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser HyperParameterTuningJobWarmStartType
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"WarmStartType")
      )

instance
  Prelude.Hashable
    HyperParameterTuningJobWarmStartConfig

instance
  Prelude.NFData
    HyperParameterTuningJobWarmStartConfig

instance
  Core.ToJSON
    HyperParameterTuningJobWarmStartConfig
  where
  toJSON :: HyperParameterTuningJobWarmStartConfig -> Value
toJSON HyperParameterTuningJobWarmStartConfig' {NonEmpty ParentHyperParameterTuningJob
HyperParameterTuningJobWarmStartType
warmStartType :: HyperParameterTuningJobWarmStartType
parentHyperParameterTuningJobs :: NonEmpty ParentHyperParameterTuningJob
$sel:warmStartType:HyperParameterTuningJobWarmStartConfig' :: HyperParameterTuningJobWarmStartConfig
-> HyperParameterTuningJobWarmStartType
$sel:parentHyperParameterTuningJobs:HyperParameterTuningJobWarmStartConfig' :: HyperParameterTuningJobWarmStartConfig
-> NonEmpty ParentHyperParameterTuningJob
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              ( Text
"ParentHyperParameterTuningJobs"
                  Text -> NonEmpty ParentHyperParameterTuningJob -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= NonEmpty ParentHyperParameterTuningJob
parentHyperParameterTuningJobs
              ),
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"WarmStartType" Text -> HyperParameterTuningJobWarmStartType -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= HyperParameterTuningJobWarmStartType
warmStartType)
          ]
      )