{-# 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.HyperParameterAlgorithmSpecification
-- 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.HyperParameterAlgorithmSpecification where

import qualified Amazonka.Core as Core
import qualified Amazonka.Lens as Lens
import qualified Amazonka.Prelude as Prelude
import Amazonka.SageMaker.Types.MetricDefinition
import Amazonka.SageMaker.Types.TrainingInputMode

-- | Specifies which training algorithm to use for training jobs that a
-- hyperparameter tuning job launches and the metrics to monitor.
--
-- /See:/ 'newHyperParameterAlgorithmSpecification' smart constructor.
data HyperParameterAlgorithmSpecification = HyperParameterAlgorithmSpecification'
  { -- | The name of the resource algorithm to use for the hyperparameter tuning
    -- job. If you specify a value for this parameter, do not specify a value
    -- for @TrainingImage@.
    HyperParameterAlgorithmSpecification -> Maybe Text
algorithmName :: Prelude.Maybe Prelude.Text,
    -- | The registry path of the Docker image that contains the training
    -- algorithm. For information about Docker registry paths for built-in
    -- algorithms, see
    -- <https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-algo-docker-registry-paths.html Algorithms Provided by Amazon SageMaker: Common Parameters>.
    -- Amazon SageMaker supports both @registry\/repository[:tag]@ and
    -- @registry\/repository[\@digest]@ image path formats. For more
    -- information, see
    -- <https://docs.aws.amazon.com/sagemaker/latest/dg/your-algorithms.html Using Your Own Algorithms with Amazon SageMaker>.
    HyperParameterAlgorithmSpecification -> Maybe Text
trainingImage :: Prelude.Maybe Prelude.Text,
    -- | An array of MetricDefinition objects that specify the metrics that the
    -- algorithm emits.
    HyperParameterAlgorithmSpecification -> Maybe [MetricDefinition]
metricDefinitions :: Prelude.Maybe [MetricDefinition],
    HyperParameterAlgorithmSpecification -> TrainingInputMode
trainingInputMode :: TrainingInputMode
  }
  deriving (HyperParameterAlgorithmSpecification
-> HyperParameterAlgorithmSpecification -> Bool
(HyperParameterAlgorithmSpecification
 -> HyperParameterAlgorithmSpecification -> Bool)
-> (HyperParameterAlgorithmSpecification
    -> HyperParameterAlgorithmSpecification -> Bool)
-> Eq HyperParameterAlgorithmSpecification
forall a. (a -> a -> Bool) -> (a -> a -> Bool) -> Eq a
/= :: HyperParameterAlgorithmSpecification
-> HyperParameterAlgorithmSpecification -> Bool
$c/= :: HyperParameterAlgorithmSpecification
-> HyperParameterAlgorithmSpecification -> Bool
== :: HyperParameterAlgorithmSpecification
-> HyperParameterAlgorithmSpecification -> Bool
$c== :: HyperParameterAlgorithmSpecification
-> HyperParameterAlgorithmSpecification -> Bool
Prelude.Eq, ReadPrec [HyperParameterAlgorithmSpecification]
ReadPrec HyperParameterAlgorithmSpecification
Int -> ReadS HyperParameterAlgorithmSpecification
ReadS [HyperParameterAlgorithmSpecification]
(Int -> ReadS HyperParameterAlgorithmSpecification)
-> ReadS [HyperParameterAlgorithmSpecification]
-> ReadPrec HyperParameterAlgorithmSpecification
-> ReadPrec [HyperParameterAlgorithmSpecification]
-> Read HyperParameterAlgorithmSpecification
forall a.
(Int -> ReadS a)
-> ReadS [a] -> ReadPrec a -> ReadPrec [a] -> Read a
readListPrec :: ReadPrec [HyperParameterAlgorithmSpecification]
$creadListPrec :: ReadPrec [HyperParameterAlgorithmSpecification]
readPrec :: ReadPrec HyperParameterAlgorithmSpecification
$creadPrec :: ReadPrec HyperParameterAlgorithmSpecification
readList :: ReadS [HyperParameterAlgorithmSpecification]
$creadList :: ReadS [HyperParameterAlgorithmSpecification]
readsPrec :: Int -> ReadS HyperParameterAlgorithmSpecification
$creadsPrec :: Int -> ReadS HyperParameterAlgorithmSpecification
Prelude.Read, Int -> HyperParameterAlgorithmSpecification -> ShowS
[HyperParameterAlgorithmSpecification] -> ShowS
HyperParameterAlgorithmSpecification -> String
(Int -> HyperParameterAlgorithmSpecification -> ShowS)
-> (HyperParameterAlgorithmSpecification -> String)
-> ([HyperParameterAlgorithmSpecification] -> ShowS)
-> Show HyperParameterAlgorithmSpecification
forall a.
(Int -> a -> ShowS) -> (a -> String) -> ([a] -> ShowS) -> Show a
showList :: [HyperParameterAlgorithmSpecification] -> ShowS
$cshowList :: [HyperParameterAlgorithmSpecification] -> ShowS
show :: HyperParameterAlgorithmSpecification -> String
$cshow :: HyperParameterAlgorithmSpecification -> String
showsPrec :: Int -> HyperParameterAlgorithmSpecification -> ShowS
$cshowsPrec :: Int -> HyperParameterAlgorithmSpecification -> ShowS
Prelude.Show, (forall x.
 HyperParameterAlgorithmSpecification
 -> Rep HyperParameterAlgorithmSpecification x)
-> (forall x.
    Rep HyperParameterAlgorithmSpecification x
    -> HyperParameterAlgorithmSpecification)
-> Generic HyperParameterAlgorithmSpecification
forall x.
Rep HyperParameterAlgorithmSpecification x
-> HyperParameterAlgorithmSpecification
forall x.
HyperParameterAlgorithmSpecification
-> Rep HyperParameterAlgorithmSpecification x
forall a.
(forall x. a -> Rep a x) -> (forall x. Rep a x -> a) -> Generic a
$cto :: forall x.
Rep HyperParameterAlgorithmSpecification x
-> HyperParameterAlgorithmSpecification
$cfrom :: forall x.
HyperParameterAlgorithmSpecification
-> Rep HyperParameterAlgorithmSpecification x
Prelude.Generic)

-- |
-- Create a value of 'HyperParameterAlgorithmSpecification' 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:
--
-- 'algorithmName', 'hyperParameterAlgorithmSpecification_algorithmName' - The name of the resource algorithm to use for the hyperparameter tuning
-- job. If you specify a value for this parameter, do not specify a value
-- for @TrainingImage@.
--
-- 'trainingImage', 'hyperParameterAlgorithmSpecification_trainingImage' - The registry path of the Docker image that contains the training
-- algorithm. For information about Docker registry paths for built-in
-- algorithms, see
-- <https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-algo-docker-registry-paths.html Algorithms Provided by Amazon SageMaker: Common Parameters>.
-- Amazon SageMaker supports both @registry\/repository[:tag]@ and
-- @registry\/repository[\@digest]@ image path formats. For more
-- information, see
-- <https://docs.aws.amazon.com/sagemaker/latest/dg/your-algorithms.html Using Your Own Algorithms with Amazon SageMaker>.
--
-- 'metricDefinitions', 'hyperParameterAlgorithmSpecification_metricDefinitions' - An array of MetricDefinition objects that specify the metrics that the
-- algorithm emits.
--
-- 'trainingInputMode', 'hyperParameterAlgorithmSpecification_trainingInputMode' - Undocumented member.
newHyperParameterAlgorithmSpecification ::
  -- | 'trainingInputMode'
  TrainingInputMode ->
  HyperParameterAlgorithmSpecification
newHyperParameterAlgorithmSpecification :: TrainingInputMode -> HyperParameterAlgorithmSpecification
newHyperParameterAlgorithmSpecification
  TrainingInputMode
pTrainingInputMode_ =
    HyperParameterAlgorithmSpecification' :: Maybe Text
-> Maybe Text
-> Maybe [MetricDefinition]
-> TrainingInputMode
-> HyperParameterAlgorithmSpecification
HyperParameterAlgorithmSpecification'
      { $sel:algorithmName:HyperParameterAlgorithmSpecification' :: Maybe Text
algorithmName =
          Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:trainingImage:HyperParameterAlgorithmSpecification' :: Maybe Text
trainingImage = Maybe Text
forall a. Maybe a
Prelude.Nothing,
        $sel:metricDefinitions:HyperParameterAlgorithmSpecification' :: Maybe [MetricDefinition]
metricDefinitions = Maybe [MetricDefinition]
forall a. Maybe a
Prelude.Nothing,
        $sel:trainingInputMode:HyperParameterAlgorithmSpecification' :: TrainingInputMode
trainingInputMode =
          TrainingInputMode
pTrainingInputMode_
      }

-- | The name of the resource algorithm to use for the hyperparameter tuning
-- job. If you specify a value for this parameter, do not specify a value
-- for @TrainingImage@.
hyperParameterAlgorithmSpecification_algorithmName :: Lens.Lens' HyperParameterAlgorithmSpecification (Prelude.Maybe Prelude.Text)
hyperParameterAlgorithmSpecification_algorithmName :: (Maybe Text -> f (Maybe Text))
-> HyperParameterAlgorithmSpecification
-> f HyperParameterAlgorithmSpecification
hyperParameterAlgorithmSpecification_algorithmName = (HyperParameterAlgorithmSpecification -> Maybe Text)
-> (HyperParameterAlgorithmSpecification
    -> Maybe Text -> HyperParameterAlgorithmSpecification)
-> Lens
     HyperParameterAlgorithmSpecification
     HyperParameterAlgorithmSpecification
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HyperParameterAlgorithmSpecification' {Maybe Text
algorithmName :: Maybe Text
$sel:algorithmName:HyperParameterAlgorithmSpecification' :: HyperParameterAlgorithmSpecification -> Maybe Text
algorithmName} -> Maybe Text
algorithmName) (\s :: HyperParameterAlgorithmSpecification
s@HyperParameterAlgorithmSpecification' {} Maybe Text
a -> HyperParameterAlgorithmSpecification
s {$sel:algorithmName:HyperParameterAlgorithmSpecification' :: Maybe Text
algorithmName = Maybe Text
a} :: HyperParameterAlgorithmSpecification)

