View Source Evision.ML.ANNMLP (Evision v0.1.7)

Link to this section Summary

cv

Clears the algorithm state

Returns the algorithm string identifier. This string is used as top level xml/yml node tag when the object is saved to a file or string.

Reads algorithm parameters from a file storage

Positional Arguments

Saves the algorithm to a file. In order to make this method work, the derived class must implement Algorithm::write(FileStorage& fs).

simplified API for language bindings

simplified API for language bindings

cv.ml

Computes error on the training or test dataset

Computes error on the training or test dataset

Creates empty model

Python prototype (for reference):

@see setAnnealCoolingRatio

@see setAnnealFinalT

@see setAnnealInitialT

@see setAnnealItePerStep

@see setBackpropMomentumScale

@see setBackpropWeightScale

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. @sa setLayerSizes

@see setRpropDW0

@see setRpropDWMax

@see setRpropDWMin

@see setRpropDWMinus

@see setRpropDWPlus

@see setTermCriteria

Returns current training method

Returns the number of variables in training samples

Positional Arguments
  • layerIdx: int

Python prototype (for reference):

Returns true if the model is classifier

Returns true if the model is trained

Loads and creates a serialized ANN from a file

Predicts response(s) for the provided sample(s)

Predicts response(s) for the provided sample(s)

Positional Arguments
  • type: int.

Positional Arguments
  • type: int.

Positional Arguments
  • val: double

@copybrief getAnnealCoolingRatio @see getAnnealCoolingRatio

Positional Arguments
  • val: double

@copybrief getAnnealFinalT @see getAnnealFinalT

Positional Arguments
  • val: double

@copybrief getAnnealInitialT @see getAnnealInitialT

Positional Arguments
  • val: int

@copybrief getAnnealItePerStep @see getAnnealItePerStep

Positional Arguments
  • val: double

@copybrief getBackpropMomentumScale @see getBackpropMomentumScale

Positional Arguments
  • val: double

@copybrief getBackpropWeightScale @see getBackpropWeightScale

Positional Arguments

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. @sa getLayerSizes

Positional Arguments
  • val: double

@copybrief getRpropDW0 @see getRpropDW0

Positional Arguments
  • val: double

@copybrief getRpropDWMax @see getRpropDWMax

Positional Arguments
  • val: double

@copybrief getRpropDWMin @see getRpropDWMin

Positional Arguments
  • val: double

@copybrief getRpropDWMinus @see getRpropDWMinus

Positional Arguments
  • val: double

@copybrief getRpropDWPlus @see getRpropDWPlus

Positional Arguments
  • val: TermCriteria

@copybrief getTermCriteria @see getTermCriteria

Positional Arguments
  • method: int.

Positional Arguments
  • method: int.

Trains the statistical model

Trains the statistical model

Trains the statistical model

Functions

Raising version of clear/1.

Raising version of create/0.

Raising version of empty/1.

Raising version of getRpropDW0/1.

Raising version of getVarCount/1.

Raising version of isClassifier/1.

Raising version of isTrained/1.

Raising version of load/1.

Raising version of predict/2.

Raising version of read/2.

Raising version of save/2.

Raising version of train/2.

Raising version of write/2.

Raising version of write/3.

Link to this section cv

Clears the algorithm state

Python prototype (for reference):

clear() -> None

Returns the algorithm string identifier. This string is used as top level xml/yml node tag when the object is saved to a file or string.

Python prototype (for reference):

getDefaultName() -> retval

Reads algorithm parameters from a file storage

Positional Arguments
  • fn_: FileNode

Python prototype (for reference):

read(fn_) -> None
Positional Arguments

Saves the algorithm to a file. In order to make this method work, the derived class must implement Algorithm::write(FileStorage& fs).

Python prototype (for reference):

save(filename) -> None

simplified API for language bindings

Positional Arguments
  • fs: Ptr<FileStorage>
Keyword Arguments

Has overloading in C++

Python prototype (for reference):

write(fs[, name]) -> None

simplified API for language bindings

Positional Arguments
  • fs: Ptr<FileStorage>
Keyword Arguments

Has overloading in C++

Python prototype (for reference):

write(fs[, name]) -> None

Link to this section cv.ml

Link to this function

calcError(self, data, test)

View Source

Computes error on the training or test dataset

