Azure Machine Learning SDK v2와 구성 요소를 사용하여 기계 학습 파이프라인 만들기 및 실행

적용 대상: Python SDK azure-ai-ml v2(현재)

이 문서에서는 Python SDK v2를 사용하여 Azure Machine Learning 파이프라인을 빌드하여 데이터 준비, 이미지 분류 모델 학습, 모델 점수 매기기라는 세 단계가 포함된 이미지 분류 작업을 완료하는 방법을 알아봅니다. 기계 학습 파이프라인은 속도, 이식성 및 재사용을 통해 워크플로를 최적화하므로 인프라 및 자동화 대신 기계 학습에 집중할 수 있습니다.

이 예제에서는 Fashion MNIST 데이터 세트의 이미지를 분류하도록 간단한 Keras 나선형 신경망을 학습시킵니다. 파이프라인은 다음과 같습니다.

이미지 분류 Keras 예의 파이프라인 그래프를 보여 주는 스크린샷.

이 문서에서는 다음 작업을 완료합니다.

  • 파이프라인 작업에 대한 입력 데이터 준비
  • 데이터를 준비하고 학습하고 점수를 매기기 위해 세 가지 구성 요소를 만듭니다.
  • 구성 요소에서 파이프라인 작성
  • 컴퓨팅으로 작업 영역에 액세스
  • 파이프라인 작업 제출
  • 구성 요소 및 학습된 인공신경망의 출력 검토
  • (선택 사항) 작업 영역 내에서 추가 재사용 및 공유를 위해 구성 요소를 등록합니다.

Azure 구독이 없는 경우 시작하기 전에 체험 계정을 만듭니다. 지금 Azure Machine Learning 평가판 또는 유료 버전을 사용해 보세요.

필수 조건

  • Azure Machine Learning 작업 영역 - 없는 경우 리소스 만들기 자습서를 완료합니다.

  • Azure Machine Learning Python SDK v2(설치 지침)를 설치한 Python 환경 - 시작하기 섹션을 확인합니다. 이 환경은 Azure Machine Learning 리소스를 정의하고 제어하기 위한 환경이며 학습을 위해 런타임에 사용되는 환경과 별개입니다.

  • 예제 리포지토리 복제

    학습 예제를 실행하려면 먼저 예제 리포지토리를 복제하고 sdk 디렉터리로 변경합니다.

    git clone --depth 1 https://github.com/Azure/azureml-examples
    cd azureml-examples/sdk
    

대화형 Python 세션 시작

이 문서에서는 Azure Machine Learning용 Python SDK를 사용하여 Azure Machine Learning 파이프라인을 만들고 제어합니다. 이 문서에서는 Python REPL 환경 또는 Jupyter Notebook에서 코드 조각을 대화형으로 실행한다고 가정합니다.

이 문서는 Azure Machine Learning 예제 리포지토리의 sdk/python/jobs/pipelines/2e_image_classification_keras_minist_convnet 디렉터리에 있는 image_classification_keras_minist_convnet.ipynb Notebook을 기반으로 합니다.

필수 라이브러리 가져오기

이 문서에 필요한 모든 Azure Machine Learning 필수 라이브러리를 가져옵니다.

# import required libraries
from azure.identity import DefaultAzureCredential, InteractiveBrowserCredential

from azure.ai.ml import MLClient
from azure.ai.ml.dsl import pipeline
from azure.ai.ml import load_component

파이프라인 작업에 대한 입력 데이터 준비

이 이미지 분류 파이프라인에 대한 입력 데이터를 준비해야 합니다.

Fashion-MNIST는 10개의 클래스로 구분된 패션 이미지의 데이터 세트입니다. 각 이미지는 28x28 회색조 이미지이며, 60,000개의 학습 이미지와 10,000개의 테스트 이미지가 있습니다. 이미지 분류 문제로서 Fashion-MNIST는 클래식 MNIST 필기 숫자 데이터베이스보다 어렵습니다. 원래 필기 숫자 데이터베이스와 동일한 압축된 이진 형식으로 배포됩니다.

