Share via


LearningModelEvaluationResult Classe

Definizione

Ottenere i risultati della valutazione.

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
Ereditarietà
Object Platform::Object IInspectable LearningModelEvaluationResult
Attributi

Requisiti Windows

Famiglia di dispositivi
Windows 10, version 1809 (è stato introdotto in 10.0.17763.0)
API contract
Windows.AI.MachineLearning.MachineLearningContract (è stato introdotto in v1.0)

Esempio

L'esempio seguente recupera le prime funzionalità di input e output del modello, crea un frame di output, associa le funzionalità di input e output e valuta il modello.

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

Commenti

Windows Server

Per usare questa API in Windows Server, è necessario usare Windows Server 2019 con Esperienza desktop.

Thread safety

Questa API è thread-safe.

Proprietà

CorrelationId

Stringa facoltativa passata a LearningModelSession.Evaluate.

ErrorStatus

Se la valutazione non è riuscita, restituisce un codice di errore per ciò che ha causato l'errore.

Outputs

Ottiene le funzionalità di output del modello.

Succeeded

True se la valutazione è stata completata correttamente; in caso contrario, false.

Si applica a

Vedi anche