LearningModelSession Classe

Définition

Utilisé pour évaluer des modèles Machine Learning.

public ref class LearningModelSession sealed : IClosable
/// [Windows.Foundation.Metadata.Activatable(Windows.AI.MachineLearning.ILearningModelSessionFactory, 65536, "Windows.AI.MachineLearning.MachineLearningContract")]
/// [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 LearningModelSession final : IClosable
/// [Windows.Foundation.Metadata.Activatable(Windows.AI.MachineLearning.ILearningModelSessionFactory, 65536, "Windows.AI.MachineLearning.MachineLearningContract")]
/// [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)]
/// [Windows.Foundation.Metadata.Activatable(Windows.AI.MachineLearning.ILearningModelSessionFactory2, 131072, "Windows.AI.MachineLearning.MachineLearningContract")]
class LearningModelSession final : IClosable
[Windows.Foundation.Metadata.Activatable(typeof(Windows.AI.MachineLearning.ILearningModelSessionFactory), 65536, "Windows.AI.MachineLearning.MachineLearningContract")]
[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 LearningModelSession : System.IDisposable
[Windows.Foundation.Metadata.Activatable(typeof(Windows.AI.MachineLearning.ILearningModelSessionFactory), 65536, "Windows.AI.MachineLearning.MachineLearningContract")]
[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)]
[Windows.Foundation.Metadata.Activatable(typeof(Windows.AI.MachineLearning.ILearningModelSessionFactory2), 131072, "Windows.AI.MachineLearning.MachineLearningContract")]
public sealed class LearningModelSession : System.IDisposable
function LearningModelSession(model, deviceToRunOn)
function LearningModelSession(model, deviceToRunOn, learningModelSessionOptions)
Public NotInheritable Class LearningModelSession
Implements IDisposable
Héritage
Object Platform::Object IInspectable LearningModelSession
Attributs
Implémente

Configuration requise pour Windows

Famille d’appareils
Windows 10, version 1809 (introduit dans 10.0.17763.0)
API contract
Windows.AI.MachineLearning.MachineLearningContract (introduit dans v1.0)

Exemples

L’exemple suivant charge un modèle et crée une session d’évaluation avec celui-ci.

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

Remarques

Windows Server

Pour utiliser cette API sur Windows Server, vous devez utiliser Windows Server 2019 avec Expérience utilisateur.

Sécurité des threads

Cette API est thread-safe.

Historique des versions

Version de Windows Version du SDK Valeur ajoutée
1903 18362 LearningModelSession(LearningModel,LearningModelDevice,LearningModelSessionOptions)

Constructeurs

LearningModelSession(LearningModel)

Crée une session à l’aide de l’appareil par défaut.

LearningModelSession(LearningModel, LearningModelDevice)

Crée une session à l’aide de l’appareil spécifié.

LearningModelSession(LearningModel, LearningModelDevice, LearningModelSessionOptions)

Crée une session à l’aide de l’appareil spécifié et d’options d’inférence supplémentaires.

Propriétés

Device

Retourne l’appareil d’évaluation de la session.

EvaluationProperties

Ensemble de propriétés qui contrôlent l’évaluation du modèle.

Model

Retourne le modèle Machine Learning entraîné pour cette session.

Méthodes

Close()

Ferme la session LearningModelSession actuelle.

Dispose()

Exécute les tâches définies par l'application associées à la libération ou à la redéfinition des ressources non managées.

Evaluate(LearningModelBinding, String)

Évaluez le modèle Machine Learning à l’aide des valeurs de fonctionnalité liées dans les liaisons.

EvaluateAsync(LearningModelBinding, String)

Évaluez de manière asynchrone le modèle Machine Learning à l’aide des valeurs de fonctionnalité déjà liées dans les liaisons.

EvaluateFeatures(IMap<String,Object>, String)

Évaluez le modèle Machine Learning à l’aide des valeurs de fonctionnalité dans les fonctionnalités.

EvaluateFeaturesAsync(IMap<String,Object>, String)

Évaluez de manière asynchrone le modèle Machine Learning à l’aide des valeurs de fonctionnalité dans les fonctionnalités.

S’applique à

Voir aussi