필요한 모든 Azure Machine Learning 필수 라이브러리를 가져옵니다.

Input을 정의하여 데이터 원본 위치에 대한 참조를 만듭니다. 데이터는 기존 위치에 그대로 남아 있으므로 추가 스토리지 비용이 발생하지 않습니다.

파이프라인 빌드를 위한 구성 요소 만들기

이미지 분류 작업은 데이터 준비, 모델 학습 및 모델 점수 매기기의 세 단계로 나눌 수 있습니다.

Azure Machine Learning 구성 요소는 Machine Learning 파이프라인에서 한 단계를 수행하는 자체 포함된 코드 조각입니다. 이 문서에서는 이미지 분류 작업을 위한 세 가지 구성 요소를 만듭니다.

  • 학습 및 테스트용 데이터 준비
  • 학습 데이터를 사용하여 이미지 분류를 위한 신경망 학습
  • 테스트 데이터를 사용하여 모델 점수 매기기

각 구성 요소에 대해 다음을 준비해야 합니다.

  1. 실행 논리가 포함된 Python 스크립트 준비

  2. 구성 요소의 인터페이스 정의

  3. 런타임 환경, 구성 요소를 실행하는 명령 등을 포함하여 구성 요소의 다른 메타데이터를 추가합니다.

다음 섹션에서는 Python 함수를 사용하는 처음 두 구성 요소와 YAML 정의를 사용하는 세 번째 구성 요소의 두 가지 방법으로 구성 요소를 만드는 방법을 보여 줍니다.

데이터 준비 구성 요소 만들기

이 파이프라인의 첫 번째 구성 요소는 fashion_ds의 압축 데이터 파일을 학습용과 채점용의 두 csv 파일로 변환합니다. Python 함수를 사용하여 이 구성 요소를 정의합니다.

Azure Machine Learning 예제 리포지토리의 예제를 따르는 경우 원본 파일은 이미 prep/ 폴더에서 사용할 수 있습니다. 이 폴더에는 구성 요소를 구성하기 위한 두 개의 파일이 있습니다. prep_component.py(구성 요소 정의) 및 conda.yaml(구성 요소의 런타임 환경 정의).

Python 함수를 사용하여 구성 요소 정의

command_component() 함수를 데코레이터로 사용하면 Python 함수에서 실행할 구성 요소의 인터페이스, 메타데이터 및 코드를 쉽게 정의할 수 있습니다. 데코레이트된 각 Python 함수는 파이프라인 서비스가 처리할 수 있는 단일 정적 사양(YAML)으로 변환됩니다.

# Converts MNIST-formatted files at the passed-in input path to training data output path and test data output path
import os
from pathlib import Path
from mldesigner import command_component, Input, Output


@command_component(
    name="prep_data",
    version="1",
    display_name="Prep Data",
    description="Convert data to CSV file, and split to training and test data",
    environment=dict(
        conda_file=Path(__file__).parent / "conda.yaml",
        image="mcr.microsoft.com/azureml/openmpi4.1.0-ubuntu20.04",
    ),
)
def prepare_data_component(
    input_data: Input(type="uri_folder"),
    training_data: Output(type="uri_folder"),
    test_data: Output(type="uri_folder"),
):
    convert(
        os.path.join(input_data, "train-images-idx3-ubyte"),
        os.path.join(input_data, "train-labels-idx1-ubyte"),
        os.path.join(training_data, "mnist_train.csv"),
        60000,
    )
    convert(
        os.path.join(input_data, "t10k-images-idx3-ubyte"),
        os.path.join(input_data, "t10k-labels-idx1-ubyte"),
        os.path.join(test_data, "mnist_test.csv"),
        10000,
    )


