Share via


LearningModelEvaluationResult Kelas

Definisi

Dapatkan hasil evaluasi.

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
Warisan
Object Platform::Object IInspectable LearningModelEvaluationResult
Atribut

Persyaratan Windows

Rangkaian perangkat
Windows 10, version 1809 (diperkenalkan dalam 10.0.17763.0)
API contract
Windows.AI.MachineLearning.MachineLearningContract (diperkenalkan dalam v1.0)

Contoh

Contoh berikut mengambil fitur input dan output pertama dari model, membuat bingkai output, mengikat fitur input dan output, dan mengevaluasi model.

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;
    }
}

Keterangan

Windows Server

Untuk menggunakan API ini di Windows Server, Anda harus menggunakan Windows Server 2019 dengan Pengalaman Desktop.

Keamanan utas

API ini aman untuk utas.

Properti

CorrelationId

String opsional yang diteruskan ke LearningModelSession.Evaluate.

ErrorStatus

Jika evaluasi gagal, mengembalikan kode kesalahan untuk apa yang menyebabkan kegagalan.

Outputs

Mendapatkan fitur output model.

Succeeded

True jika evaluasi berhasil diselesaikan; jika tidak, salah.

Berlaku untuk

Lihat juga