-- | The registry path of the Docker image that contains the training
-- algorithm. For information about Docker registry paths for built-in
-- algorithms, see
-- <https://docs.aws.amazon.com/sagemaker/latest/dg/sagemaker-algo-docker-registry-paths.html Algorithms Provided by Amazon SageMaker: Common Parameters>.
-- Amazon SageMaker supports both @registry\/repository[:tag]@ and
-- @registry\/repository[\@digest]@ image path formats. For more
-- information, see
-- <https://docs.aws.amazon.com/sagemaker/latest/dg/your-algorithms.html Using Your Own Algorithms with Amazon SageMaker>.
hyperParameterAlgorithmSpecification_trainingImage :: Lens.Lens' HyperParameterAlgorithmSpecification (Prelude.Maybe Prelude.Text)
hyperParameterAlgorithmSpecification_trainingImage :: (Maybe Text -> f (Maybe Text))
-> HyperParameterAlgorithmSpecification
-> f HyperParameterAlgorithmSpecification
hyperParameterAlgorithmSpecification_trainingImage = (HyperParameterAlgorithmSpecification -> Maybe Text)
-> (HyperParameterAlgorithmSpecification
    -> Maybe Text -> HyperParameterAlgorithmSpecification)
-> Lens
     HyperParameterAlgorithmSpecification
     HyperParameterAlgorithmSpecification
     (Maybe Text)
     (Maybe Text)
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HyperParameterAlgorithmSpecification' {Maybe Text
trainingImage :: Maybe Text
$sel:trainingImage:HyperParameterAlgorithmSpecification' :: HyperParameterAlgorithmSpecification -> Maybe Text
trainingImage} -> Maybe Text
trainingImage) (\s :: HyperParameterAlgorithmSpecification
s@HyperParameterAlgorithmSpecification' {} Maybe Text
a -> HyperParameterAlgorithmSpecification
s {$sel:trainingImage:HyperParameterAlgorithmSpecification' :: Maybe Text
trainingImage = Maybe Text
a} :: HyperParameterAlgorithmSpecification)

