

翻訳は機械翻訳により提供されています。提供された翻訳内容と英語版の間で齟齬、不一致または矛盾がある場合、英語版が優先します。

# モデル変換を使用して `modeltransform` コマンド
<a name="machine-learning-api-modeltransform"></a>

Neptune ML `modeltransform` コマンドを使用すると、モデル変換ジョブを作成したり、そのステータスを確認したり、停止したり、アクティブなモデルトレーニングジョブをすべて一覧表示したりできます。

## Neptune ML `modeltransform` コマンドを使用したモデル変換ジョブの作成
<a name="machine-learning-api-modeltransform-create-job"></a>

インクリメンタル変換ジョブを作成するための、モデルの再トレーニングなしでの Neptune ML `modeltransform` コマンドは、次のようになります。

------
#### [ AWS CLI ]

```
aws neptunedata start-ml-model-transform-job \
  --endpoint-url https://{{your-neptune-endpoint}}:{{port}} \
  --id "{{(a unique model-transform job ID)}}" \
  --data-processing-job-id "{{(the job-id of a completed data-processing job)}}" \
  --ml-model-training-job-id "{{(the job-id of a completed model-training job)}}" \
  --model-transform-output-s3-location "s3://{{(your S3 bucket)}}/neptune-model-transform"
```