def convert(imgf, labelf, outf, n):
    f = open(imgf, "rb")
    l = open(labelf, "rb")
    o = open(outf, "w")

    f.read(16)
    l.read(8)
    images = []

    for i in range(n):
        image = [ord(l.read(1))]
        for j in range(28 * 28):
            image.append(ord(f.read(1)))
        images.append(image)

    for image in images:
        o.write(",".join(str(pix) for pix in image) + "\n")
    f.close()
    o.close()
    l.close()

위의 코드는 @command_component 데코레이터를 사용하여 표시 이름이 Prep Data인 구성 요소를 정의합니다.

  • name은 구성 요소의 고유 식별자입니다.

  • version 구성 요소의 현재 버전을 가져옵니다. 구성 요소에는 여러 버전이 있을 수 있습니다.

  • display_name은 고유하지 않은 UI 구성 요소의 친숙한 표시 이름입니다.

  • description은 일반적으로 이 구성 요소가 완료할 수 있는 작업을 설명합니다.

  • environment는 이 구성 요소의 런타임 환경을 지정합니다. 이 구성 요소의 환경은 Docker 이미지를 지정하고 conda.yaml 파일을 참조하세요.

    conda.yaml 파일에는 다음과 같이 구성 요소에 사용되는 모든 패키지가 포함되어 있습니다.

    name: imagekeras_prep_conda_env
    channels:
      - defaults
    dependencies:
      - python=3.7.11
      - pip=20.0
      - pip:
        - mldesigner==0.1.0b4
    
  • prepare_data_component 함수는 input_data에 대해 하나의 입력을 정의하고 training_datatest_data에 대해 두 개의 출력을 정의합니다. input_data는 입력 데이터 경로입니다. training_datatest_data는 학습 데이터 및 테스트 데이터의 출력 데이터 경로입니다.

  • 이 구성 요소는 input_data의 데이터를 학습 데이터 csv에서 training_data로, 테스트 데이터 csv를 test_data로 변환합니다.

다음은 스튜디오 UI에서 구성 요소의 모양입니다.

  • 구성 요소는 파이프라인 그래프의 블록입니다.
  • input_data, training_datatest_data는 데이터 스트리밍을 위해 다른 구성 요소에 연결하는 구성 요소의 포트입니다.

UI 및 코드의 데이터 준비 구성 요소 스크린샷.

이제 Prep Data 구성 요소에 대한 모든 원본 파일을 준비했습니다.

모델 학습 구성 요소 만들기

이 섹션에서는 Prep Data 구성 요소와 같은 Python 함수에서 이미지 분류 모델을 학습시키기 위한 구성 요소를 만듭니다.

차이점은 학습 논리가 더 복잡하기 때문에 원본 학습 코드를 별도의 Python 파일에 넣을 수 있다는 것입니다.

이 구성 요소의 원본 파일은 Azure Machine Learning 예제 리포지토리train/ 폴더에 있습니다. 이 폴더에는 구성 요소를 구성하는 세 개의 파일이 포함되어 있습니다.

  • train.py: 모델을 학습시키는 실제 논리를 포함합니다.
  • train_component.py: 구성 요소의 인터페이스를 정의하고 train.py에서 함수를 가져옵니다.
  • conda.yaml: 구성 요소의 런타임 환경을 정의합니다.

실행 논리가 포함된 스크립트 가져오기

train.py 파일에는 이미지 분류를 위해 Keras 인공신경망을 학습시키는 학습 모델 논리를 수행하는 일반 Python 함수가 포함되어 있습니다. 코드를 보려면 GitHub의 train.py 파일을 참조하세요.

Python 함수를 사용하여 구성 요소 정의

학습 함수를 성공적으로 정의한 후 Azure Machine Learning SDK v2에서 @command_component를 사용하여 Azure Machine Learning 파이프라인에서 사용할 수 있는 구성 요소로 함수를 래핑할 수 있습니다.

import os
from pathlib import Path
from mldesigner import command_component, Input, Output


