ResourceConfiguration 類別

定義 Azure Machine Learning 資源之資源設定的詳細資料。

初始化 ResourceConfiguration。

繼承
builtins.object
ResourceConfiguration

建構函式

ResourceConfiguration(cpu=None, memory_in_gb=None, gpu=None)

參數

名稱 Description
cpu

要配置給此資源的 CPU 核心數目。 可以是十進位。

預設值: None
memory_in_gb

以 GB 為單位的記憶體 (量,) 配置給此資源。 可以是十進位。

預設值: None
gpu
int

要為此資源配置的 GPU 數目。

預設值: None
cpu
必要

要配置給此資源的 CPU 核心數目。 可以是十進位。

memory_in_gb
必要

以 GB 為單位的記憶體 (量,) 配置給此資源。 可以是十進位。

gpu
必要
int

要為此資源配置的 GPU 數目。

備註

使用這個類別初始化資源組態。 例如,下列程式碼示範如何註冊模型,以指定架構、輸入和輸出資料集,以及資源組態。


   import sklearn

   from azureml.core import Model
   from azureml.core.resource_configuration import ResourceConfiguration


   model = Model.register(workspace=ws,
                          model_name='my-sklearn-model',                # Name of the registered model in your workspace.
                          model_path='./sklearn_regression_model.pkl',  # Local file to upload and register as a model.
                          model_framework=Model.Framework.SCIKITLEARN,  # Framework used to create the model.
                          model_framework_version=sklearn.__version__,  # Version of scikit-learn used to create the model.
                          sample_input_dataset=input_dataset,
                          sample_output_dataset=output_dataset,
                          resource_configuration=ResourceConfiguration(cpu=1, memory_in_gb=0.5),
                          description='Ridge regression model to predict diabetes progression.',
                          tags={'area': 'diabetes', 'type': 'regression'})

   print('Name:', model.name)
   print('Version:', model.version)

方法

deserialize

將 JSON 物件轉換成 ResourceConfiguration 物件。

serialize

將此 ResourceConfiguration 轉換成 JSON 序列化字典。

deserialize

將 JSON 物件轉換成 ResourceConfiguration 物件。

static deserialize(payload_obj)

參數

名稱 Description
payload_obj
必要

要轉換成 ResourceConfiguration 物件的 JSON 物件。

傳回

類型 Description

所提供 JSON 物件的 ResourceConfiguration 標記法。

serialize

將此 ResourceConfiguration 轉換成 JSON 序列化字典。

serialize()

傳回

類型 Description

此 ResourceConfiguration 的 JSON 表示。