LearningModelDeviceKind Перечисление

Определение

Определяет список типов устройств, которые могут оценивать модель машинного обучения.

public enum class LearningModelDeviceKind
/// [Windows.Foundation.Metadata.ContractVersion(Windows.AI.MachineLearning.MachineLearningContract, 65536)]
enum class LearningModelDeviceKind
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.AI.MachineLearning.MachineLearningContract), 65536)]
public enum LearningModelDeviceKind
var value = Windows.AI.MachineLearning.LearningModelDeviceKind.default
Public Enum LearningModelDeviceKind
Наследование
LearningModelDeviceKind
Атрибуты

Требования к Windows

Семейство устройств
Windows 10, version 1809 (появилось в 10.0.17763.0)
API contract
Windows.AI.MachineLearning.MachineLearningContract (появилось в v1.0)

Поля

Cpu 1

Используйте ЦП для оценки модели.

Default 0

Система самостоятельно решит, какое устройство следует использовать.

DirectX 2

Используйте GPU или другое устройство DirectX для оценки модели.

DirectXHighPerformance 3

Используйте устройство, определенное системой, для высокой производительности.

DirectXMinPower 4

Используйте системное устройство, определенное политикой, для минимальной мощности.

Примеры

В следующем примере загружается модель, выбирается устройство, на котором будет оцениваться модель, и создается сеанс оценки.

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

Комментарии

Если этот параметр не указан, система решит, какое устройство использовать.

Windows Server

Чтобы использовать этот API в Windows Server, необходимо использовать Windows Server 2019 с возможностями рабочего стола.

Потокобезопасность

Этот API является потокобезопасным.

Применяется к

См. также раздел