F_VN_CreateSvmSgdClassifierExp

F_VN_CreateSvmSgdClassifierExp 1:

Create a linear SVM classifier using stochastic gradient descent for training. The initial reference count is set to one if a new model is created and kept, otherwise. This SVM classifier is only applicable to binary classification problems. It learns a separating hyperplane between a class with label -1 and a class with label 1. These class labels are predefined. For training, any positive class labels are mapped to 1 and any negative class labels are mapped to -1. Models of this type neither support on-line training (sample by sample) nor retraining. (expert function)

Syntax

Definition:

FUNCTION F_VN_CreateSvmSgdClassifierExp : HRESULT
VAR_INPUT
    ipMlModel             : Reference To ITcVnMlModel;
    eType                 : ETcVnSvmSgdClassifierType;
    eMarginType           : ETcVnSvmSgdClassifierMarginType;
    fMarginRegularization : REAL;
    fInitialStepSize      : REAL;
    fStepDecreasingPower  : REAL;
    nMaxIterations        : UDINT;
    fEpsilon              : LREAL;
    hrPrev                : HRESULT;
END_VAR

F_VN_CreateSvmSgdClassifierExp 2: Inputs

Name

Type

Description

ipMlModel

Reference To ITcVnMlModel

Returns the created model (Non-zero interface pointers are reused.)

eType

ETcVnSvmSgdClassifierType

Learning algorithm type (default: TCVN_SSCT_ASGD)

eMarginType

ETcVnSvmSgdClassifierMarginType

Margin type (default: TCVN_SSCMT_SOFT_MARGIN)

fMarginRegularization

REAL

Margin regularization parameter (default: 0.00001)

fInitialStepSize

REAL

Initial step size (default: 0.05)

fStepDecreasingPower

REAL

Power parameter (default: 0.75)

nMaxIterations

UDINT

Maximum number of iterations (disabled if it equals 0 and fEpsilon is different from 0.0; triggers the usage of the default value of 100000 if nMaxIterations and fEpsilon equal 0)

fEpsilon

LREAL

Maximum allowed difference of the error between two successive iterations (disabled if it equals 0.0 and nMaxIterations is different from 0; triggers the usage of the default value of 0.00001 if nMaxIterations and fEpsilon equal 0)

hrPrev

HRESULT

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

F_VN_CreateSvmSgdClassifierExp 3: Return value

HRESULT

Weiterführende Informationen

Die Funktion F_VN_CreateSvmSgdClassifierExp ist eine Expert-Variante von F_VN_CreateSvmSgdClassifier. Sie enthält zusätzliche Parameter.

Parameter

Modell

In dem Interface Pointer ipMlModel wird das erstellte Modell zurückgegeben.

Algorithmus

eType legt fest welches Optimierungsverfahren im Training verwendet wird:

Abgrenzung der Klassen

eMarginType legt fest, ob die Abgrenzung der Klassen strikt (TCVN_SSCMT_HARD_MARGIN) oder mit Ausreißern durchgeführt (TCVN_SSCMT_SOFT_MARGIN) werden soll.

Regularisierung

fMarginRegularization ist dafür verantwortlich, dass die Gewichte bei jedem Schritt abnehmen und steuert, wie stark der Einfluss von Ausreißern beschränkt wird. Je kleiner der Parameter, desto geringer die Wahrscheinlichkeit, dass ein Ausreißer ignoriert wird.

Schrittweite

fInitialStepSize gibt die Schrittweite zu Beginn des Trainings an.

Abnahme der Schrittweite

fStepDecreasingPower gibt den Exponenten für die Reduzierung der Schrittweite an.

Maximale Iterationen

Für die Optimierung werden maximal so viele Iterationen genutzt, wie in nMaxIterations angegeben sind. Wenn der Wert 0 ist, wird der jeweilige Default-Wert verwendet.

Abbruchgrenze

Die Optimierung wird abgebrochen, sobald sich der Fehler zwischen zwei Iterationen nicht stärker verändert, als in fEpsilon angegeben ist. Wenn der Wert 0 ist, wird der jeweilige Default-Wert verwendet.

Anwendung

Ein SVM-SGD-Modell zur Klassifikation kann z.B. so erstellt werden:

hr := F_VN_CreateSvmSgdClassifierExp(
    ipMlModel               := ipMlModel,
    eType                   := TCVN_SSCT_ASGD,
    eMarginType             := TCVN_SSCMT_SOFT_MARGIN,
    fMarginRegularization   := 0.00001,
    fInitialStepSize        := 0.05,
    fStepDecreasingPower    := 0.75,
    nMaxIterations          := 0,
    fEpsilon                := 0,
    hrPrev                  := hr);

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