LearningModel.InputFeatures Property
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
A list of the model's input features.
public:
property IVectorView<ILearningModelFeatureDescriptor ^> ^ InputFeatures { IVectorView<ILearningModelFeatureDescriptor ^> ^ get(); };
IVectorView<ILearningModelFeatureDescriptor> InputFeatures();
public IReadOnlyList<ILearningModelFeatureDescriptor> InputFeatures { get; }
var iVectorView = learningModel.inputFeatures;
Public ReadOnly Property InputFeatures As IReadOnlyList(Of ILearningModelFeatureDescriptor)
Property Value
A list of the model's input features.
Examples
The following example loads a model from a local file, creates a session from the model, and gets the input and output features of the model.
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;
}
}
Remarks
Windows Server
To use this API on Windows Server, you must use Windows Server 2019 with Desktop Experience.
Thread safety
This API is thread-safe.