Share via


LearningModel 클래스

정의

학습된 기계 학습 모델을 나타냅니다.

public ref class LearningModel sealed : IClosable
/// [Windows.Foundation.Metadata.ContractVersion(Windows.AI.MachineLearning.MachineLearningContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
/// [Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
class LearningModel final : IClosable
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.AI.MachineLearning.MachineLearningContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
[Windows.Foundation.Metadata.Threading(Windows.Foundation.Metadata.ThreadingModel.Both)]
public sealed class LearningModel : System.IDisposable
Public NotInheritable Class LearningModel
Implements IDisposable
상속
Object Platform::Object IInspectable LearningModel
특성
구현

Windows 요구 사항

디바이스 패밀리
Windows 10, version 1809 (10.0.17763.0에서 도입되었습니다.)
API contract
Windows.AI.MachineLearning.MachineLearningContract (v1.0에서 도입되었습니다.)

예제

다음 예제에서는 모델을 로드하고 해당 모델을 사용하여 평가 세션을 만듭니다.

private async Task LoadModelAsync(string _modelFileName)
{
    LearningModel _model;
    LearningModelSession _session;

    try
    {
        // Load and create the model
        var modelFile = 
            await StorageFile.GetFileFromApplicationUriAsync(new Uri($"ms-appx:///Assets/{_modelFileName}"));
        _model = await LearningModel.LoadFromStorageFileAsync(modelFile);

        // Create the evaluation session with the model
        _session = new LearningModelSession(_model);

    }
    catch (Exception ex)
    {
        StatusBlock.Text = $"error: {ex.Message}";
        _model = null;
    }
}

설명

Windows ML과 상호 작용하는 데 사용하는 기본 개체입니다. 이를 사용하여 학습된 ONNX 모델을 로드, 바인딩 및 평가합니다.

  1. Load* 생성자 중 하나를 사용하여 모델을 로드합니다.
  2. InputFeaturesOutputFeatures를 열거하고 모델에 바인딩합니다.
  3. LearningModelSession 및 evalaute를 만듭니다.

Windows Server

Windows Server에서 이 API를 사용하려면 데스크톱 환경과 함께 Windows Server 2019를 사용해야 합니다.

스레드로부터의 안전성

이 API는 스레드로부터 안전합니다.

속성

Author

모델 작성자의 이름입니다.

Description

모델에 대한 설명입니다.

Domain

모델의 도메인입니다.

InputFeatures

모델의 입력 기능 목록입니다.

Metadata

ONNX 모델의 원시 <문자열, 문자열> 메타데이터입니다.

Name

모델의 이름입니다.

OutputFeatures

모델의 출력 기능 목록입니다.

Version

모델의 버전입니다.

메서드

Close()

메모리 내 ONNX 모델을 해제합니다. 호출한 후에는 LearningModelSession 개체를 더 이상 만들 수 없습니다.

Dispose()

관리되지 않는 리소스의 확보, 해제 또는 다시 설정과 관련된 애플리케이션 정의 작업을 수행합니다.

LoadFromFilePath(String)

디스크의 파일에서 ONNX 모델을 로드합니다.

LoadFromFilePath(String, ILearningModelOperatorProvider)

디스크의 파일에서 ONNX 모델을 로드합니다.

LoadFromStorageFileAsync(IStorageFile)

IStorageFile에서 ONNX 모델을 비동기적으로 로드합니다.

LoadFromStorageFileAsync(IStorageFile, ILearningModelOperatorProvider)

IStorageFile에서 ONNX 모델을 비동기적으로 로드합니다.

LoadFromStream(IRandomAccessStreamReference)

스트림에서 ONNX 모델을 로드합니다.

LoadFromStream(IRandomAccessStreamReference, ILearningModelOperatorProvider)

스트림에서 ONNX 모델을 로드합니다.

LoadFromStreamAsync(IRandomAccessStreamReference)

스트림에서 ONNX 모델을 비동기적으로 로드합니다.

LoadFromStreamAsync(IRandomAccessStreamReference, ILearningModelOperatorProvider)

스트림에서 ONNX 모델을 비동기적으로 로드합니다.

적용 대상

추가 정보