Positional Arguments
  • data: Ptr<TrainData>.

    the training data

  • test: bool.

    if true, the error is computed over the test subset of the data, otherwise it's computed over the training subset of the data. Please note that if you loaded a completely different dataset to evaluate already trained classifier, you will probably want not to set the test subset at all with TrainData::setTrainTestSplitRatio and specify test=false, so that the error is computed for the whole new set. Yes, this sounds a bit confusing.

Return

The method uses StatModel::predict to compute the error. For regression models the error is computed as RMS, for classifiers - as a percent of missclassified samples (0%-100%).

Python prototype (for reference):

calcError(data, test[, resp]) -> retval, resp
Link to this function

calcError(self, data, test, opts)

View Source

Computes error on the training or test dataset

Positional Arguments
  • data: Ptr<TrainData>.

    the training data

  • test: bool.

    if true, the error is computed over the test subset of the data, otherwise it's computed over the training subset of the data. Please note that if you loaded a completely different dataset to evaluate already trained classifier, you will probably want not to set the test subset at all with TrainData::setTrainTestSplitRatio and specify test=false, so that the error is computed for the whole new set. Yes, this sounds a bit confusing.

Return

The method uses StatModel::predict to compute the error. For regression models the error is computed as RMS, for classifiers - as a percent of missclassified samples (0%-100%).

Python prototype (for reference):

calcError(data, test[, resp]) -> retval, resp

Creates empty model

Use StatModel::train to train the model, Algorithm::load\<ANN_MLP>(filename) to load the pre-trained model. Note that the train method has optional flags: ANN_MLP::TrainFlags.

Python prototype (for reference):

create() -> retval

Python prototype (for reference):

empty() -> retval
Link to this function

getAnnealCoolingRatio(self)

View Source

@see setAnnealCoolingRatio

Python prototype (for reference):

getAnnealCoolingRatio() -> retval

@see setAnnealFinalT

Python prototype (for reference):

getAnnealFinalT() -> retval

@see setAnnealInitialT

Python prototype (for reference):

getAnnealInitialT() -> retval
Link to this function

getAnnealItePerStep(self)

View Source

@see setAnnealItePerStep

Python prototype (for reference):

getAnnealItePerStep() -> retval
Link to this function

getBackpropMomentumScale(self)

View Source

@see setBackpropMomentumScale

Python prototype (for reference):

getBackpropMomentumScale() -> retval
Link to this function

getBackpropWeightScale(self)

View Source

@see setBackpropWeightScale

Python prototype (for reference):

getBackpropWeightScale() -> retval

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. @sa setLayerSizes

Python prototype (for reference):

getLayerSizes() -> retval

@see setRpropDW0

Python prototype (for reference):

getRpropDW0() -> retval

@see setRpropDWMax

Python prototype (for reference):

getRpropDWMax() -> retval

@see setRpropDWMin

Python prototype (for reference):

getRpropDWMin() -> retval

@see setRpropDWMinus

Python prototype (for reference):

getRpropDWMinus() -> retval

@see setRpropDWPlus

Python prototype (for reference):

getRpropDWPlus() -> retval

@see setTermCriteria

Python prototype (for reference):

getTermCriteria() -> retval

Returns current training method

Python prototype (for reference):

getTrainMethod() -> retval

Returns the number of variables in training samples

Python prototype (for reference):

getVarCount() -> retval
Link to this function

getWeights(self, layerIdx)

View Source
Positional Arguments
  • layerIdx: int

Python prototype (for reference):

getWeights(layerIdx) -> retval

Returns true if the model is classifier

Python prototype (for reference):

isClassifier() -> retval

Returns true if the model is trained

Python prototype (for reference):

isTrained() -> retval

Loads and creates a serialized ANN from a file

Positional Arguments
  • filepath: String.

    path to serialized ANN

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.

Python prototype (for reference):

load(filepath) -> retval

Predicts response(s) for the provided sample(s)

Positional Arguments
  • samples: Evision.Mat.

    The input samples, floating-point matrix

Keyword Arguments
  • flags: int.

    The optional flags, model-dependent. See cv::ml::StatModel::Flags.

Return
  • results: Evision.Mat.

    The optional output matrix of results.

Python prototype (for reference):

predict(samples[, results[, flags]]) -> retval, results
Link to this function

predict(self, samples, opts)

View Source

Predicts response(s) for the provided sample(s)

Positional Arguments
  • samples: Evision.Mat.

    The input samples, floating-point matrix

Keyword Arguments
  • flags: int.

    The optional flags, model-dependent. See cv::ml::StatModel::Flags.

Return
  • results: Evision.Mat.

    The optional output matrix of results.

Python prototype (for reference):

