

本文属于机器翻译版本。若本译文内容与英语原文存在差异，则一律以英文原文为准。

# Neptune ML 模型训练 API
<a name="data-api-dp-ml-training"></a>

**模型训练操作：**
+ [StartMLModelTrainingJob（操作）](#StartMLModelTrainingJob)
+ [ListMLModelTrainingJobs（操作）](#ListMLModelTrainingJobs)
+ [GetMLModelTrainingJob（操作）](#GetMLModelTrainingJob)
+ [CancelMLModelTrainingJob（操作）](#CancelMLModelTrainingJob)

**模型训练结构：**
+ [CustomModelTrainingParameters（结构）](#CustomModelTrainingParameters)

## StartMLModelTrainingJob（操作）
<a name="StartMLModelTrainingJob"></a>

         此 API 的 AWS CLI 名称为：`start-ml-model-training-job`。

创建新的 Neptune ML 模型训练任务。请参阅[使用 `modeltraining` 命令进行模型训练](https://docs.aws.amazon.com/neptune/latest/userguide/machine-learning-api-modeltraining.html)。

在启用了 IAM 身份验证的 Neptune 集群中调用此操作时，发出请求的 IAM 用户或角色必须附加允许在该集群中执行 [neptune-db:StartMLModelTrainingJob](https://docs.aws.amazon.com/neptune/latest/userguide/iam-dp-actions.html#startmlmodeltrainingjob) IAM 操作的策略。

**请求**
+ **baseProcessingInstanceType**（在 CLI 中：`--base-processing-instance-type`）– 一个字符串，类型为：`string`（UTF-8 编码的字符串）。

  用于准备和管理机器学习模型训练的机器学习实例的类型。这是根据用于处理训练数据和模型的内存要求选择的 CPU 实例。
+ **customModelTrainingParameters**（在 CLI 中：`--custom-model-training-parameters`） – [CustomModelTrainingParameters](#CustomModelTrainingParameters) 对象。

  自定义模型训练的配置。这是 JSON 对象。
+ **dataProcessingJobId**（在 CLI 中：`--data-processing-job-id`）– *必需：*一个字符串，类型为：`string`（UTF-8 编码的字符串）。

  已完成的数据处理任务的任务 ID，该任务已创建训练将使用的数据。
+ **enableManagedSpotTraining**（在 CLI 中：`--enable-managed-spot-training`）– 一个布尔值，类型为：`boolean` [布尔值（true 或 false）]。

  使用 Amazon Elastic Compute Cloud 竞价型实例优化训练机器学习模型的成本。默认值为 `False`。
+ **id**（在 CLI 中：`--id`）– 一个字符串，类型为：`string`（UTF-8 编码的字符串）。

  新任务的唯一标识符。默认值为自动生成的 UUID。
+ **maxHPONumberOfTrainingJobs**（在 CLI 中：`--max-hpo-number-of-training-jobs`）– 一个整数，类型为：`integer`（带符号的 32 位整数）。

  超参数调整任务要启动的最大训练任务总数。默认值为 2。Neptune ML 会自动调整机器学习模型的超参数。要获得性能良好的模型，请至少使用 10 个任务（换句话说，将 `maxHPONumberOfTrainingJobs` 设置为 10）。通常，调整次数越多，结果越好。
+ **maxHPOParallelTrainingJobs**（在 CLI 中：`--max-hpo-parallel-training-jobs`）– 一个整数，类型为：`integer`（带符号的 32 位整数）。

  为超参数调整任务启动的最大并行训练任务数。默认值为 2。您可以运行的并行任务数量受训练实例上可用资源的限制。
+ **neptuneIamRoleArn**（在 CLI 中：`--neptune-iam-role-arn`）– 一个字符串，类型为：`string`（UTF-8 编码的字符串）。

  向 Neptune 提供对 SageMaker 和 Amazon S3 资源的访问权限的 IAM 角色的 ARN。必须将其列在您的数据库集群参数组中，否则将发生错误。
+ **previousModelTrainingJobId**（在 CLI 中：`--previous-model-training-job-id`）– 一个字符串，类型为：`string`（UTF-8 编码的字符串）。

  已完成的模型训练任务的任务 ID，您要根据更新的数据以递增方式更新该任务。
+ **s3OutputEncryptionKMSKey**（在 CLI 中：`--s-3-output-encryption-kms-key`）– 一个字符串，类型为：`string`（UTF-8 编码的字符串）。

  SageMaker 用于加密处理任务的输出的 Amazon Key Management Service (KMS) 密钥。默认值为“无”。
+ **sagemakerIamRoleArn**（在 CLI 中：`--sagemaker-iam-role-arn`）– 一个字符串，类型为：`string`（UTF-8 编码的字符串）。

  用于 SageMaker 执行的 IAM 角色的 ARN。必须将其列在您的数据库集群参数组中，否则将发生错误。
+ **securityGroupIds**（在 CLI 中：`--security-group-ids`）– 一个字符串，类型为：`string`（UTF-8 编码的字符串）。

  VPC 安全组 ID。默认值为 None (无)。
+ **subnets**（在 CLI 中：`--subnets`）– 一个字符串，类型为：`string`（UTF-8 编码的字符串）。

  Neptune VPC 中子网的 ID。默认值为 None (无)。
+ **trainingInstanceType**（在 CLI 中：`--training-instance-type`）– 一个字符串，类型为：`string`（UTF-8 编码的字符串）。

  用于模型训练的 ML 实例的类型。所有 Neptune ML 模型都支持 CPU、GPU 和多 GPU 训练。默认值为 `ml.p3.2xlarge`。为训练选择正确的实例类型取决于任务类型、图形大小和预算。
+ **trainingInstanceVolumeSizeInGB**（在 CLI 中：`--training-instance-volume-size-in-gb`）– 一个整数，类型为：`integer`（带符号的 32 位整数）。

  训练实例的磁盘卷大小。输入数据和输出模型都存储在磁盘上，因此卷大小必须足够大，以容纳两个数据集。默认值是 0。如果未指定或为 0，Neptune ML 会根据数据处理步骤中生成的建议选择磁盘卷大小。
+ **trainingTimeOutInSeconds**（在 CLI 中：`--training-time-out-in-seconds`）– 一个整数，类型为：`integer`（带符号的 32 位整数）。

  训练任务的超时（以秒为单位）。默认值为 86400（1 天）。
+ **trainModelS3Location**（在 CLI 中：`--train-model-s3-location`）– *必需：*一个字符串，类型为：`string`（UTF-8 编码的字符串）。

  Amazon S3 中要存储模型构件的位置。
+ **volumeEncryptionKMSKey**（在 CLI 中：`--volume-encryption-kms-key`）– 一个字符串，类型为：`string`（UTF-8 编码的字符串）。

  Amazon Key Management Service (KMS) 密钥，SageMaker 使用它来加密连接到运行训练任务的 ML 计算实例的存储卷上的数据。默认值为 None (无)。

**响应**
+ **arn** – 一个字符串，类型为：`string`（UTF-8 编码的字符串）。

  新模型训练任务的 ARN。
+ **creationTimeInMillis** – 长整型，类型为：`long`（有符号的 64 位整数）。

  模型训练任务创建时间，以毫秒为单位。
+ **id** – 一个字符串，类型为：`string`（UTF-8 编码的字符串）。

  新模型训练任务的唯一 ID。

**错误**
+ [UnsupportedOperationException](data-api-dp-errors.md#UnsupportedOperationException)
+ [BadRequestException](data-api-dp-errors.md#BadRequestException)
+ [MLResourceNotFoundException](data-api-dp-errors.md#MLResourceNotFoundException)
+ [InvalidParameterException](data-api-dp-errors.md#InvalidParameterException)
+ [ClientTimeoutException](data-api-dp-errors.md#ClientTimeoutException)
+ [PreconditionsFailedException](data-api-dp-errors.md#PreconditionsFailedException)
+ [ConstraintViolationException](data-api-dp-errors.md#ConstraintViolationException)
+ [InvalidArgumentException](data-api-dp-errors.md#InvalidArgumentException)
+ [MissingParameterException](data-api-dp-errors.md#MissingParameterException)
+ [IllegalArgumentException](data-api-dp-errors.md#IllegalArgumentException)
+ [TooManyRequestsException](data-api-dp-errors.md#TooManyRequestsException)

## ListMLModelTrainingJobs（操作）
<a name="ListMLModelTrainingJobs"></a>

         此 API 的 AWS CLI 名称为：`list-ml-model-training-jobs`。

列出 Neptune ML 模型训练任务。请参阅[使用 `modeltraining` 命令进行模型训练](https://docs.aws.amazon.com/neptune/latest/userguide/machine-learning-api-modeltraining.html)。

在启用了 IAM 身份验证的 Neptune 集群中调用此操作时，发出请求的 IAM 用户或角色必须附加允许在该集群中执行 [neptune-db:neptune-db:ListMLModelTrainingJobs](https://docs.aws.amazon.com/neptune/latest/userguide/iam-dp-actions.html#neptune-db:listmlmodeltrainingjobs) IAM 操作的策略。

**请求**
+ **maxItems**（在 CLI 中：`--max-items`）– ListMLModelTrainingJobsInputMaxItemsInteger，类型为：`integer`（带符号的 32 位整数），不小于 1 或大于 1024。

  要返回的最大项目数（从 1 到 1024；默认值为 10）。
+ **neptuneIamRoleArn**（在 CLI 中：`--neptune-iam-role-arn`）– 一个字符串，类型为：`string`（UTF-8 编码的字符串）。

  向 Neptune 提供对 SageMaker 和 Amazon S3 资源的访问权限的 IAM 角色的 ARN。必须将其列在您的数据库集群参数组中，否则将发生错误。

**响应**
+ **ids** – 一个字符串，类型为：`string`（UTF-8 编码的字符串）。

  模型训练任务 ID 列表的页面。

**错误**
+ [UnsupportedOperationException](data-api-dp-errors.md#UnsupportedOperationException)
+ [BadRequestException](data-api-dp-errors.md#BadRequestException)
+ [MLResourceNotFoundException](data-api-dp-errors.md#MLResourceNotFoundException)
+ [InvalidParameterException](data-api-dp-errors.md#InvalidParameterException)
+ [ClientTimeoutException](data-api-dp-errors.md#ClientTimeoutException)
+ [PreconditionsFailedException](data-api-dp-errors.md#PreconditionsFailedException)
+ [ConstraintViolationException](data-api-dp-errors.md#ConstraintViolationException)
+ [InvalidArgumentException](data-api-dp-errors.md#InvalidArgumentException)
+ [MissingParameterException](data-api-dp-errors.md#MissingParameterException)
+ [IllegalArgumentException](data-api-dp-errors.md#IllegalArgumentException)
+ [TooManyRequestsException](data-api-dp-errors.md#TooManyRequestsException)

## GetMLModelTrainingJob（操作）
<a name="GetMLModelTrainingJob"></a>

         此 API 的 AWS CLI 名称为：`get-ml-model-training-job`。

检索有关 Neptune ML 模型训练任务的信息。请参阅[使用 `modeltraining` 命令进行模型训练](https://docs.aws.amazon.com/neptune/latest/userguide/machine-learning-api-modeltraining.html)。

在启用了 IAM 身份验证的 Neptune 集群中调用此操作时，发出请求的 IAM 用户或角色必须附加允许在该集群中执行 [neptune-db:GetMLModelTrainingJobStatus](https://docs.aws.amazon.com/neptune/latest/userguide/iam-dp-actions.html#getmlmodeltrainingjobstatus) IAM 操作的策略。

**请求**
+ **id**（在 CLI 中：`--id`）– *必需：*一个字符串，类型为：`string`（UTF-8 编码的字符串）。

  要检索的模型训练任务的唯一标识符。
+ **neptuneIamRoleArn**（在 CLI 中：`--neptune-iam-role-arn`）– 一个字符串，类型为：`string`（UTF-8 编码的字符串）。

  向 Neptune 提供对 SageMaker 和 Amazon S3 资源的访问权限的 IAM 角色的 ARN。必须将其列在您的数据库集群参数组中，否则将发生错误。

**响应**
+ **hpoJob** – 一个 [MlResourceDefinition](data-api-dp-ml-data-processing.md#MlResourceDefinition) 对象。

  HPO 任务。
+ **id** – 一个字符串，类型为：`string`（UTF-8 编码的字符串）。

  此模型训练任务的唯一标识符。
+ **mlModels** – [MlConfigDefinition](data-api-dp-ml-data-processing.md#MlConfigDefinition) 对象的数组。

  正在使用的机器学习模型的配置列表。
+ **modelTransformJob** – 一个 [MlResourceDefinition](data-api-dp-ml-data-processing.md#MlResourceDefinition) 对象。

  模型转换任务。
+ **processingJob** – 一个 [MlResourceDefinition](data-api-dp-ml-data-processing.md#MlResourceDefinition) 对象。

  数据处理任务。
+ **status** – 一个字符串，类型为：`string`（UTF-8 编码的字符串）。

  模型训练任务的状态。

**错误**
+ [UnsupportedOperationException](data-api-dp-errors.md#UnsupportedOperationException)
+ [BadRequestException](data-api-dp-errors.md#BadRequestException)
+ [MLResourceNotFoundException](data-api-dp-errors.md#MLResourceNotFoundException)
+ [InvalidParameterException](data-api-dp-errors.md#InvalidParameterException)
+ [ClientTimeoutException](data-api-dp-errors.md#ClientTimeoutException)
+ [PreconditionsFailedException](data-api-dp-errors.md#PreconditionsFailedException)
+ [ConstraintViolationException](data-api-dp-errors.md#ConstraintViolationException)
+ [InvalidArgumentException](data-api-dp-errors.md#InvalidArgumentException)
+ [MissingParameterException](data-api-dp-errors.md#MissingParameterException)
+ [IllegalArgumentException](data-api-dp-errors.md#IllegalArgumentException)
+ [TooManyRequestsException](data-api-dp-errors.md#TooManyRequestsException)

## CancelMLModelTrainingJob（操作）
<a name="CancelMLModelTrainingJob"></a>

         此 API 的 AWS CLI 名称为：`cancel-ml-model-training-job`。

取消 Neptune ML 模型训练任务。请参阅[使用 `modeltraining` 命令进行模型训练](https://docs.aws.amazon.com/neptune/latest/userguide/machine-learning-api-modeltraining.html)。

在启用了 IAM 身份验证的 Neptune 集群中调用此操作时，发出请求的 IAM 用户或角色必须附加允许在该集群中执行 [neptune-db:CancelMLModelTrainingJob](https://docs.aws.amazon.com/neptune/latest/userguide/iam-dp-actions.html#cancelmlmodeltrainingjob) IAM 操作的策略。

**请求**
+ **clean**（在 CLI 中：`--clean`）– 一个布尔值，类型为：`boolean` [布尔值（true 或 false）]。

  如果设置为 `TRUE`，则此标志指定在任务停止时应删除所有 Amazon S3 构件。默认值为 `FALSE`。
+ **id**（在 CLI 中：`--id`）– *必需：*一个字符串，类型为：`string`（UTF-8 编码的字符串）。

  要取消的模型训练任务的唯一标识符。
+ **neptuneIamRoleArn**（在 CLI 中：`--neptune-iam-role-arn`）– 一个字符串，类型为：`string`（UTF-8 编码的字符串）。

  向 Neptune 提供对 SageMaker 和 Amazon S3 资源的访问权限的 IAM 角色的 ARN。必须将其列在您的数据库集群参数组中，否则将发生错误。

**响应**
+ **status** – 一个字符串，类型为：`string`（UTF-8 编码的字符串）。

  取消的状态。

**错误**
+ [UnsupportedOperationException](data-api-dp-errors.md#UnsupportedOperationException)
+ [BadRequestException](data-api-dp-errors.md#BadRequestException)
+ [MLResourceNotFoundException](data-api-dp-errors.md#MLResourceNotFoundException)
+ [InvalidParameterException](data-api-dp-errors.md#InvalidParameterException)
+ [ClientTimeoutException](data-api-dp-errors.md#ClientTimeoutException)
+ [PreconditionsFailedException](data-api-dp-errors.md#PreconditionsFailedException)
+ [ConstraintViolationException](data-api-dp-errors.md#ConstraintViolationException)
+ [InvalidArgumentException](data-api-dp-errors.md#InvalidArgumentException)
+ [MissingParameterException](data-api-dp-errors.md#MissingParameterException)
+ [IllegalArgumentException](data-api-dp-errors.md#IllegalArgumentException)
+ [TooManyRequestsException](data-api-dp-errors.md#TooManyRequestsException)

## *模型训练结构：*
<a name="data-api-dp-ml-training-model-training-structures-spacer"></a>

## CustomModelTrainingParameters（结构）
<a name="CustomModelTrainingParameters"></a>

包含自定义模型训练参数。请参阅 [Neptune ML 中的自定义模型](https://docs.aws.amazon.com/neptune/latest/userguide/machine-learning-custom-models.html)。

**Fields**
+ **sourceS3DirectoryPath** – 这是*必需的：*一个字符串，类型为：`string`（UTF-8 编码的字符串）。

  实现您的模型的 Python 模块所在的 Amazon S3 位置的路径。这必须指向有效的现有 Amazon S3 位置，其中至少包含训练脚本、转换脚本和 `model-hpo-configuration.json` 文件。
+ **trainingEntryPointScript** – 这是一个字符串，类型为：`string`（UTF-8 编码的字符串）。

  执行模型训练并将超参数作为命令行参数（包括固定的超参数）的脚本模块中入口点的名称。默认值为 `training.py`。
+ **transformEntryPointScript** – 这是一个字符串，类型为：`string`（UTF-8 编码的字符串）。

  脚本模块中入口点的名称，该脚本应在确定超参数搜索中的最佳模型之后运行，以计算模型部署所需的模型构件。它应该能够在没有命令行参数的情况下运行。默认值为 `transform.py`。