9. コンピューティングクラスター
モデルの学習や推論に利用
自動スケーリングの際のmaxnodeやインスタンスサイズ、VNETを指定可能
クラスターはAMLStudioもしくはSDKから作成が可能
pythonSDKから作成する例
from azureml.core.compute import ComputeTarget, AmlCompute
from azureml.core.compute_target import ComputeTargetException
# Specify the configuration for the new cluster
compute_config = AmlCompute.provisioning_configuration(vm_size="STANDARD_D2_V3",
min_nodes=0,
max_nodes=4,
vnet_resourcegroup_name=vnet_resourcegroup_name,
vnet_name=vnet_name,
subnet_name=subnet_name)
# Create the cluster with the specified name and configuration
cpu_cluster = ComputeTarget.create(ws, cpu_cluster_name, compute_config)
9
28. Webサービスエンドポイント
HTTP要求を送信して推論結果を得ることができる
import requests
# send a random row from the test set to score
random_index = np.random.randint(0, len(X_test)-1)
input_data = "{"data": [" + str(list(X_test[random_index])) + "]}"
headers = {'Content-Type': 'application/json'}
# for AKS deployment you'd need to the service key in the header as well
# api_key = service.get_key()
# headers = {'Content-Type':'application/json', 'Authorization':('Bearer '+ api_key)}
resp = requests.post(service.scoring_uri, input_data, headers=headers)
print("POST to url", service.scoring_uri)
#print("input data:", input_data)
print("label:", y_test[random_index])
print("prediction:", resp.text)
参考:イメージの分類チュートリアル:モデルをデプロイする-AzureMachineLearning 28