predict(samples[, results[, flags]]) -> retval, results
Link to this function

setActivationFunction(self, type)

View Source
Positional Arguments
  • type: int.

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

Keyword Arguments
  • 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.

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

Python prototype (for reference):

setActivationFunction(type[, param1[, param2]]) -> None
Link to this function

setActivationFunction(self, type, opts)

View Source
Positional Arguments
  • type: int.

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

Keyword Arguments
  • 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.

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

Python prototype (for reference):

setActivationFunction(type[, param1[, param2]]) -> None
Link to this function

setAnnealCoolingRatio(self, val)

View Source
Positional Arguments
  • val: double

@copybrief getAnnealCoolingRatio @see getAnnealCoolingRatio

Python prototype (for reference):

setAnnealCoolingRatio(val) -> None
Link to this function

setAnnealFinalT(self, val)

View Source
Positional Arguments
  • val: double

@copybrief getAnnealFinalT @see getAnnealFinalT

Python prototype (for reference):

setAnnealFinalT(val) -> None
Link to this function

setAnnealInitialT(self, val)

View Source
Positional Arguments
  • val: double

@copybrief getAnnealInitialT @see getAnnealInitialT

Python prototype (for reference):

setAnnealInitialT(val) -> None
Link to this function

setAnnealItePerStep(self, val)

View Source
Positional Arguments
  • val: int

@copybrief getAnnealItePerStep @see getAnnealItePerStep

Python prototype (for reference):

setAnnealItePerStep(val) -> None
Link to this function

setBackpropMomentumScale(self, val)

View Source
Positional Arguments
  • val: double

@copybrief getBackpropMomentumScale @see getBackpropMomentumScale

Python prototype (for reference):

setBackpropMomentumScale(val) -> None
Link to this function

setBackpropWeightScale(self, val)

View Source
Positional Arguments
  • val: double

@copybrief getBackpropWeightScale @see getBackpropWeightScale

Python prototype (for reference):

setBackpropWeightScale(val) -> None
Link to this function

setLayerSizes(self, layer_sizes)

View Source
Positional Arguments

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. @sa getLayerSizes

Python prototype (for reference):

setLayerSizes(_layer_sizes) -> None
Positional Arguments
  • val: double

@copybrief getRpropDW0 @see getRpropDW0

Python prototype (for reference):

setRpropDW0(val) -> None
Link to this function

setRpropDWMax(self, val)

View Source
Positional Arguments
  • val: double

@copybrief getRpropDWMax @see getRpropDWMax

Python prototype (for reference):

setRpropDWMax(val) -> None
Link to this function

setRpropDWMin(self, val)

View Source
Positional Arguments
  • val: double

@copybrief getRpropDWMin @see getRpropDWMin

Python prototype (for reference):

setRpropDWMin(val) -> None
Link to this function

setRpropDWMinus(self, val)

View Source
Positional Arguments
  • val: double

@copybrief getRpropDWMinus @see getRpropDWMinus

Python prototype (for reference):

setRpropDWMinus(val) -> None
Link to this function

setRpropDWPlus(self, val)

View Source
Positional Arguments
  • val: double

@copybrief getRpropDWPlus @see getRpropDWPlus

Python prototype (for reference):

setRpropDWPlus(val) -> None
Link to this function

setTermCriteria(self, val)

View Source
Positional Arguments
  • val: TermCriteria

@copybrief getTermCriteria @see getTermCriteria

Python prototype (for reference):

setTermCriteria(val) -> None
Link to this function

setTrainMethod(self, method)

View Source
Positional Arguments
  • method: int.

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

Keyword Arguments
  • 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.

Sets training method and common parameters.

Python prototype (for reference):

setTrainMethod(method[, param1[, param2]]) -> None
Link to this function

setTrainMethod(self, method, opts)

View Source
Positional Arguments
  • method: int.

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

Keyword Arguments
  • 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.

Sets training method and common parameters.

Python prototype (for reference):

setTrainMethod(method[, param1[, param2]]) -> None

Trains the statistical model

Positional Arguments
  • trainData: Ptr<TrainData>.

    training data that can be loaded from file using TrainData::loadFromCSV or created with TrainData::create.

Keyword Arguments
  • flags: int.

    optional flags, depending on the model. Some of the models can be updated with the new training samples, not completely overwritten (such as NormalBayesClassifier or ANN_MLP).

Python prototype (for reference):

train(trainData[, flags]) -> retval
Link to this function

train(self, trainData, opts)

View Source

