LearningModelDevice Clase

Definición

Dispositivo que se usa para evaluar el modelo de 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
Herencia
Object Platform::Object IInspectable LearningModelDevice
Atributos

Requisitos de Windows

Familia de dispositivos
Windows 10, version 1809 (se introdujo en la versión 10.0.17763.0)
API contract
Windows.AI.MachineLearning.MachineLearningContract (se introdujo en la versión v1.0)

Ejemplos

En el ejemplo siguiente se carga un modelo, se selecciona el dispositivo en el que se va a evaluar el modelo y se crea una sesión de evaluación.

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

Comentarios

Windows Server

Para usar esta API en Windows Server, debe usar Windows Server 2019 con experiencia de escritorio.

Seguridad para subprocesos

Esta API es segura para subprocesos.

Constructores

LearningModelDevice(LearningModelDeviceKind)

Cree un objeto LearningModelDevice a partir del elemento LearningModelDeviceKind especificado.

Propiedades

AdapterId

Devuelve el identificador único del dispositivo.

Direct3D11Device

Devuelve el IDirect3DDevice para el dispositivo.

Métodos

CreateFromDirect3D11Device(IDirect3DDevice)

Cree un objeto LearningModelDevice a partir del IDirect3DDevice especificado.

Se aplica a

Consulte también