F_VN_TrainBatchClusters

F_VN_TrainBatchClusters 1:

Train a clusterer with a batch of samples and return the IDs of the clusters the samples have been assigned to, if requested. On-line trainable clusterers are trained once with each sample. Depending on the application and the number of available training samples, repeated training of such models with the same data may improve the results.
Can use available TwinCAT Job Tasks for executing parallel code regions.

Syntax

Definition:

FUNCTION F_VN_TrainBatchClusters : HRESULT
VAR_INPUT
    ipClusterer : ITcVnMlModel;
    ipSamples   : ITcUnknown;
    ipClusters  : Reference To ITcVnContainer;
    hrPrev      : HRESULT;
END_VAR

F_VN_TrainBatchClusters 2: Inputs

Name

Type

Description

ipClusterer

ITcVnMlModel

Clusterer to be used

ipSamples

ITcUnknown

Container holding a batch of input samples (ContainerType_Vector_Vector_REAL or ContainerType_Vector_Vector_LREAL)

ipClusters

Reference To ITcVnContainer

Returns the IDs of the clusters the samples have been assigned to (ContainerType_Vector_DINT; optional, set to 0 if not required)

hrPrev

HRESULT

HRESULT indicating the result of previous operations (If SUCCEEDED(hrPrev) equals false, no operation is executed.)

F_VN_TrainBatchClusters 3: Return value

HRESULT

Further information

The function F_VN_TrainBatchClusters trains a Clusterer model with several samples. Compared to F_VN_TrainBatch, the assigned clusters can also be returned for each sample.

Parameter

Clusterer model

The previously created Clusterer model must be transferred to ipClusterer.

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.

Clusters

The IDs of the assigned clusters are returned in a container of the type ContainerType_Vector_DINT via the reference ipClusters.

Application

For example, a Clusterer model can be trained like this:

hr := F_VN_TrainBatchClusters(
    ipClusterer := ipClusterModel,
    ipSamples   := ipSamples,
    ipClusters  := ipClusters,
    hrPrev      := hr);

hr := F_VN_GetAt_DINT(ipClusters, nClusterOfThirdSample, 2, hr);

The call of F_VN_GetAt_DINT shows how the cluster assignment of the 3rd sample can be queried directly after training.

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