LearningModelSession Класс

Определение

Используется для оценки моделей машинного обучения.

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
Наследование
Object Platform::Object IInspectable LearningModelSession
Атрибуты
Реализации

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

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

Примеры

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

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

Комментарии

Windows Server

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

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

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

Журнал версий

Версия Windows Версия пакета SDK Добавленная стоимость
1903 18362 LearningModelSession(LearningModel,LearningModelDevice,LearningModelSessionOptions)

Конструкторы

LearningModelSession(LearningModel)

Создает сеанс с использованием устройства по умолчанию.

LearningModelSession(LearningModel, LearningModelDevice)

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

LearningModelSession(LearningModel, LearningModelDevice, LearningModelSessionOptions)

Создает сеанс с использованием указанного устройства и дополнительных параметров вывода.

Свойства

Device

Возвращает устройство оценки сеанса.

EvaluationProperties

Набор свойств, управляющих оценкой модели.

Model

Возвращает обученную модель машинного обучения для этого сеанса.

Методы

Close()

Закрывает текущее LearningModelSession.

Dispose()

Выполняет определяемые приложением задачи, связанные с удалением, высвобождением или сбросом неуправляемых ресурсов.

Evaluate(LearningModelBinding, String)

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

EvaluateAsync(LearningModelBinding, String)

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

EvaluateFeatures(IMap<String,Object>, String)

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

EvaluateFeaturesAsync(IMap<String,Object>, String)

Асинхронная оценка модели машинного обучения с помощью значений признаков в функциях.

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

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