LearningModelDevice Classe

Définition

Appareil utilisé pour évaluer le modèle Machine Learning.

public ref class LearningModelDevice sealed
/// [Windows.Foundation.Metadata.Activatable(Windows.AI.MachineLearning.ILearningModelDeviceFactory, 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 LearningModelDevice final
[Windows.Foundation.Metadata.Activatable(typeof(Windows.AI.MachineLearning.ILearningModelDeviceFactory), 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 LearningModelDevice
function LearningModelDevice(deviceKind)
Public NotInheritable Class LearningModelDevice
Héritage
Object Platform::Object IInspectable LearningModelDevice
Attributs

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, sélectionne l’appareil sur lequel évaluer le modèle et crée une session d’évaluation.

private async Task LoadModelAsync(string _modelFileName, bool _useGPU)
{
    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);

        // Select the device to evaluate on
        LearningModelDevice device = null;
        if (_useGPU)
        {
            // Use a GPU or other DirectX device to evaluate the model.
            device = new LearningModelDevice(LearningModelDeviceKind.DirectX);
        }
        else
        {
            // Use the CPU to evaluate the model.
            device = new LearningModelDevice(LearningModelDeviceKind.Cpu);
        }

        // Create the evaluation session with the model and device.
        _session = new LearningModelSession(_model, device);

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

Constructeurs

LearningModelDevice(LearningModelDeviceKind)

Créez un LearningModelDevice à partir du LearningModelDeviceKind spécifié.

Propriétés

AdapterId

Retourne l’identificateur unique de l’appareil.

Direct3D11Device

Retourne l’IDirect3DDevice pour l’appareil.

Méthodes

CreateFromDirect3D11Device(IDirect3DDevice)

Créez un LearningModelDevice à partir du IDirect3DDevice spécifié.

S’applique à

Voir aussi