詳細については、 AWS CLI 「 コマンドリファレンス」の[start-ml-model-transform-job](https://docs.aws.amazon.com/cli/latest/reference/neptunedata/start-ml-model-transform-job.html)」を参照してください。

------
#### [ SDK ]

```
import boto3
from botocore.config import Config

client = boto3.client(
    'neptunedata',
    endpoint_url='https://{{your-neptune-endpoint}}:{{port}}',
    config=Config(read_timeout=None, retries={'total_max_attempts': 1})
)

response = client.start_ml_model_transform_job(
    id='{{(a unique model-transform job ID)}}',
    dataProcessingJobId='{{(the job-id of a completed data-processing job)}}',
    mlModelTrainingJobId='{{(the job-id of a completed model-training job)}}',
    modelTransformOutputS3Location='s3://{{(your S3 bucket)}}/neptune-model-transform'
)

print(response)
```

------
#### [ awscurl ]

```
awscurl https://{{your-neptune-endpoint}}:{{port}}/ml/modeltransform \
  --region {{us-east-1}} \
  --service neptune-db \
  -X POST \
  -H 'Content-Type: application/json' \
  -d '{
        "id" : "{{(a unique model-transform job ID)}}",
        "dataProcessingJobId" : "{{(the job-id of a completed data-processing job)}}",
        "mlModelTrainingJobId" : "{{(the job-id of a completed model-training job)}}",
        "modelTransformOutputS3Location" : "s3://{{(your S3 bucket)}}/neptune-model-transform"
      }'
```

**注記**  
この例では、 AWS 認証情報が 環境で設定されていることを前提としています。{{us-east-1}} を Neptune クラスターのリージョンに置き換えます。

------
#### [ curl ]

```
curl \
  -X POST https://{{your-neptune-endpoint}}:{{port}}/ml/modeltransform \
  -H 'Content-Type: application/json' \
  -d '{
        "id" : "{{(a unique model-transform job ID)}}",
        "dataProcessingJobId" : "{{(the job-id of a completed data-processing job)}}",
        "mlModelTrainingJobId" : "{{(the job-id of a completed model-training job)}}",
        "modelTransformOutputS3Location" : "s3://{{(your S3 bucket)}}/neptune-model-transform"
      }'
```

------

完了した SageMaker AI トレーニングジョブからジョブを作成するための Neptune ML `modeltransform` コマンドは次のようになります。

------
#### [ AWS CLI ]

```
aws neptunedata start-ml-model-transform-job \
  --endpoint-url https://{{your-neptune-endpoint}}:{{port}} \
  --id "{{(a unique model-transform job ID)}}" \
  --training-job-name "{{(name of a completed SageMaker training job)}}" \
  --model-transform-output-s3-location "s3://{{(your S3 bucket)}}/neptune-model-transform"
```

詳細については、 AWS CLI 「 コマンドリファレンス」の[start-ml-model-transform-job](https://docs.aws.amazon.com/cli/latest/reference/neptunedata/start-ml-model-transform-job.html)」を参照してください。

------
#### [ SDK ]

```
import boto3
from botocore.config import Config

client = boto3.client(
    'neptunedata',
    endpoint_url='https://{{your-neptune-endpoint}}:{{port}}',
    config=Config(read_timeout=None, retries={'total_max_attempts': 1})
)

response = client.start_ml_model_transform_job(
    id='{{(a unique model-transform job ID)}}',
    trainingJobName='{{(name of a completed SageMaker training job)}}',
    modelTransformOutputS3Location='s3://{{(your S3 bucket)}}/neptune-model-transform'
)

print(response)
```

------
#### [ awscurl ]

```
awscurl https://{{your-neptune-endpoint}}:{{port}}/ml/modeltransform \
  --region {{us-east-1}} \
  --service neptune-db \
  -X POST \
  -H 'Content-Type: application/json' \
  -d '{
        "id" : "{{(a unique model-transform job ID)}}",
        "trainingJobName" : "{{(name of a completed SageMaker training job)}}",
        "modelTransformOutputS3Location" : "s3://{{(your S3 bucket)}}/neptune-model-transform"
      }'
```

**注記**  
この例では、 AWS 認証情報が 環境で設定されていることを前提としています。{{us-east-1}} を Neptune クラスターのリージョンに置き換えます。

------
#### [ curl ]

```
curl \
  -X POST https://{{your-neptune-endpoint}}:{{port}}/ml/modeltransform \
  -H 'Content-Type: application/json' \
  -d '{
        "id" : "{{(a unique model-transform job ID)}}",
        "trainingJobName" : "{{(name of a completed SageMaker training job)}}",
        "modelTransformOutputS3Location" : "s3://{{(your S3 bucket)}}/neptune-model-transform"
      }'
```

------

カスタムモデル実装を使用してジョブを作成するための Neptune ML `modeltransform` コマンドは次のようになります。

------
#### [ AWS CLI ]

```
aws neptunedata start-ml-model-transform-job \
  --endpoint-url https://{{your-neptune-endpoint}}:{{port}} \
  --id "{{(a unique model-transform job ID)}}" \
  --training-job-name "{{(name of a completed SageMaker training job)}}" \
  --model-transform-output-s3-location "s3://{{(your Amazon S3 bucket)}}/neptune-model-transform/" \
  --custom-model-transform-parameters '{
    "sourceS3DirectoryPath": "s3://{{(your Amazon S3 bucket)}}/{{(path to your Python module)}}",
    "transformEntryPointScript": "{{(your transform script entry-point name in the Python module)}}"
  }'
```

詳細については、 AWS CLI 「 コマンドリファレンス」の[start-ml-model-transform-job](https://docs.aws.amazon.com/cli/latest/reference/neptunedata/start-ml-model-transform-job.html)」を参照してください。

------
#### [ SDK ]

```
import boto3
from botocore.config import Config

client = boto3.client(
    'neptunedata',
    endpoint_url='https://{{your-neptune-endpoint}}:{{port}}',
    config=Config(read_timeout=None, retries={'total_max_attempts': 1})
)

response = client.start_ml_model_transform_job(
    id='{{(a unique model-transform job ID)}}',
    trainingJobName='{{(name of a completed SageMaker training job)}}',
    modelTransformOutputS3Location='s3://{{(your Amazon S3 bucket)}}/neptune-model-transform/',
    customModelTransformParameters={
        'sourceS3DirectoryPath': 's3://{{(your Amazon S3 bucket)}}/{{(path to your Python module)}}',
        'transformEntryPointScript': '{{(your transform script entry-point name in the Python module)}}'
    }
)

print(response)
```

------
#### [ awscurl ]

```
awscurl https://{{your-neptune-endpoint}}:{{port}}/ml/modeltransform \
  --region {{us-east-1}} \
  --service neptune-db \
  -X POST \
  -H 'Content-Type: application/json' \
  -d '{
        "id" : "{{(a unique model-transform job ID)}}",
        "trainingJobName" : "{{(name of a completed SageMaker training job)}}",
        "modelTransformOutputS3Location" : "s3://{{(your Amazon S3 bucket)}}/neptune-model-transform/",
        "customModelTransformParameters" : {
          "sourceS3DirectoryPath": "s3://{{(your Amazon S3 bucket)}}/{{(path to your Python module)}}",
          "transformEntryPointScript": "{{(your transform script entry-point name in the Python module)}}"
        }
      }'
```

**注記**  
この例では、 AWS 認証情報が 環境で設定されていることを前提としています。{{us-east-1}} を Neptune クラスターのリージョンに置き換えます。

------
#### [ curl ]

```
curl \
  -X POST https://{{your-neptune-endpoint}}:{{port}}/ml/modeltransform \
  -H 'Content-Type: application/json' \
  -d '{
        "id" : "{{(a unique model-transform job ID)}}",
        "trainingJobName" : "{{(name of a completed SageMaker training job)}}",
        "modelTransformOutputS3Location" : "s3://{{(your Amazon S3 bucket)}}/neptune-model-transform/",
        "customModelTransformParameters" : {
          "sourceS3DirectoryPath": "s3://{{(your Amazon S3 bucket)}}/{{(path to your Python module)}}",
          "transformEntryPointScript": "{{(your transform script entry-point name in the Python module)}}"
        }
      }'
```

------

**`modeltransform` ジョブ作成のパラメータ**
+ **`id`** — (*オプション*) 新しいジョブの一意の識別子。

  *タイプ*: 文字列。*デフォルト値*: 自動生成された UUID。
+ **`dataProcessingJobId`** — 完了したデータ処理ジョブのジョブ ID。

  *タイプ*: 文字列。

  *注意*: `dataProcessingJobId` および `mlModelTrainingJobId` の両方を、または `trainingJobName` 含める必要があります。
+ **`mlModelTrainingJobId`** — 完了したモデルトレーニングジョブのジョブ ID。

  *タイプ*: 文字列。

  *注意*: `dataProcessingJobId` および `mlModelTrainingJobId` の両方を、または `trainingJobName` 含める必要があります。
+ **`trainingJobName`** — 完了した SageMaker AI トレーニングジョブの名前。

  *タイプ*: 文字列。

  *注意*: `dataProcessingJobId` および `mlModelTrainingJobId` パラメータの両方を、または `trainingJobName`パラメータを含める必要があります。
+ **`sagemakerIamRoleArn`** — (*オプション*) SageMaker AI 実行のための IAM ロールの ARN。

  *タイプ*: 文字列。*注意*: これは DB クラスターパラメータグループに一覧表示されている必要があります。そうしないと、エラーが発生します。
+ **`neptuneIamRoleArn`** — (*オプション*) SageMaker AI および Amazon S3 リソースへの Neptune アクセスを提供する IAM ロールの ARN。

  *タイプ*: 文字列。*注意*: これは DB クラスターパラメータグループに一覧表示されている必要があります。そうしないと、エラーが発生します。
+ **`customModelTransformParameters `** — (*オプション*) カスタムモデルを使用したモデル変換の構成情報。`customModelTransformParameters` オブジェクトには次のフィールドが含まれています。これらのフィールドには、トレーニングジョブの保存されたモデルパラメーターと互換性のある値が必要です。
  + **`sourceS3DirectoryPath`** — (*必須*) モデルを実装する Python モジュールがある Amazon S3 の場所へのパス。これは、少なくともトレーニングスクリプト、変換スクリプト、および `model-hpo-configuration.json` ファイルを含む有効な既存の Amazon S3 の場所を指定しなければなりません。
  + **`transformEntryPointScript`** — (*オプション*) モデルのデプロイに必要なモデルアーティファクトを計算するために、ハイパーパラメーター検索の最適なモデルが特定された後に実行されるスクリプトのモジュール内のエントリポイントの名前。コマンドライン引数なしで実行できるはずです。

    *デフォルト*: `transform.py`。
+ **`baseProcessingInstanceType`** — (*オプション*) ML モデルのトレーニングの準備と管理に使用される ML インスタンスのタイプ。

  *タイプ*: 文字列。*注意*: これは、変換データとモデルの処理に必要なメモリに基づいて選択された CPU インスタンスです。「[モデルトレーニングとモデル変換のインスタンスの選択](machine-learning-on-graphs-instance-selection.md#machine-learning-on-graphs-training-transform-instance-size)」を参照してください。
+ **`baseProcessingInstanceVolumeSizeInGB`** — (*オプション*) トレーニングインスタンスのディスクボリュームサイズ。入力データと出力モデルの両方がディスクに保存されるため、ボリュームサイズは両方のデータセットを保持するのに十分な大きさでなければなりません。

  *タイプ*: 整数。*デフォルト*: `0`。

  *注意*: 指定しない場合、または 0 の場合、Neptune ML はデータ処理ステップで生成された推奨に基づいてディスクボリュームサイズを選択します。「[モデルトレーニングとモデル変換のインスタンスの選択](machine-learning-on-graphs-instance-selection.md#machine-learning-on-graphs-training-transform-instance-size)」を参照してください。
+ **`subnets`** — (*オプション*) Neptune VPC 内のサブネットの ID。

  *タイプ*: 文字列のリスト。*デフォルト*: *なし*。
+ **`securityGroupIds`** — (*オプション*) VPC セキュリティグループ ID。

  *タイプ*: 文字列のリスト。*デフォルト*: *なし*。
+ **`volumeEncryptionKMSKey`**   –   (*オプション*) 変換ジョブを実行する ML コンピューティングインスタンスにアタッチされたストレージボリュームのデータを暗号化するために SageMaker AI が使用する AWS Key Management Service (AWS KMS) キー。

  *タイプ*: 文字列。*デフォルト*: *なし*。
+ **`enableInterContainerTrafficEncryption`** — (*オプション*) トレーニングジョブまたはハイパーパラメータチューニングジョブでのコンテナ間トラフィック暗号化を有効または無効にします。

  *タイプ*：ブール値 *デフォルト*: *true*。
**注記**  
`enableInterContainerTrafficEncryption` パラメータは、[エンジンリリース 1.2.0.2.R3](engine-releases-1.2.0.2.R3.md) でのみ使用できます。
+ **`s3OutputEncryptionKMSKey`**   –   (*オプション*) SageMaker AI が処理ジョブの出力を暗号化するために使用する AWS Key Management Service (AWS KMS) キー。

  *タイプ*: 文字列。*デフォルト*: *なし*。

## Neptune ML `modeltransform` コマンドを使用したモデル変換ジョブのステータスの取得
<a name="machine-learning-api-modeltransform-get-job-status"></a>

ジョブのステータスのサンプル Neptune ML `modeltransform` コマンドは、次のようになります。

------
#### [ AWS CLI ]

```
aws neptunedata get-ml-model-transform-job \
  --endpoint-url https://{{your-neptune-endpoint}}:{{port}} \
  --id "{{(the job ID)}}"
```

詳細については、 AWS CLI 「 コマンドリファレンス」の[get-ml-model-transform-job](https://docs.aws.amazon.com/cli/latest/reference/neptunedata/get-ml-model-transform-job.html)」を参照してください。

------
#### [ SDK ]

```
import boto3
from botocore.config import Config

client = boto3.client(
    'neptunedata',
    endpoint_url='https://{{your-neptune-endpoint}}:{{port}}',
    config=Config(read_timeout=None, retries={'total_max_attempts': 1})
)

response = client.get_ml_model_transform_job(
    id='{{(the job ID)}}'
)

print(response)
```

------
#### [ awscurl ]

```
awscurl https://{{your-neptune-endpoint}}:{{port}}/ml/modeltransform/{{(the job ID)}} \
  --region {{us-east-1}} \
  --service neptune-db \
  -X GET
```

**注記**  
この例では、 AWS 認証情報が 環境で設定されていることを前提としています。{{us-east-1}} を Neptune クラスターのリージョンに置き換えます。

------
#### [ curl ]

```
curl -s \
  "https://{{your-neptune-endpoint}}:{{port}}/ml/modeltransform/{{(the job ID)}}" \
  | python -m json.tool
```

------

**`modeltransform` ジョブステータスのパラメータ**
+ **`id`** — (*必須*) モデル変換ジョブの一意の識別子。

  *タイプ*: 文字列。
+ **`neptuneIamRoleArn`** — (*オプション*) SageMaker AI および Amazon S3 リソースへの Neptune アクセスを提供する IAM ロールの ARN。

  *タイプ*: 文字列。*注意*: これは DB クラスターパラメータグループに一覧表示されている必要があります。そうしないと、エラーが発生します。

## Neptune ML `modeltransform` コマンドを使用したモデル変換ジョブの停止
<a name="machine-learning-api-modeltransform-stop-job"></a>

ジョブのを停止するサンプル Neptune ML `modeltransform` コマンドは、次のようになります。

------
#### [ AWS CLI ]

```
aws neptunedata cancel-ml-model-transform-job \
  --endpoint-url https://{{your-neptune-endpoint}}:{{port}} \
  --id "{{(the job ID)}}"
```

Amazon S3 アーティファクトもクリーンアップするには:

```
aws neptunedata cancel-ml-model-transform-job \
  --endpoint-url https://{{your-neptune-endpoint}}:{{port}} \
  --id "{{(the job ID)}}" \
  --clean
```

詳細については、 AWS CLI 「 コマンドリファレンス」の[cancel-ml-model-transform-job](https://docs.aws.amazon.com/cli/latest/reference/neptunedata/cancel-ml-model-transform-job.html)」を参照してください。

------
#### [ SDK ]

```
import boto3
from botocore.config import Config

client = boto3.client(
    'neptunedata',
    endpoint_url='https://{{your-neptune-endpoint}}:{{port}}',
    config=Config(read_timeout=None, retries={'total_max_attempts': 1})
)

response = client.cancel_ml_model_transform_job(
    id='{{(the job ID)}}',
    clean=True
)

print(response)
```

------
#### [ awscurl ]

```
awscurl https://{{your-neptune-endpoint}}:{{port}}/ml/modeltransform/{{(the job ID)}} \
  --region {{us-east-1}} \
  --service neptune-db \
  -X DELETE
```

Amazon S3 アーティファクトもクリーンアップするには:

```
awscurl "https://{{your-neptune-endpoint}}:{{port}}/ml/modeltransform/{{(the job ID)}}?clean=true" \
  --region {{us-east-1}} \
  --service neptune-db \
  -X DELETE
```

**注記**  
この例では、 AWS 認証情報が 環境で設定されていることを前提としています。{{us-east-1}} を Neptune クラスターのリージョンに置き換えます。

------
#### [ curl ]

```
curl -s \
  -X DELETE "https://{{your-neptune-endpoint}}:{{port}}/ml/modeltransform/{{(the job ID)}}"
```

または、このようになります。

```
curl -s \
  -X DELETE "https://{{your-neptune-endpoint}}:{{port}}/ml/modeltransform/{{(the job ID)}}?clean=true"
```

------

**`modeltransform` 停止ジョブのパラメータ**
+ **`id`** — (*必須*) モデル変換ジョブの一意の識別子。

  *タイプ*: 文字列。
+ **`neptuneIamRoleArn`** — (*オプション*) SageMaker AI および Amazon S3 リソースへの Neptune アクセスを提供する IAM ロールの ARN。

  *タイプ*: 文字列。*注意*: これは DB クラスターパラメータグループに一覧表示されている必要があります。そうしないと、エラーが発生します。
+ **`clean`** — (*オプション*) このフラグは、ジョブが停止したときにすべての Amazon S3 アーティファクトを削除する必要があることを指定します。

  *タイプ*: ブール値。*デフォルト*: `FALSE`。

## Neptune ML `modeltransform` コマンドを使用したアクティブなモデル変換ジョブの一覧表示
<a name="machine-learning-api-modeltransform-list-jobs"></a>

アクティブジョブの一覧表示のサンプル Neptune ML `modeltransform` コマンドは、次のようになります。

------
#### [ AWS CLI ]

```
aws neptunedata list-ml-model-transform-jobs \
  --endpoint-url https://{{your-neptune-endpoint}}:{{port}}
```

結果の数を制限するには:

```
aws neptunedata list-ml-model-transform-jobs \
  --endpoint-url https://{{your-neptune-endpoint}}:{{port}} \
  --max-items 3
```

詳細については、 AWS CLI 「 コマンドリファレンス」の[list-ml-model-transform-jobs](https://docs.aws.amazon.com/cli/latest/reference/neptunedata/list-ml-model-transform-jobs.html)」を参照してください。

------
#### [ SDK ]

```
import boto3
from botocore.config import Config

client = boto3.client(
    'neptunedata',
    endpoint_url='https://{{your-neptune-endpoint}}:{{port}}',
    config=Config(read_timeout=None, retries={'total_max_attempts': 1})
)

response = client.list_ml_model_transform_jobs(
    maxItems=3
)

print(response)
```

------
#### [ awscurl ]

```
awscurl https://{{your-neptune-endpoint}}:{{port}}/ml/modeltransform \
  --region {{us-east-1}} \
  --service neptune-db \
  -X GET
```

結果の数を制限するには:

```
awscurl "https://{{your-neptune-endpoint}}:{{port}}/ml/modeltransform?maxItems=3" \
  --region {{us-east-1}} \
  --service neptune-db \
  -X GET
```

**注記**  
この例では、 AWS 認証情報が 環境で設定されていることを前提としています。{{us-east-1}} を Neptune クラスターのリージョンに置き換えます。

------
#### [ curl ]

```
curl -s "https://{{your-neptune-endpoint}}:{{port}}/ml/modeltransform" | python -m json.tool
```

または、このようになります。

```
curl -s "https://{{your-neptune-endpoint}}:{{port}}/ml/modeltransform?maxItems=3" | python -m json.tool
```

------

**`modeltransform` ジョブの一覧表示のパラメータ**
+ **`maxItems`** — (*オプション*) 返される項目の最大数。

  *タイプ*: 整数。*デフォルト*: `10`。*最大許容値*: `1024`。
+ **`neptuneIamRoleArn`** — (*オプション*) SageMaker AI および Amazon S3 リソースへの Neptune アクセスを提供する IAM ロールの ARN。

  *タイプ*: 文字列。*注意*: これは DB クラスターパラメータグループに一覧表示されている必要があります。そうしないと、エラーが発生します。