Y. LeCun, L. Bottou, G.B. Orr and K.-R. Muller, *Efficient backprop*, in Neural Networks---Tricks of the Trade, Springer Lecture Notes in Computer Sciences 1524, pp.5-50, 1998.
.. _RPROP93:
*
M. Riedmiller and H. Braun, *A Direct Adaptive Method for Faster Backpropagation Learning: The RPROP Algorithm*, Proc. ICNN, San Francisco (1993).
[RPROP93] M. Riedmiller and H. Braun, *A Direct Adaptive Method for Faster Backpropagation Learning: The RPROP Algorithm*, Proc. ICNN, San Francisco (1993).
CvANN_MLP_TrainParams
---------------------
.. ocv:class:: CvANN_MLP_TrainParams
Parameters of the MLP training algorithm. ::
Parameters of the MLP training algorithm. You can initialize the structure by a constructor or the individual parameters can be adjusted after the structure is created.
struct CvANN_MLP_TrainParams
{
CvANN_MLP_TrainParams();
CvANN_MLP_TrainParams( CvTermCriteria term_crit, int train_method,
The RPROP algorithm parameters (see :ref:`[RPROP93] <RPROP93>` for details):
.. ocv:member:: double rp_dw0
The structure has a default constructor that initializes parameters for the ``RPROP`` algorithm. There is also a more advanced constructor to customize the parameters and/or choose the back-propagation algorithm. Finally, the individual parameters can be adjusted after the structure is created.
Initial value :math:`\Delta_0` of update-values :math:`\Delta_{ij}`.
CvANN_MLP
---------
.. ocv:class:: CvANN_MLP
.. ocv:member:: double rp_dw_plus
MLP model. ::
Increase factor :math:`\eta^+`.
class CvANN_MLP : public CvStatModel
{
public:
CvANN_MLP();
CvANN_MLP( const Mat& _layer_sizes,
int _activ_func=SIGMOID_SYM,
double _f_param1=0, double _f_param2=0 );
.. ocv:member:: double rp_dw_minus
Decrease factor :math:`\eta^-`.
.. ocv:member:: double rp_dw_min
Update-values lower limit :math:`\Delta_{min}`.
virtual ~CvANN_MLP();
.. ocv:member:: double rp_dw_max
virtual void create( const Mat& _layer_sizes,
int _activ_func=SIGMOID_SYM,
double _f_param1=0, double _f_param2=0 );
Update-values upper limit :math:`\Delta_{max}`.
virtual int train( const Mat& _inputs, const Mat& _outputs,
virtual void write( CvFileStorage* storage, const char* name );
:param term_crit: Termination criteria of the training algorithm. You can specify the maximum number of iterations (``max_iter``) and/or tolerance on the error change (``epsilon``).
int get_layer_count() { return layer_sizes ? layer_sizes->cols : 0; }
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 :ocv:func:`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.
Mat& layer_sizes;
Mat& wbuf;
Mat& sample_weights;
double** weights;
double f_param1, f_param2;
double min_val, max_val, min_val1, max_val1;
int activ_func;
int max_count, max_buf_sz;
CvANN_MLP_TrainParams params;
CvRNG rng;
};
CvANN_MLP::CvANN_MLP
--------------------
The constructors.
.. ocv:function:: CvANN_MLP::CvANN_MLP()
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 ``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.
:param _layer_sizes: Integer vector specifying the number of neurons in each layer including the input and output layers.
:param layerSizes: Integer vector specifying the number of neurons in each layer including the input and output layers.
:param _activ_func: Parameter specifying the activation function for each neuron: one of ``CvANN_MLP::IDENTITY`` , ``CvANN_MLP::SIGMOID_SYM`` , and ``CvANN_MLP::GAUSSIAN`` .
:param activateFunc: Parameter specifying the activation function for each neuron: one of ``CvANN_MLP::IDENTITY``, ``CvANN_MLP::SIGMOID_SYM``, and ``CvANN_MLP::GAUSSIAN``.
:param _f_param1,_f_param2: Free parameters of the activation function, :math:`\alpha` and :math:`\beta` , respectively. See the formulas in the introduction section.
:param fparam1/fparam2: Free parameters of the activation function, :math:`\alpha` and :math:`\beta`, respectively. See the formulas in the introduction section.
The method creates an MLP network with the specified topology and assigns the same activation function to all the neurons.
:param _outputs: Floating-point matrix of the corresponding output vectors, one vector per row.
:param inputs: Floating-point matrix of input vectors, one vector per row.
:param _sample_weights: (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.
:param outputs: Floating-point matrix of the corresponding output vectors, one vector per row.
:param _sample_idx: Optional integer vector indicating the samples (rows of ``_inputs`` and ``_outputs`` ) that are taken into account.
:param 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.
:param _params: Training parameters. See the ``CvANN_MLP_TrainParams`` description.
:param sampleIdx: Optional integer vector indicating the samples (rows of ``inputs`` and ``outputs``) that are taken into account.
:param _flags: Various parameters to control the training algorithm. A combination of the following parameters is possible:
:param params: Training parameters. See the :ocv:class:`CvANN_MLP_TrainParams` description.
* **UPDATE_WEIGHTS = 1** Algorithm updates the network weights, rather than computes them from scratch. In the latter case the weights are initialized using the Nguyen-Widrow algorithm.
:param 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.
...
...
@@ -257,3 +238,38 @@ Trains/updates MLP.
This method applies the specified training algorithm to computing/adjusting the network weights. It returns the number of done iterations.