LearningModelEvaluationResult クラス

定義

評価の結果を取得します。

public ref class LearningModelEvaluationResult sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.AI.MachineLearning.MachineLearningContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class LearningModelEvaluationResult final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.AI.MachineLearning.MachineLearningContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class LearningModelEvaluationResult
Public NotInheritable Class LearningModelEvaluationResult
継承
Object Platform::Object IInspectable LearningModelEvaluationResult
属性

Windows の要件

デバイス ファミリ
Windows 10, version 1809 (10.0.17763.0 で導入)
API contract
Windows.AI.MachineLearning.MachineLearningContract (v1.0 で導入)

次の例では、モデルの最初の入力および出力機能を取得し、出力フレームを作成し、入力と出力の特徴をバインドして、モデルを評価します。

private async Task EvaluateModelAsync(
    VideoFrame _inputFrame, 
    LearningModelSession _session, 
    IReadOnlyList<ILearningModelFeatureDescriptor> _inputFeatures, 
    IReadOnlyList<ILearningModelFeatureDescriptor> _outputFeatures,
    LearningModel _model)
{
    ImageFeatureDescriptor _inputImageDescription;
    TensorFeatureDescriptor _outputImageDescription;
    LearningModelBinding _binding = null;
    VideoFrame _outputFrame = null;
    LearningModelEvaluationResult _results;

    try
    {
        // Retrieve the first input feature which is an image
        _inputImageDescription =
            _inputFeatures.FirstOrDefault(feature => feature.Kind == LearningModelFeatureKind.Image)
            as ImageFeatureDescriptor;

        // Retrieve the first output feature which is a tensor
        _outputImageDescription =
            _outputFeatures.FirstOrDefault(feature => feature.Kind == LearningModelFeatureKind.Tensor)
            as TensorFeatureDescriptor;

        // Create output frame based on expected image width and height
        _outputFrame = new VideoFrame(
            BitmapPixelFormat.Bgra8, 
            (int)_inputImageDescription.Width, 
            (int)_inputImageDescription.Height);

        // Create binding and then bind input/output features
        _binding = new LearningModelBinding(_session);

        _binding.Bind(_inputImageDescription.Name, _inputFrame);
        _binding.Bind(_outputImageDescription.Name, _outputFrame);

        // Evaluate and get the results
        _results = await _session.EvaluateAsync(_binding, "test");
    }
    catch (Exception ex)
    {
        StatusBlock.Text = $"error: {ex.Message}";
        _model = null;
    }
}

注釈

Windows Server

Windows Server でこの API を使用するには、Windows Server 2019 デスクトップ エクスペリエンスを使用する必要があります。

スレッド セーフ

この API はスレッド セーフです。

プロパティ

CorrelationId

LearningModelSession.Evaluate に渡された省略可能な文字列。

ErrorStatus

評価に失敗した場合は、エラーの原因に関するエラー コードを返します。

Outputs

モデルの出力機能を取得します。

Succeeded

評価が正常に完了した場合は True。それ以外の場合は false。

適用対象

こちらもご覧ください