OpenCV 2.4.3.2

org.opencv.ml
Class CvANN_MLP

java.lang.Object
  extended by org.opencv.ml.CvStatModel
      extended by org.opencv.ml.CvANN_MLP

public class CvANN_MLP
extends CvStatModel

MLP model.

Unlike many other models in ML that are constructed and trained at once, in the MLP model these steps are separated. First, a network with the specified topology is created using the non-default constructor or the method "CvANN_MLP.create". All the weights are set to zeros. Then, the network is trained using a set of input and output vectors. The training procedure can be repeated more than once, that is, the weights can be adjusted based on the new training data.

See Also:
org.opencv.ml.CvANN_MLP : public CvStatModel

Field Summary
static int GAUSSIAN
           
static int IDENTITY
           
static int NO_INPUT_SCALE
           
static int NO_OUTPUT_SCALE
           
static int SIGMOID_SYM
           
static int UPDATE_WEIGHTS
           
 
Constructor Summary
CvANN_MLP()
          The constructors.
CvANN_MLP(Mat layerSizes)
          The constructors.
CvANN_MLP(Mat layerSizes, int activateFunc, double fparam1, double fparam2)
          The constructors.
 
Method Summary
 void clear()
           
 void create(Mat layerSizes)
          Constructs MLP with the specified topology.
 void create(Mat layerSizes, int activateFunc, double fparam1, double fparam2)
          Constructs MLP with the specified topology.
 float predict(Mat inputs, Mat outputs)
          Predicts responses for input samples.
 int train(Mat inputs, Mat outputs, Mat sampleWeights)
          Trains/updates MLP.
 int train(Mat inputs, Mat outputs, Mat sampleWeights, Mat sampleIdx, CvANN_MLP_TrainParams params, int flags)
          Trains/updates MLP.
 
Methods inherited from class org.opencv.ml.CvStatModel
load, load, save, save
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

GAUSSIAN

public static final int GAUSSIAN
See Also:
Constant Field Values

IDENTITY

public static final int IDENTITY
See Also:
Constant Field Values

NO_INPUT_SCALE

public static final int NO_INPUT_SCALE
See Also:
Constant Field Values

NO_OUTPUT_SCALE

public static final int NO_OUTPUT_SCALE
See Also:
Constant Field Values

SIGMOID_SYM

public static final int SIGMOID_SYM
See Also:
Constant Field Values

UPDATE_WEIGHTS

public static final int UPDATE_WEIGHTS
See Also:
Constant Field Values
Constructor Detail

CvANN_MLP

public CvANN_MLP()

The constructors.

The advanced constructor allows to create MLP with the specified topology. See "CvANN_MLP.create" for details.

See Also:
org.opencv.ml.CvANN_MLP.CvANN_MLP

CvANN_MLP

public CvANN_MLP(Mat layerSizes)

The constructors.

The advanced constructor allows to create MLP with the specified topology. See "CvANN_MLP.create" for details.

Parameters:
layerSizes - a layerSizes
See Also:
org.opencv.ml.CvANN_MLP.CvANN_MLP

CvANN_MLP

public CvANN_MLP(Mat layerSizes,
                 int activateFunc,
                 double fparam1,
                 double fparam2)

The constructors.

The advanced constructor allows to create MLP with the specified topology. See "CvANN_MLP.create" for details.

Parameters:
layerSizes - a layerSizes
activateFunc - a activateFunc
fparam1 - a fparam1
fparam2 - a fparam2
See Also:
org.opencv.ml.CvANN_MLP.CvANN_MLP
Method Detail

clear

public void clear()

create

public void create(Mat layerSizes)

Constructs MLP with the specified topology.

The method creates an MLP network with the specified topology and assigns the same activation function to all the neurons.

Parameters:
layerSizes - Integer vector specifying the number of neurons in each layer including the input and output layers.
See Also:
org.opencv.ml.CvANN_MLP.create

create

public void create(Mat layerSizes,
                   int activateFunc,
                   double fparam1,
                   double fparam2)

Constructs MLP with the specified topology.

The method creates an MLP network with the specified topology and assigns the same activation function to all the neurons.

Parameters:
layerSizes - Integer vector specifying the number of neurons in each layer including the input and output layers.
activateFunc - Parameter specifying the activation function for each neuron: one of CvANN_MLP.IDENTITY, CvANN_MLP.SIGMOID_SYM, and CvANN_MLP.GAUSSIAN.
fparam1 - Free parameter of the activation function, alpha. See the formulas in the introduction section.
fparam2 - Free parameter of the activation function, beta. See the formulas in the introduction section.
See Also:
org.opencv.ml.CvANN_MLP.create

predict

public float predict(Mat inputs,
                     Mat outputs)

Predicts responses for input samples.

The method returns a dummy value which should be ignored.

Parameters:
inputs - Input samples.
outputs - Predicted responses for corresponding samples.
See Also:
org.opencv.ml.CvANN_MLP.predict

train

public int train(Mat inputs,
                 Mat outputs,
                 Mat sampleWeights)

Trains/updates MLP.

This method applies the specified training algorithm to computing/adjusting the network weights. It returns the number of done iterations.

The RPROP training algorithm is parallelized with the TBB library.

Parameters:
inputs - Floating-point matrix of input vectors, one vector per row.
outputs - Floating-point matrix of the corresponding output vectors, one vector per row.
sampleWeights - (RPROP only) Optional floating-point vector of weights for each sample. Some samples may be more important than others for training. You may want to raise the weight of certain classes to find the right balance between hit-rate and false-alarm rate, and so on.
See Also:
org.opencv.ml.CvANN_MLP.train

train

public int train(Mat inputs,
                 Mat outputs,
                 Mat sampleWeights,
                 Mat sampleIdx,
                 CvANN_MLP_TrainParams params,
                 int flags)

Trains/updates MLP.

This method applies the specified training algorithm to computing/adjusting the network weights. It returns the number of done iterations.

The RPROP training algorithm is parallelized with the TBB library.

Parameters:
inputs - Floating-point matrix of input vectors, one vector per row.
outputs - Floating-point matrix of the corresponding output vectors, one vector per row.
sampleWeights - (RPROP only) Optional floating-point vector of weights for each sample. Some samples may be more important than others for training. You may want to raise the weight of certain classes to find the right balance between hit-rate and false-alarm rate, and so on.
sampleIdx - Optional integer vector indicating the samples (rows of inputs and outputs) that are taken into account.
params - Training parameters. See the "CvANN_MLP_TrainParams" description.
flags - Various parameters to control the training algorithm. A combination of the following parameters is possible:
  • UPDATE_WEIGHTS Algorithm updates the network weights, rather than computes them from scratch. In the latter case the weights are initialized using the Nguyen-Widrow algorithm.
  • NO_INPUT_SCALE Algorithm does not normalize the input vectors. If this flag is not set, the training algorithm normalizes each input feature independently, shifting its mean value to 0 and making the standard deviation equal to 1. If the network is assumed to be updated frequently, the new training data could be much different from original one. In this case, you should take care of proper normalization.
  • NO_OUTPUT_SCALE Algorithm does not normalize the output vectors. If the flag is not set, the training algorithm normalizes each output feature independently, by transforming it to the certain range depending on the used activation function.
See Also:
org.opencv.ml.CvANN_MLP.train

OpenCV 2.4.3.2 Documentation