-- | An array of MetricDefinition objects that specify the metrics that the
-- algorithm emits.
hyperParameterAlgorithmSpecification_metricDefinitions :: Lens.Lens' HyperParameterAlgorithmSpecification (Prelude.Maybe [MetricDefinition])
hyperParameterAlgorithmSpecification_metricDefinitions :: (Maybe [MetricDefinition] -> f (Maybe [MetricDefinition]))
-> HyperParameterAlgorithmSpecification
-> f HyperParameterAlgorithmSpecification
hyperParameterAlgorithmSpecification_metricDefinitions = (HyperParameterAlgorithmSpecification -> Maybe [MetricDefinition])
-> (HyperParameterAlgorithmSpecification
    -> Maybe [MetricDefinition]
    -> HyperParameterAlgorithmSpecification)
-> Lens
     HyperParameterAlgorithmSpecification
     HyperParameterAlgorithmSpecification
     (Maybe [MetricDefinition])
     (Maybe [MetricDefinition])
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HyperParameterAlgorithmSpecification' {Maybe [MetricDefinition]
metricDefinitions :: Maybe [MetricDefinition]
$sel:metricDefinitions:HyperParameterAlgorithmSpecification' :: HyperParameterAlgorithmSpecification -> Maybe [MetricDefinition]
metricDefinitions} -> Maybe [MetricDefinition]
metricDefinitions) (\s :: HyperParameterAlgorithmSpecification
s@HyperParameterAlgorithmSpecification' {} Maybe [MetricDefinition]
a -> HyperParameterAlgorithmSpecification
s {$sel:metricDefinitions:HyperParameterAlgorithmSpecification' :: Maybe [MetricDefinition]
metricDefinitions = Maybe [MetricDefinition]
a} :: HyperParameterAlgorithmSpecification) ((Maybe [MetricDefinition] -> f (Maybe [MetricDefinition]))
 -> HyperParameterAlgorithmSpecification
 -> f HyperParameterAlgorithmSpecification)
