Table of Contents

Class ANN_MLP

Namespace
OpenCvSharp.ML
Assembly
OpenCvSharp.dll

Artificial Neural Networks - Multi-Layer Perceptrons.

public class ANN_MLP : StatModel, IDisposable, ICvPtrHolder
Inheritance
ANN_MLP
Implements
Inherited Members

Constructors

ANN_MLP(nint)

Creates instance by raw pointer cv::ml::ANN_MLP*

protected ANN_MLP(nint p)

Parameters

p nint

Properties

BackpropMomentumScale

Strength of the momentum term (the difference between weights on the 2 previous iterations). This parameter provides some inertia to smooth the random fluctuations of the weights. It can vary from 0 (the feature is disabled) to 1 and beyond. The value 0.1 or so is good enough. Default value is 0.1.

public double BackpropMomentumScale { get; set; }

Property Value

double

BackpropWeightScale

Strength of the weight gradient term. The recommended value is about 0.1. Default value is 0.1.

public double BackpropWeightScale { get; set; }

Property Value

double

RpropDW0

Initial value Delta_0 of update-values Delta_{ij}. Default value is 0.1.

public double RpropDW0 { get; set; }

Property Value

double

RpropDWMax

Update-values upper limit Delta_{max}. It must be >1. Default value is 50.

public double RpropDWMax { get; set; }

Property Value

double

RpropDWMin

Update-values lower limit Delta_{min}. It must be positive. Default value is FLT_EPSILON.

public double RpropDWMin { get; set; }

Property Value

double

RpropDWMinus

Decrease factor eta^-. It must be >1. Default value is 0.5.

public double RpropDWMinus { get; set; }

Property Value

double

RpropDWPlus

Increase factor eta^+. It must be >1. Default value is 1.2.

public double RpropDWPlus { get; set; }

Property Value

double

TermCriteria

Termination criteria of the training algorithm.

public TermCriteria TermCriteria { get; set; }

Property Value

TermCriteria

Methods

Create()

Creates the empty model.

public static ANN_MLP Create()

Returns

ANN_MLP

DisposeManaged()

Releases managed resources

protected override void DisposeManaged()

GetLayerSizes()

Integer vector specifying the number of neurons in each layer including the input and output layers. The very first element specifies the number of elements in the input layer. The last element - number of elements in the output layer.

public virtual Mat GetLayerSizes()

Returns

Mat

GetTrainMethod()

Returns current training method

public virtual ANN_MLP.TrainingMethods GetTrainMethod()

Returns

ANN_MLP.TrainingMethods

Load(string)

Loads and creates a serialized ANN from a file. Use ANN::save to serialize and store an ANN to disk. Load the ANN from this file again, by calling this function with the path to the file.

public static ANN_MLP Load(string filePath)

Parameters

filePath string

path to serialized ANN

Returns

ANN_MLP

LoadFromString(string)

Loads algorithm from a String.

public static ANN_MLP LoadFromString(string strModel)

Parameters

strModel string

he string variable containing the model you want to load.

Returns

ANN_MLP

SetActivationFunction(ActivationFunctions, double, double)

Initialize the activation function for each neuron. Currently the default and the only fully supported activation function is ANN_MLP::SIGMOID_SYM.

public virtual void SetActivationFunction(ANN_MLP.ActivationFunctions type, double param1 = 0, double param2 = 0)

Parameters

type ANN_MLP.ActivationFunctions

The type of activation function. See ANN_MLP::ActivationFunctions.

param1 double

The first parameter of the activation function, \f$\alpha\f$. Default value is 0.

param2 double

The second parameter of the activation function, \f$\beta\f$. Default value is 0.

SetLayerSizes(InputArray)

Integer vector specifying the number of neurons in each layer including the input and output layers. The very first element specifies the number of elements in the input layer. The last element - number of elements in the output layer.Default value is empty Mat.

public virtual void SetLayerSizes(InputArray layerSizes)

Parameters

layerSizes InputArray

SetTrainMethod(TrainingMethods, double, double)

Sets training method and common parameters.

public virtual void SetTrainMethod(ANN_MLP.TrainingMethods method, double param1 = 0, double param2 = 0)

Parameters

method ANN_MLP.TrainingMethods

Default value is ANN_MLP::RPROP. See ANN_MLP::TrainingMethods.

param1 double

passed to setRpropDW0 for ANN_MLP::RPROP and to setBackpropWeightScale for ANN_MLP::BACKPROP and to initialT for ANN_MLP::ANNEAL.

param2 double

passed to setRpropDWMin for ANN_MLP::RPROP and to setBackpropMomentumScale for ANN_MLP::BACKPROP and to finalT for ANN_MLP::ANNEAL.