@command_component(
    name="train_image_classification_keras",
    version="1",
    display_name="Train Image Classification Keras",
    description="train image classification with keras",
    environment=dict(
        conda_file=Path(__file__).parent / "conda.yaml",
        image="mcr.microsoft.com/azureml/openmpi4.1.0-ubuntu20.04",
    ),
)
def keras_train_component(
    input_data: Input(type="uri_folder"),
    output_model: Output(type="uri_folder"),
    epochs=10,
):
    # avoid dependency issue, execution logic is in train() func in train.py file
    from train import train

    train(input_data, output_model, epochs)

위의 코드는 @command_component를 사용하여 표시 이름이 Train Image Classification Keras인 구성 요소를 정의합니다.

  • keras_train_component 함수는 학습 데이터의 출처인 입력 input_data, 학습 중 epoch를 지정하는 입력 epochs, 모델 파일을 출력하는 출력 output_model을 하나씩 정의합니다. epochs의 기본값은 10입니다. 이 구성 요소의 실행 논리는 위의 train.py에 있는 train() 함수에서 가져왔습니다.

모델 학습 구성 요소는 데이터 준비 구성 요소보다 약간 더 복잡한 구성을 가지고 있습니다. conda.yaml은 다음과 같습니다.

name: imagekeras_train_conda_env
channels:
  - defaults
dependencies:
  - python=3.7.11
  - pip=20.2
  - pip:
    - mldesigner==0.1.0b12
    - azureml-mlflow==1.50.0
    - tensorflow==2.7.0
    - numpy==1.21.4
    - scikit-learn==1.0.1
    - pandas==1.3.4
    - matplotlib==3.2.2
    - protobuf==3.20.0

이제 Train Image Classification Keras 구성 요소에 대한 모든 원본 파일을 준비했습니다.

모델 점수 매기기 구성 요소 만들기

이 섹션에서는 이전 구성 요소 외에 Yaml 사양 및 스크립트를 통해 학습된 모델의 점수를 매기기 위한 구성 요소를 만듭니다.

Azure Machine Learning 예제 리포지토리의 예제를 따르는 경우 원본 파일은 이미 score/ 폴더에서 사용할 수 있습니다. 이 폴더에는 구성 요소를 구성하는 세 개의 파일이 포함되어 있습니다.

  • score.py: 구성 요소의 소스 코드를 포함합니다.
  • score.yaml: 구성 요소의 인터페이스 및 기타 세부 정보를 정의합니다.
  • conda.yaml: 구성 요소의 런타임 환경을 정의합니다.

실행 논리가 포함된 스크립트 가져오기

score.py 파일에는 학습 모델 논리를 수행하는 일반 Python 함수가 포함되어 있습니다.

from tensorflow import keras
from keras.models import Sequential
from keras.layers import Dense, Dropout, Flatten
from keras.layers import Conv2D, MaxPooling2D
from tensorflow.keras.layers import BatchNormalization
from tensorflow.keras.utils import to_categorical
from keras.callbacks import Callback
from keras.models import load_model

import argparse
from pathlib import Path
import numpy as np
import pandas as pd
import os
import matplotlib.pyplot as plt
import mlflow


def get_file(f):

    f = Path(f)
    if f.is_file():
        return f
    else:
        files = list(f.iterdir())
        if len(files) == 1:
            return files[0]
        else:
            raise Exception("********This path contains more than one file*******")


def parse_args():
    # setup argparse
    parser = argparse.ArgumentParser()

    # add arguments
    parser.add_argument(
        "--input_data", type=str, help="path containing data for scoring"
    )
    parser.add_argument(
        "--input_model", type=str, default="./", help="input path for model"
    )

    parser.add_argument(
        "--output_result", type=str, default="./", help="output path for model"
    )

    # parse args
    args = parser.parse_args()

    # return args
    return args