-> ((Maybe [MetricDefinition] -> f (Maybe [MetricDefinition]))
    -> Maybe [MetricDefinition] -> f (Maybe [MetricDefinition]))
-> (Maybe [MetricDefinition] -> f (Maybe [MetricDefinition]))
-> HyperParameterAlgorithmSpecification
-> f HyperParameterAlgorithmSpecification
forall b c a. (b -> c) -> (a -> b) -> a -> c
Prelude.. AnIso
  [MetricDefinition]
  [MetricDefinition]
  [MetricDefinition]
  [MetricDefinition]
-> Iso
     (Maybe [MetricDefinition])
     (Maybe [MetricDefinition])
     (Maybe [MetricDefinition])
     (Maybe [MetricDefinition])
forall (f :: * -> *) (g :: * -> *) s t a b.
(Functor f, Functor g) =>
AnIso s t a b -> Iso (f s) (g t) (f a) (g b)
Lens.mapping AnIso
  [MetricDefinition]
  [MetricDefinition]
  [MetricDefinition]
  [MetricDefinition]
forall s t a b. (Coercible s a, Coercible t b) => Iso s t a b
Lens.coerced

-- | Undocumented member.
hyperParameterAlgorithmSpecification_trainingInputMode :: Lens.Lens' HyperParameterAlgorithmSpecification TrainingInputMode
hyperParameterAlgorithmSpecification_trainingInputMode :: (TrainingInputMode -> f TrainingInputMode)
-> HyperParameterAlgorithmSpecification
-> f HyperParameterAlgorithmSpecification
hyperParameterAlgorithmSpecification_trainingInputMode = (HyperParameterAlgorithmSpecification -> TrainingInputMode)
-> (HyperParameterAlgorithmSpecification
    -> TrainingInputMode -> HyperParameterAlgorithmSpecification)
-> Lens
     HyperParameterAlgorithmSpecification
     HyperParameterAlgorithmSpecification
     TrainingInputMode
     TrainingInputMode
forall s a b t. (s -> a) -> (s -> b -> t) -> Lens s t a b
Lens.lens (\HyperParameterAlgorithmSpecification' {TrainingInputMode
trainingInputMode :: TrainingInputMode
$sel:trainingInputMode:HyperParameterAlgorithmSpecification' :: HyperParameterAlgorithmSpecification -> TrainingInputMode
trainingInputMode} -> TrainingInputMode
trainingInputMode) (\s :: HyperParameterAlgorithmSpecification
s@HyperParameterAlgorithmSpecification' {} TrainingInputMode
a -> HyperParameterAlgorithmSpecification
s {$sel:trainingInputMode:HyperParameterAlgorithmSpecification' :: TrainingInputMode
trainingInputMode = TrainingInputMode
a} :: HyperParameterAlgorithmSpecification)

instance
  Core.FromJSON
    HyperParameterAlgorithmSpecification
  where
  parseJSON :: Value -> Parser HyperParameterAlgorithmSpecification
parseJSON =
    String
-> (Object -> Parser HyperParameterAlgorithmSpecification)
-> Value
-> Parser HyperParameterAlgorithmSpecification
forall a. String -> (Object -> Parser a) -> Value -> Parser a
Core.withObject
      String
