LearningModelEvaluationResult 類別
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
取得評估的結果。
public ref class LearningModelEvaluationResult sealed
/// [Windows.Foundation.Metadata.ContractVersion(Windows.AI.MachineLearning.MachineLearningContract, 65536)]
/// [Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
class LearningModelEvaluationResult final
[Windows.Foundation.Metadata.ContractVersion(typeof(Windows.AI.MachineLearning.MachineLearningContract), 65536)]
[Windows.Foundation.Metadata.MarshalingBehavior(Windows.Foundation.Metadata.MarshalingType.Agile)]
public sealed class LearningModelEvaluationResult
Public NotInheritable Class LearningModelEvaluationResult
- 繼承
- 屬性
Windows 需求
裝置系列 |
Windows 10, version 1809 (已於 10.0.17763.0 引進)
|
API contract |
Windows.AI.MachineLearning.MachineLearningContract (已於 v1.0 引進)
|
範例
下列範例會擷取模型的第一個輸入和輸出功能、建立輸出框架、系結輸入和輸出功能,以及評估模型。
private async Task EvaluateModelAsync(
VideoFrame _inputFrame,
LearningModelSession _session,
IReadOnlyList<ILearningModelFeatureDescriptor> _inputFeatures,
IReadOnlyList<ILearningModelFeatureDescriptor> _outputFeatures,
LearningModel _model)
{
ImageFeatureDescriptor _inputImageDescription;
TensorFeatureDescriptor _outputImageDescription;
LearningModelBinding _binding = null;
VideoFrame _outputFrame = null;
LearningModelEvaluationResult _results;
try
{
// Retrieve the first input feature which is an image
_inputImageDescription =
_inputFeatures.FirstOrDefault(feature => feature.Kind == LearningModelFeatureKind.Image)
as ImageFeatureDescriptor;
// Retrieve the first output feature which is a tensor
_outputImageDescription =
_outputFeatures.FirstOrDefault(feature => feature.Kind == LearningModelFeatureKind.Tensor)
as TensorFeatureDescriptor;
// Create output frame based on expected image width and height
_outputFrame = new VideoFrame(
BitmapPixelFormat.Bgra8,
(int)_inputImageDescription.Width,
(int)_inputImageDescription.Height);
// Create binding and then bind input/output features
_binding = new LearningModelBinding(_session);
_binding.Bind(_inputImageDescription.Name, _inputFrame);
_binding.Bind(_outputImageDescription.Name, _outputFrame);
// Evaluate and get the results
_results = await _session.EvaluateAsync(_binding, "test");
}
catch (Exception ex)
{
StatusBlock.Text = $"error: {ex.Message}";
_model = null;
}
}
備註
Windows Server
若要在 Windows Server 上使用此 API,您必須搭配桌面體驗使用 Windows Server 2019。
執行緒安全
此 API 是安全線程。
屬性
CorrelationId |
傳遞至 LearningModelSession.Evaluate的選擇性字串。 |
ErrorStatus |
如果評估失敗,則傳回導致失敗原因的錯誤碼。 |
Outputs |
取得模型的輸出功能。 |
Succeeded |
如果評估成功完成,則為 True;否則為 false。 |