本文為英文版的機器翻譯版本,如內容有任何歧義或不一致之處,概以英文版為準。
使用 Neptune ML 模型轉換命令,您可以使用預先訓練的模型參數計算模型成品,例如在處理後的圖形資料上進行節點嵌入。
在增量模型推論工作流程中,在您處理從 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。
- 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 呼叫,以建立新端點,或使用此工作產生的新模型成品更新現有端點。這可讓新的或更新的端點,為更新的圖形資料提供模型預測。
您也可以提供 trainingJobName 參數,為 Neptune ML 模型訓練期間啟動的任何 SageMaker AI 訓練任務產生模型成品。由於 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。
- 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 中的自訂模型。
modeltransform 命令一律會針對該訓練的最佳 SageMaker AI 訓練任務執行模型轉換。
如需模型轉換工作的詳細資訊,請參閱 modeltransform 命令。