"HyperParameterAlgorithmSpecification"
      ( \Object
x ->
          Maybe Text
-> Maybe Text
-> Maybe [MetricDefinition]
-> TrainingInputMode
-> HyperParameterAlgorithmSpecification
HyperParameterAlgorithmSpecification'
            (Maybe Text
 -> Maybe Text
 -> Maybe [MetricDefinition]
 -> TrainingInputMode
 -> HyperParameterAlgorithmSpecification)
-> Parser (Maybe Text)
-> Parser
     (Maybe Text
      -> Maybe [MetricDefinition]
      -> TrainingInputMode
      -> HyperParameterAlgorithmSpecification)
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"AlgorithmName")
            Parser
  (Maybe Text
   -> Maybe [MetricDefinition]
   -> TrainingInputMode
   -> HyperParameterAlgorithmSpecification)
-> Parser (Maybe Text)
-> Parser
     (Maybe [MetricDefinition]
      -> TrainingInputMode -> HyperParameterAlgorithmSpecification)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser (Maybe Text)
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"TrainingImage")
            Parser
  (Maybe [MetricDefinition]
   -> TrainingInputMode -> HyperParameterAlgorithmSpecification)
-> Parser (Maybe [MetricDefinition])
-> Parser
     (TrainingInputMode -> HyperParameterAlgorithmSpecification)
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> ( Object
x Object -> Text -> Parser (Maybe (Maybe [MetricDefinition]))
forall a. FromJSON a => Object -> Text -> Parser (Maybe a)
Core..:? Text
"MetricDefinitions"
                            Parser (Maybe (Maybe [MetricDefinition]))
-> Maybe [MetricDefinition] -> Parser (Maybe [MetricDefinition])
forall a. Parser (Maybe a) -> a -> Parser a
Core..!= Maybe [MetricDefinition]
forall a. Monoid a => a
Prelude.mempty
                        )
            Parser (TrainingInputMode -> HyperParameterAlgorithmSpecification)
-> Parser TrainingInputMode
-> Parser HyperParameterAlgorithmSpecification
forall (f :: * -> *) a b. Applicative f => f (a -> b) -> f a -> f b
Prelude.<*> (Object
x Object -> Text -> Parser TrainingInputMode
forall a. FromJSON a => Object -> Text -> Parser a
Core..: Text
"TrainingInputMode")
      )

instance
  Prelude.Hashable
    HyperParameterAlgorithmSpecification

instance
  Prelude.NFData
    HyperParameterAlgorithmSpecification

instance
  Core.ToJSON
    HyperParameterAlgorithmSpecification
  where
  toJSON :: HyperParameterAlgorithmSpecification -> Value
toJSON HyperParameterAlgorithmSpecification' {Maybe [MetricDefinition]
Maybe Text
TrainingInputMode
trainingInputMode :: TrainingInputMode
metricDefinitions :: Maybe [MetricDefinition]
trainingImage :: Maybe Text
algorithmName :: Maybe Text
$sel:trainingInputMode:HyperParameterAlgorithmSpecification' :: HyperParameterAlgorithmSpecification -> TrainingInputMode
$sel:metricDefinitions:HyperParameterAlgorithmSpecification' :: HyperParameterAlgorithmSpecification -> Maybe [MetricDefinition]
$sel:trainingImage:HyperParameterAlgorithmSpecification' :: HyperParameterAlgorithmSpecification -> Maybe Text
$sel:algorithmName:HyperParameterAlgorithmSpecification' :: HyperParameterAlgorithmSpecification -> Maybe Text
..} =
    [Pair] -> Value
Core.object
      ( [Maybe Pair] -> [Pair]
forall a. [Maybe a] -> [a]
Prelude.catMaybes
          [ (Text
"AlgorithmName" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
algorithmName,
            (Text
"TrainingImage" Text -> Text -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=) (Text -> Pair) -> Maybe Text -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe Text
trainingImage,
            (Text
"MetricDefinitions" Text -> [MetricDefinition] -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..=)
              ([MetricDefinition] -> Pair)
-> Maybe [MetricDefinition] -> Maybe Pair
forall (f :: * -> *) a b. Functor f => (a -> b) -> f a -> f b
Prelude.<$> Maybe [MetricDefinition]
metricDefinitions,
            Pair -> Maybe Pair
forall a. a -> Maybe a
Prelude.Just
              (Text
"TrainingInputMode" Text -> TrainingInputMode -> Pair
forall kv v. (KeyValue kv, ToJSON v) => Text -> v -> kv
Core..= TrainingInputMode
trainingInputMode)
          ]
      )