-api-id | -api-type | ms.custom |
---|---|---|
T:Windows.AI.MachineLearning.LearningModelSession |
winrt class |
RS5 |
Used to evaluate machine learning models.
To use this API on Windows Server, you must use Windows Server 2019 with Desktop Experience.
This API is thread-safe.
Windows version | SDK version | Value added |
---|---|---|
1903 | 18362 | LearningModelSession(LearningModel,LearningModelDevice,LearningModelSessionOptions) |
Windows ML, Windows ML samples (GitHub)
The following example loads a model and creates an evaluation session with it.
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;
}
}