F_VN_PredictBatch
Compute predictions for a batch of samples.
Can use available TwinCAT Job Tasks for executing parallel code regions.
Syntax
Definition:
FUNCTION F_VN_PredictBatch : HRESULT
VAR_INPUT
ipMlModel : ITcVnMlModel;
ipSamples : ITcUnknown;
ipPredictions : Reference To ITcVnContainer;
hrPrev : HRESULT;
END_VAR
Inputs
Name |
Type |
Description |
---|---|---|
ipMlModel |
Classifier or regressor to be used | |
ipSamples |
Container holding a batch of input samples (ContainerType_Vector_Vector_REAL or ContainerType_Vector_Vector_LREAL) | |
ipPredictions |
Reference To ITcVnContainer |
Returns the predicted outputs (depending on ipSamples; class labels (for classification, ContainerType_Vector_DINT) or real-valued predictions (for regression with scalar output, ContainerType_Vector_REAL or ContainerType_Vector_LREAL; for regression with vectorial output, ContainerType_Vector_Vector_REAL or ContainerType_Vector_Vector_LREAL)) |
hrPrev |
HRESULT indicating the result of previous operations (If SUCCEEDED(hrPrev) equals false, no operation is executed.) |
Further information
The function F_VN_PredictBatch
calculates the prediction of a model for several samples. Depending on the type of model, the predictions have a different data type (see ipPredictions
).
Parameter
Model
For prediction, the previously trained model must be transferred to ipMlModel
.
Samples
The samples are transferred to ipSamples
in a container. The type of container must be ContainerType_Vector_Vector_REAL
or ContainerType_Vector_Vector_LREAL
.
Predictions
The predictions are returned in a container via the reference ipPredictions
. Depending on the type of model, the container has a different type:
- Class label for a classification:
ContainerType_Vector_DINT
- Numerical prediction values in a scalar regression:
ContainerType_Vector_REAL
orContainerType_Vector_LREAL,
depending onipSamples
- Numerical prediction values in a vector regression:
ContainerType_Vector_Vector_REAL
orContainerType_Vector_Vector_LREAL,
depending onipSamples
Expert parameters
The expert variant F_VN_PredictBatchExp contains additional parameters.
Application
For example, several samples can be classified at the same time:
hr := F_VN_PredictBatch(
ipMlModel := ipMlModel,
ipSamples := ipSamples,
ipPredictions := ipPredictions,
hrPrev := hr);
hr := F_VN_GetAt_DINT(ipPredictions, nClassOfThirdSample, 2, hr);
The call of F_VN_GetAt_DINT
shows how the class label of the 3rd sample can be get from the predictions.
Related functions
Required License
TC3 Vision Machine Learning
System Requirements
Development environment | Target platform | PLC libraries to include |
---|---|---|
TwinCAT V3.1.4024.54 or later | PC or CX (x64) with PL50, e.g. Intel 4-core Atom CPU | Tc3_Vision |