

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

# トレーニング済みモデルを使用して新しいモデルのアーティファクトを生成する
<a name="machine-learning-model-transform"></a>

Neptune ML モデル変換コマンドを使用すると、事前にトレーニングしたモデルパラメータを使用して、処理されたグラフデータに対するノード埋め込みなどのモデルアーティファクトを計算できます。

## 増分推論のためのモデル変換
<a name="machine-learning-model-transform-incremental"></a>

[増分モデル推論ワークフロー](machine-learning-overview-evolving-data-incremental.md#machine-learning-overview-incremental)では、Neptune からエクスポートした更新されたグラフデータを処理した後、次のようなコマンドを使用してモデル変換ジョブを開始できます。

------
#### [ 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 data-processing job-id of a completed job)}}" \
  --ml-model-training-job-id "{{(the ML model training job-id)}}" \
  --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 data-processing job-id of a completed job)}}',
    mlModelTrainingJobId='{{(the ML model training job-id)}}',
    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 data-processing job-id of a completed job)}}",
        "mlModelTrainingJobId": "{{(the ML model training job-id)}}",
        "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 data-processing job-id of a completed job)}}",
        "mlModelTrainingJobId": "{{(the ML model training job-id)}}",
        "modelTransformOutputS3Location" : "s3://{{(your S3 bucket)}}/neptune-model-transform/"
      }'
```

------

その後、このジョブの ID を create-endpoints API 呼び出しに渡して、新しいエンドポイントを作成するか、このジョブによって生成された新しいモデルアーティファクトで既存のエンドポイントを更新できます。これにより、新しいエンドポイントまたは更新されたエンドポイントが、更新されたグラフデータのモデル予測を提供できるようになります。

## あらゆるトレーニングジョブのモデル変換
<a name="machine-learning-model-transform-any-job"></a>

Neptune ML モデルトレーニング中に起動された任意の SageMaker AI トレーニングジョブのモデルアーティファクトを生成する `trainingJobName` パラメータを指定することもできます。Neptune ML モデルトレーニングジョブは潜在的に多くの SageMaker AI トレーニングジョブを起動できるため、これらのいずれかの SageMaker AI トレーニングジョブに基づいて推論エンドポイントを柔軟に作成できます。

例えば、次のようになります。

------
#### [ 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/"
      }'
```

------

元のトレーニングジョブがユーザー指定のカスタムモデルを対象とした場合は、モデル変換を呼び出す際に `customModelTransformParameters` オブジェクトを含める必要があります。カスタムモデルの実装と使用方法の詳細については、[Neptune ML のカスタムモデル](machine-learning-custom-models.md) を参照してください。

**注記**  
`modeltransform` コマンドは常に、そのトレーニングに最適な SageMaker AI トレーニングジョブでモデル変換を実行します。

モデル変換ジョブについては、[モデルトランスフォームコマンド](machine-learning-api-modeltransform.md) を参照してください。