ANN_MLP class

Artificial Neural Networks - Multi-Layer Perceptrons. https://docs.opencv.org/4.x/d0/dce/classcv_1_1ml_1_1ANN__MLP.html

Inheritance
Available extensions

Constructors

ANN_MLP.create()
Creates an empty model. Use one of the train methods to train it, or ANN_MLP.load.
factory
ANN_MLP.fromPointer(ANN_MLPPtr ptr, [bool attach = true])
factory
ANN_MLP.load(String filepath)
Loads a model saved with save from filepath. Throws CvException when the file does not hold a valid model.
factory
ANN_MLP.loadFromString(String strModel, {String objname = ''})
Loads a model from the content of a file saved with save (e.g. a Flutter asset).
factory

Properties

annealCoolingRatio ↔ double
ANNEAL: cooling ratio.
getter/setter pair
annealFinalT ↔ double
ANNEAL: final temperature.
getter/setter pair
annealInitialT ↔ double
ANNEAL: initial temperature.
getter/setter pair
annealItePerStep ↔ int
ANNEAL: iteration per step.
getter/setter pair
backpropMomentumScale ↔ double
BPROP: strength of the momentum term.
getter/setter pair
backpropWeightScale ↔ double
BPROP: strength of the weight gradient term.
getter/setter pair
defaultName → String
The name used when saving the model, opencv_ml_ann_mlp.
no setter
hashCode → int
The hash code for this object.
no setterinherited
isClassifier → bool
Whether the model is a classifier (false for a regressor).
no setter
isDisposed → bool
Whether this object has been disposed.
no setterinherited
isEmpty → bool
no setter
isTrained → bool
no setter
layerSizes ↔ Mat
Integer vector specifying the number of neurons in each layer including the input and output layers.
getter/setter pair
props → List<Object?>
no setterinherited
ptr ↔ Pointer<ANN_MLP>
getter/setter pairinherited
ref → ANN_MLP
A view of the native memory behind ptr, not a copy.
no setteroverride
rpropDW0 ↔ double
RPROP: initial value of update-values.
getter/setter pair
rpropDWMax ↔ double
RPROP: update-values upper limit.
getter/setter pair
rpropDWMin ↔ double
RPROP: update-values lower limit.
getter/setter pair
rpropDWMinus ↔ double
RPROP: decrease factor.
getter/setter pair
rpropDWPlus ↔ double
RPROP: increase factor.
getter/setter pair
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
termCriteria ↔ TermCriteria
Termination criteria of the training algorithm.
getter/setter pair
trainMethod → int
The current training method.
no setter
varCount → int
Number of variables in training samples.
no setter

Methods

calcError(TrainData data, bool test) → (double, Mat)
Computes the error on the training (test false) or test (test true) part of data.
calcErrorAsync(TrainData data, bool test) → Future<(double, Mat)>

Available on ANN_MLP, provided by the ANN_MLPAsync extension

clear() → void
Clears the model, it becomes untrained.
dispose() → void
Releases the underlying native resources. Idempotent: calling it more than once is safe, but the object must not be used after dispose.
inherited
freeNative() → void
Frees the native resources owned by this object. Subclasses implement the concrete free logic here; callers must use dispose instead.
override
getWeights(int layerIdx) → Mat
Weights of the network: index 0 holds the input scale, 1 to layerSizes.total - 1 the weights between consecutive layers, the next index the output scale and the last one its inverse.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
predict(Mat samples, {int flags = 0}) → Mat
Predicts the response for each row of samples, one row of the returned Mat per sample.
predictAsync(Mat samples, {int flags = 0}) → Future<Mat>

Available on ANN_MLP, provided by the ANN_MLPAsync extension

save(String filename) → void
Saves the model to filename (.xml, .yml or .json).
setActivationFunction(int type, {double param1 = 0, double param2 = 0}) → void
Initializes the activation function for each neuron, one of IDENTITY, SIGMOID_SYM, GAUSSIAN, RELU, LEAKYRELU.
setTrainMethod(int method, {double param1 = 0, double param2 = 0}) → void
Sets the training method, one of BACKPROP, RPROP, ANNEAL, and its common parameters.
toString() → String
A string representation of this object.
inherited
train(Mat samples, int layout, Mat responses) → bool
Trains the model on samples (CV_32F, one sample per row for ROW_SAMPLE).
trainAsync(Mat samples, int layout, Mat responses) → Future<bool>

Available on ANN_MLP, provided by the ANN_MLPAsync extension

trainWithData(TrainData data, {int flags = 0}) → bool
Trains the model on data, flags may be StatModel.UPDATE_MODEL or model-specific flags.
trainWithDataAsync(TrainData data, {int flags = 0}) → Future<bool>

Available on ANN_MLP, provided by the ANN_MLPAsync extension

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Properties

finalizer → NativeFinalizer
final

Constants

ANNEAL → const int
BACKPROP → const int
GAUSSIAN → const int
IDENTITY → const int
LEAKYRELU → const int
NO_INPUT_SCALE → const int
NO_OUTPUT_SCALE → const int
RELU → const int
RPROP → const int
SIGMOID_SYM → const int
UPDATE_WEIGHTS → const int