LearningModel.OutputFeatures 属性
定义
重要
一些信息与预发行产品相关,相应产品在发行之前可能会进行重大修改。 对于此处提供的信息,Microsoft 不作任何明示或暗示的担保。
模型的输出特征列表。
public:
property IVectorView<ILearningModelFeatureDescriptor ^> ^ OutputFeatures { IVectorView<ILearningModelFeatureDescriptor ^> ^ get(); };
IVectorView<ILearningModelFeatureDescriptor> OutputFeatures();
public IReadOnlyList<ILearningModelFeatureDescriptor> OutputFeatures { get; }
var iVectorView = learningModel.outputFeatures;
Public ReadOnly Property OutputFeatures As IReadOnlyList(Of ILearningModelFeatureDescriptor)
属性值
模型的输出特征列表。
示例
以下示例加载模型,使用模型创建评估会话,并获取模型的输入和输出功能。
private async Task LoadModelAsync(string _modelFileName)
{
LearningModel _model;
LearningModelSession _session;
ImageFeatureDescriptor _inputImageDescription;
TensorFeatureDescriptor _outputImageDescription;
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);
//Get input and output features of the model
List<ILearningModelFeatureDescriptor> inputFeatures = _model.InputFeatures.ToList();
List<ILearningModelFeatureDescriptor> outputFeatures = _model.OutputFeatures.ToList();
// 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;
}
catch (Exception ex)
{
StatusBlock.Text = $"error: {ex.Message}";
_model = null;
}
}
注解
Windows Server
若要在 Windows Server 上使用此 API,必须使用具有桌面体验的 Windows Server 2019。
线程安全
此 API 是线程安全的。