Trains the statistical model

Positional Arguments
  • trainData: Ptr<TrainData>.

    training data that can be loaded from file using TrainData::loadFromCSV or created with TrainData::create.

Keyword Arguments
  • flags: int.

    optional flags, depending on the model. Some of the models can be updated with the new training samples, not completely overwritten (such as NormalBayesClassifier or ANN_MLP).

Python prototype (for reference):

train(trainData[, flags]) -> retval
Link to this function

train(self, samples, layout, responses)

View Source

Trains the statistical model

Positional Arguments
  • samples: Evision.Mat.

    training samples

  • layout: int.

    See ml::SampleTypes.

  • responses: Evision.Mat.

    vector of responses associated with the training samples.

Python prototype (for reference):

train(samples, layout, responses) -> retval

Link to this section Functions

Link to this function

calcError!(self, data, test)

View Source

Raising version of calcError/3.

Link to this function

calcError!(self, data, test, opts)

View Source

Raising version of calcError/4.

Raising version of clear/1.

Raising version of create/0.

Raising version of empty/1.

Link to this function

getAnnealCoolingRatio!(self)

View Source

Raising version of getAnnealCoolingRatio/1.

Raising version of getAnnealFinalT/1.

Link to this function

getAnnealInitialT!(self)

View Source

Raising version of getAnnealInitialT/1.

Link to this function

getAnnealItePerStep!(self)

View Source

Raising version of getAnnealItePerStep/1.

Link to this function

getBackpropMomentumScale!(self)

View Source

Raising version of getBackpropMomentumScale/1.

Link to this function

getBackpropWeightScale!(self)

View Source

Raising version of getBackpropWeightScale/1.

Raising version of getDefaultName/1.

Raising version of getLayerSizes/1.

Raising version of getRpropDW0/1.

Raising version of getRpropDWMax/1.

Raising version of getRpropDWMin/1.

Raising version of getRpropDWMinus/1.

Raising version of getRpropDWPlus/1.

Raising version of getTermCriteria/1.

Raising version of getTrainMethod/1.

Raising version of getVarCount/1.

Link to this function

getWeights!(self, layerIdx)

View Source

Raising version of getWeights/2.

Raising version of isClassifier/1.

Raising version of isTrained/1.

Raising version of load/1.

Raising version of predict/2.

Link to this function

predict!(self, samples, opts)

View Source

Raising version of predict/3.

Raising version of read/2.

Raising version of save/2.

Link to this function

setActivationFunction!(self, type)

View Source

Raising version of setActivationFunction/2.

Link to this function

setActivationFunction!(self, type, opts)

View Source

Raising version of setActivationFunction/3.

Link to this function

setAnnealCoolingRatio!(self, val)

View Source

Raising version of setAnnealCoolingRatio/2.

Link to this function

setAnnealFinalT!(self, val)

View Source

Raising version of setAnnealFinalT/2.

Link to this function

setAnnealInitialT!(self, val)

View Source

Raising version of setAnnealInitialT/2.

Link to this function

setAnnealItePerStep!(self, val)

View Source

Raising version of setAnnealItePerStep/2.

Link to this function

setBackpropMomentumScale!(self, val)

View Source

Raising version of setBackpropMomentumScale/2.

Link to this function

setBackpropWeightScale!(self, val)

View Source

Raising version of setBackpropWeightScale/2.

Link to this function

setLayerSizes!(self, layer_sizes)

View Source

Raising version of setLayerSizes/2.

Raising version of setRpropDW0/2.

Link to this function

setRpropDWMax!(self, val)

View Source

Raising version of setRpropDWMax/2.

Link to this function

setRpropDWMin!(self, val)

View Source

Raising version of setRpropDWMin/2.

Link to this function

setRpropDWMinus!(self, val)

View Source

Raising version of setRpropDWMinus/2.

Link to this function

setRpropDWPlus!(self, val)

View Source

Raising version of setRpropDWPlus/2.

Link to this function

setTermCriteria!(self, val)

View Source

Raising version of setTermCriteria/2.

Link to this function

setTrainMethod!(self, method)

View Source

Raising version of setTrainMethod/2.

Link to this function

setTrainMethod!(self, method, opts)

View Source

Raising version of setTrainMethod/3.

Raising version of train/2.

Link to this function

train!(self, trainData, opts)

View Source

Raising version of train/3.

Link to this function

train!(self, samples, layout, responses)

View Source

Raising version of train/4.

Raising version of write/2.

Raising version of write/3.