def score(input_data, input_model, output_result):

    test_file = get_file(input_data)
    data_test = pd.read_csv(test_file, header=None)

    img_rows, img_cols = 28, 28
    input_shape = (img_rows, img_cols, 1)

    # Read test data
    X_test = np.array(data_test.iloc[:, 1:])
    y_test = to_categorical(np.array(data_test.iloc[:, 0]))
    X_test = (
        X_test.reshape(X_test.shape[0], img_rows, img_cols, 1).astype("float32") / 255
    )

    # Load model
    files = [f for f in os.listdir(input_model) if f.endswith(".h5")]
    model = load_model(input_model + "/" + files[0])

    # Log metrics of the model
    eval = model.evaluate(X_test, y_test, verbose=0)

    mlflow.log_metric("Final test loss", eval[0])
    print("Test loss:", eval[0])

    mlflow.log_metric("Final test accuracy", eval[1])
    print("Test accuracy:", eval[1])

    # Score model using test data
    y_predict = model.predict(X_test)
    y_result = np.argmax(y_predict, axis=1)

    # Output result
    np.savetxt(output_result + "/predict_result.csv", y_result, delimiter=",")


def main(args):
    score(args.input_data, args.input_model, args.output_result)


# run script
if __name__ == "__main__":
    # parse args
    args = parse_args()

    # call main function
    main(args)

score.py의 코드는 input_data, input_modeloutput_result의 세 가지 명령줄 인수를 사용합니다. 프로그램은 입력 데이터를 사용하여 입력 모델을 채점한 다음 채점 결과를 출력합니다.

Yaml을 통해 구성 요소 정의

이 섹션에서는 유효한 YAML 구성 요소 사양 형식으로 구성 요소 사양을 만드는 방법을 알아봅니다. 이 파일은 다음 정보를 지정합니다.

  • 메타데이터: name, display_name, version, type 등
  • 인터페이스: 입력 및 출력
  • 명령, 코드, 환경: 구성 요소를 실행하는 데 사용되는 명령, 코드 및 환경
$schema: https://azuremlschemas.azureedge.net/latest/commandComponent.schema.json
type: command

name: score_image_classification_keras
display_name: Score Image Classification Keras
inputs:
  input_data: 
    type: uri_folder
  input_model:
    type: uri_folder
outputs:
  output_result:
    type: uri_folder
code: ./
command: python score.py --input_data ${{inputs.input_data}} --input_model ${{inputs.input_model}} --output_result ${{outputs.output_result}}
environment:
  conda_file: ./conda.yaml
  image: mcr.microsoft.com/azureml/openmpi4.1.0-ubuntu20.04
  • name은 구성 요소의 고유 식별자입니다. 표시 이름은 Score Image Classification Keras입니다.
  • 이 구성 요소에는 두 개의 입력과 하나의 출력이 있습니다.
  • 소스 코드 경로는 code 섹션에 정의되어 있으며 구성 요소가 클라우드에서 실행될 때 해당 경로의 모든 파일이 이 구성 요소의 스냅샷으로 업로드됩니다.
  • command 섹션은 이 구성 요소를 실행하는 동안 실행할 명령을 지정합니다.
  • environment 섹션에는 Docker 이미지와 conda yaml 파일이 포함되어 있습니다. 원본 파일은 샘플 리포지토리에 있습니다.

이제 모델 점수 매기기 구성 요소에 대한 모든 원본 파일이 있습니다.

구성 요소를 로드하여 파이프라인 빌드

Python 함수로 정의된 데이터 준비 구성 요소와 모델 학습 구성 요소는 일반 Python 함수처럼 구성 요소를 가져올 수 있습니다.

다음 코드에서는 prep 폴더의 prep_component.py 파일과 train 폴더의 train_component 파일에서 각각 prepare_data_component()keras_train_component() 함수를 가져옵니다.

%load_ext autoreload
%autoreload 2

# load component function from component python file
from prep.prep_component import prepare_data_component
from train.train_component import keras_train_component

# print hint of components
help(prepare_data_component)
help(keras_train_component)

yaml에서 정의한 점수 구성 요소의 경우 load_component() 함수를 사용하여 로드할 수 있습니다.

