ANN_MLP

Objective-C

@interface ANN_MLP : StatModel

Swift

class ANN_MLP : StatModel

Artificial Neural Networks - Multi-Layer Perceptrons.

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 ANN_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.

Additional flags for StatModel::train are available: ANN_MLP::TrainFlags.

See

REF: ml_intro_ann

Member of Ml

Methods

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

    Declaration

    Objective-C

    - (nonnull Mat *)getLayerSizes;

    Swift

    func getLayerSizes() -> Mat
  • Declaration

    Objective-C

    - (Mat*)getWeights:(int)layerIdx NS_SWIFT_NAME(getWeights(layerIdx:));

    Swift

    func getWeights(layerIdx: Int32) -> Mat
  • 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.
    

    Declaration

    Objective-C

    + (nonnull ANN_MLP *)create;

    Swift

    class func create() -> ANN_MLP
  • 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.

    Declaration

    Objective-C

    + (nonnull ANN_MLP *)load:(nonnull NSString *)filepath;

    Swift

    class func load(filepath: String) -> ANN_MLP

    Parameters

    filepath

    path to serialized ANN

  • Declaration

    Objective-C

    - (nonnull TermCriteria *)getTermCriteria;

    Swift

    func getTermCriteria() -> TermCriteria
  • Declaration

    Objective-C

    - (double)getAnnealCoolingRatio;

    Swift

    func getAnnealCoolingRatio() -> Double
  • Declaration

    Objective-C

    - (double)getAnnealFinalT;

    Swift

    func getAnnealFinalT() -> Double
  • Declaration

    Objective-C

    - (double)getAnnealInitialT;

    Swift

    func getAnnealInitialT() -> Double
  • Declaration

    Objective-C

    - (double)getBackpropMomentumScale;

    Swift

    func getBackpropMomentumScale() -> Double
  • Declaration

    Objective-C

    - (double)getBackpropWeightScale;

    Swift

    func getBackpropWeightScale() -> Double
  • Declaration

    Objective-C

    - (double)getRpropDW0;

    Swift

    func getRpropDW0() -> Double
  • Declaration

    Objective-C

    - (double)getRpropDWMax;

    Swift

    func getRpropDWMax() -> Double
  • Declaration

    Objective-C

    - (double)getRpropDWMin;

    Swift

    func getRpropDWMin() -> Double
  • Declaration

    Objective-C

    - (double)getRpropDWMinus;

    Swift

    func getRpropDWMinus() -> Double
  • Declaration

    Objective-C

    - (double)getRpropDWPlus;

    Swift

    func getRpropDWPlus() -> Double
  • Declaration

    Objective-C

    - (int)getAnnealItePerStep;

    Swift

    func getAnnealItePerStep() -> Int32
  • Returns current training method

    Declaration

    Objective-C

    - (int)getTrainMethod;

    Swift

    func getTrainMethod() -> Int32
  • Initialize the activation function for each neuron. Currently the default and the only fully supported activation function is ANN_MLP::SIGMOID_SYM.

    Declaration

    Objective-C

    - (void)setActivationFunction:(int)type
                           param1:(double)param1
                           param2:(double)param2;

    Swift

    func setActivationFunction(type: Int32, param1: Double, param2: Double)

    Parameters

    type

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

    param1

    The first parameter of the activation function,

    \alpha
    . Default value is 0.

    param2

    The second parameter of the activation function,

    \beta
    . 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.

    Declaration

    Objective-C

    - (void)setActivationFunction:(int)type param1:(double)param1;

    Swift

    func setActivationFunction(type: Int32, param1: Double)

    Parameters

    type

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

    param1

    The first parameter of the activation function,

    \alpha
    . 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.

    Declaration

    Objective-C

    - (void)setActivationFunction:(int)type;

    Swift

    func setActivationFunction(type: Int32)

    Parameters

    type

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

  • getAnnealCoolingRatio - see: -getAnnealCoolingRatio:

    Declaration

    Objective-C

    - (void)setAnnealCoolingRatio:(double)val;

    Swift

    func setAnnealCoolingRatio(val: Double)
  • getAnnealFinalT - see: -getAnnealFinalT:

    Declaration

    Objective-C

    - (void)setAnnealFinalT:(double)val;

    Swift

    func setAnnealFinalT(val: Double)
  • getAnnealInitialT - see: -getAnnealInitialT:

    Declaration

    Objective-C

    - (void)setAnnealInitialT:(double)val;

    Swift

    func setAnnealInitialT(val: Double)
  • getAnnealItePerStep - see: -getAnnealItePerStep:

    Declaration

    Objective-C

    - (void)setAnnealItePerStep:(int)val;

    Swift

    func setAnnealItePerStep(val: Int32)
  • getBackpropMomentumScale - see: -getBackpropMomentumScale:

    Declaration

    Objective-C

    - (void)setBackpropMomentumScale:(double)val;

    Swift

    func setBackpropMomentumScale(val: Double)
  • getBackpropWeightScale - see: -getBackpropWeightScale:

    Declaration

    Objective-C

    - (void)setBackpropWeightScale:(double)val;

    Swift

    func setBackpropWeightScale(val: Double)
  • 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.

    See

    -getLayerSizes:

    Declaration

    Objective-C

    - (void)setLayerSizes:(nonnull Mat *)_layer_sizes;

    Swift

    func setLayerSizes(_layer_sizes: Mat)
  • getRpropDW0 - see: -getRpropDW0:

    Declaration

    Objective-C

    - (void)setRpropDW0:(double)val;

    Swift

    func setRpropDW0(val: Double)
  • getRpropDWMax - see: -getRpropDWMax:

    Declaration

    Objective-C

    - (void)setRpropDWMax:(double)val;

    Swift

    func setRpropDWMax(val: Double)
  • getRpropDWMin - see: -getRpropDWMin:

    Declaration

    Objective-C

    - (void)setRpropDWMin:(double)val;

    Swift

    func setRpropDWMin(val: Double)
  • getRpropDWMinus - see: -getRpropDWMinus:

    Declaration

    Objective-C

    - (void)setRpropDWMinus:(double)val;

    Swift

    func setRpropDWMinus(val: Double)
  • getRpropDWPlus - see: -getRpropDWPlus:

    Declaration

    Objective-C

    - (void)setRpropDWPlus:(double)val;

    Swift

    func setRpropDWPlus(val: Double)
  • getTermCriteria - see: -getTermCriteria:

    Declaration

    Objective-C

    - (void)setTermCriteria:(nonnull TermCriteria *)val;

    Swift

    func setTermCriteria(val: TermCriteria)
  • Sets training method and common parameters.

    Declaration

    Objective-C

    - (void)setTrainMethod:(int)method param1:(double)param1 param2:(double)param2;

    Swift

    func setTrainMethod(method: Int32, param1: Double, param2: Double)

    Parameters

    method

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

    param1

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

    param2

    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.

    Declaration

    Objective-C

    - (void)setTrainMethod:(int)method param1:(double)param1;

    Swift

    func setTrainMethod(method: Int32, param1: Double)

    Parameters

    method

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

    param1

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

  • Sets training method and common parameters.

    Declaration

    Objective-C

    - (void)setTrainMethod:(int)method;

    Swift

    func setTrainMethod(method: Int32)

    Parameters

    method

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