LearningModelSession.EvaluateAsync(LearningModelBinding, String) Метод
Определение
Важно!
Некоторые сведения относятся к предварительной версии продукта, в которую до выпуска могут быть внесены существенные изменения. Майкрософт не предоставляет никаких гарантий, явных или подразумеваемых, относительно приведенных здесь сведений.
Асинхронная оценка модели машинного обучения с помощью значений признаков, уже привязанных в привязках.
public:
virtual IAsyncOperation<LearningModelEvaluationResult ^> ^ EvaluateAsync(LearningModelBinding ^ bindings, Platform::String ^ correlationId) = EvaluateAsync;
/// [Windows.Foundation.Metadata.RemoteAsync]
IAsyncOperation<LearningModelEvaluationResult> EvaluateAsync(LearningModelBinding const& bindings, winrt::hstring const& correlationId);
[Windows.Foundation.Metadata.RemoteAsync]
public IAsyncOperation<LearningModelEvaluationResult> EvaluateAsync(LearningModelBinding bindings, string correlationId);
function evaluateAsync(bindings, correlationId)
Public Function EvaluateAsync (bindings As LearningModelBinding, correlationId As String) As IAsyncOperation(Of LearningModelEvaluationResult)
Параметры
- bindings
- LearningModelBinding
Значения, привязанные к именованным функциям ввода и вывода.
- correlationId
-
String
Platform::String
winrt::hstring
Необязательная строка, предоставляемая пользователем для подключения выходных результатов.
Возвращаемое значение
LearningModelEvaluationResult из оценки.
- Атрибуты
Примеры
В следующем примере извлекаются первые входные и выходные признаки из модели, создается выходной кадр, выполняется привязка входных и выходных признаков и выполняется оценка модели.
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
Чтобы использовать этот API в Windows Server, необходимо использовать Windows Server 2019 с возможностями рабочего стола.
Потокобезопасность
Этот API является потокобезопасным.