# load component function from yaml
keras_score_component = load_component(source="./score/score.yaml")

파이프라인 빌드

이제 모든 구성 요소와 입력 데이터를 만들고 로드하여 파이프라인을 빌드했습니다. 파이프라인으로 구성할 수 있습니다.

참고 항목

서버리스 컴퓨팅을 사용하려면 맨 위에 from azure.ai.ml.entities import ResourceConfiguration을(를) 추가합니다. 그런 후 다음을 바꿉니다.

  • default_compute=cpu_compute_target,(default_compute="serverless", 사용)
  • train_node.compute = gpu_compute_target(train_node.resources = "ResourceConfiguration(instance_type="Standard_NC6s_v3",instance_count=2) 사용)
# define a pipeline containing 3 nodes: Prepare data node, train node, and score node
@pipeline(
    default_compute=cpu_compute_target,
)
def image_classification_keras_minist_convnet(pipeline_input_data):
    """E2E image classification pipeline with keras using python sdk."""
    prepare_data_node = prepare_data_component(input_data=pipeline_input_data)

    train_node = keras_train_component(
        input_data=prepare_data_node.outputs.training_data
    )
    train_node.compute = gpu_compute_target

    score_node = keras_score_component(
        input_data=prepare_data_node.outputs.test_data,
        input_model=train_node.outputs.output_model,
    )


# create a pipeline
pipeline_job = image_classification_keras_minist_convnet(pipeline_input_data=mnist_ds)

파이프라인에는 기본 컴퓨팅 cpu_compute_target이 있습니다. 즉, 특정 노드에 대한 컴퓨팅을 지정하지 않으면 해당 노드가 기본 컴퓨팅에서 실행됩니다.

파이프라인에는 파이프라인 수준 입력 pipeline_input_data가 있습니다. 파이프라인 작업을 제출할 때 파이프라인 입력에 값을 할당할 수 있습니다.

파이프라인에는 세 개의 노드, prepare_data_node, train_node 및 score_node가 있습니다.

  • prepare_data_nodeinput_datapipeline_input_data의 값을 사용합니다.

  • train_nodeinput_data는 prepare_data_node의 training_data 출력에서 가져옵니다.

  • score_node의 input_data는 prepare_data_node의 test_data 출력에서 가져오고 input_model은 train_node의 output_model에서 가져옵니다.

  • train_node는 CNN 모델을 학습시키므로 해당 컴퓨팅을 gpu_compute_target으로 지정하면 학습 성능이 개선될 수 있습니다.

파이프라인 작업 제출

이제 파이프라인을 구성했으므로 작업 영역에 제출할 수 있습니다. 작업을 제출하려면 먼저 작업 영역에 연결해야 합니다.

작업 영역에 액세스

자격 증명 구성

DefaultAzureCredential을 사용하여 작업 영역에 액세스합니다. DefaultAzureCredential은 대부분의 Azure SDK 인증 시나리오를 처리할 수 있어야 합니다.

작동하지 않는 경우 사용 가능한 자격 증명에 대한 참조: 자격 증명 구성 예, azure-identity 참조 문서.

try:
    credential = DefaultAzureCredential()
    # Check if given credential can get token successfully.
    credential.get_token("https://management.azure.com/.default")
except Exception as ex:
    # Fall back to InteractiveBrowserCredential in case DefaultAzureCredential not work
    credential = InteractiveBrowserCredential()

컴퓨팅으로 작업 영역에 대한 핸들 가져오기

Azure Machine Learning Services를 관리하기 위한 MLClient 개체를 만듭니다. 서버리스 컴퓨팅을 사용하는 경우 이러한 컴퓨팅을 만들 필요가 없습니다.

# Get a handle to workspace
ml_client = MLClient.from_config(credential=credential)

# Retrieve an already attached Azure Machine Learning Compute.
cpu_compute_target = "cpu-cluster"
print(ml_client.compute.get(cpu_compute_target))
gpu_compute_target = "gpu-cluster"
print(ml_client.compute.get(gpu_compute_target))

Important

이 코드 조각은 작업 영역 구성 json 파일이 현재 디렉터리 또는 그 부모 디렉터리에 저장될 것으로 예상합니다. 작업 영역 만들기에 대한 자세한 내용은 작업 영역 리소스 만들기를 참조하세요. 파일에 구성 저장에 대한 자세한 내용은 작업 영역 구성 파일 만들기를 참조 하세요.

작업 영역에 파이프라인 작업 제출

이제 작업 영역에 대한 핸들을 얻었으므로 파이프라인 작업을 제출할 수 있습니다.

pipeline_job = ml_client.jobs.create_or_update(
    pipeline_job, experiment_name="pipeline_samples"
)
pipeline_job

위의 코드는 이 이미지 분류 파이프라인 작업을 pipeline_samples라는 실험에 제출합니다. 실험이 존재하지 않는 경우 자동으로 만들어집니다. pipeline_input_datafashion_ds를 사용합니다.

pipeline_job에 대한 호출은 다음과 유사한 출력을 생성합니다.

Experiment를 제출(submit)하기 위한 호출이 빠르게 완료되고 다음과 비슷한 출력이 생성됩니다.

실험 이름 Type 상태 세부 정보 페이지
pipeline_samples sharp_pipe_4gvqx6h1fb 파이프라인 준비 Azure Machine Learning 스튜디오에 연결합니다.

링크를 열어 파이프라인 실행을 모니터링하거나 다음을 실행하여 완료될 때까지 차단할 수 있습니다.

# wait until the job completes
ml_client.jobs.stream(pipeline_job.name)

Important

첫 번째 파이프라인 실행에는 약 15분이 걸립니다. 모든 종속성을 다운로드해야 하고, Docker 이미지를 만들고, Python 환경을 프로비저닝하고 만듭니다. 파이프라인을 다시 실행하면 해당 리소스를 만드는 대신 다시 사용하므로 이 실행에 걸리는 시간이 크게 줄어듭니다. 그러나 파이프라인의 총 실행 시간은 스크립트의 워크로드 및 각 파이프라인 단계에서 실행되는 프로세스에 따라 달라집니다.

UI에서 출력 체크 아웃 및 파이프라인 디버그

파이프라인의 작업 세부 정보 페이지인 Link to Azure Machine Learning studio를 열 수 있습니다. 다음과 같은 파이프라인 그래프가 표시됩니다.

파이프라인 작업 세부 정보 페이지의 스크린샷.

구성 요소를 마우스 오른쪽 단추로 클릭하여 각 구성 요소의 로그 및 출력을 확인하거나 구성 요소를 선택하여 세부 정보 창을 열 수 있습니다. UI에서 파이프라인을 디버그하는 방법에 대해 자세히 알아보려면 디버그 파이프라인 실패 사용 방법을 참조하세요.

(선택 사항) 작업 영역에 구성 요소 등록

이전 섹션에서는 E2E가 이미지 분류 작업을 완료하기 위해 세 가지 구성 요소를 사용하여 파이프라인을 빌드했습니다. 또한 구성 요소를 작업 영역에 등록하여 작업 영역 내에서 공유하고 다시 사용할 수 있습니다. 다음은 데이터 준비 구성 요소를 등록하는 예입니다.

try:
    # try get back the component
    prep = ml_client.components.get(name="prep_data", version="1")
except:
    # if not exists, register component using following code
    prep = ml_client.components.create_or_update(prepare_data_component)

# list all components registered in workspace
for c in ml_client.components.list():
    print(c)

ml_client.components.get()을 사용하면 이름 및 버전별로 등록된 구성 요소를 가져올 수 있습니다. ml_client.components.create_or_update()를 사용하여 이전에 Python 함수 또는 yaml에서 로드된 구성 요소를 등록할 수 있습니다.

다음 단계