c++ - OpenCV是否用零初始化权重矩阵,cv::ml::ANN_MLP

标签 c++ opencv neural-network opencv3.3

它在 OpenCV 文档中提到 here

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.

还提到了:

UPDATE_WEIGHTS

Update the network weights, rather than compute them from scratch. In the latter case the weights are initialized using the Nguyen-Widrow algorithm.

所以我想知道当我开始训练模型时,权重初始化到底发生了什么。也感谢与 OpenCV 3.3.1 相关的答案

最佳答案

您有任何理由怀疑文档吗? OpenCV是开源库,下面有什么可以自己看here

ANN_MLPImpl()
{
    clear();
    setActivationFunction( SIGMOID_SYM, 0, 0);
    setLayerSizes(Mat());
    setTrainMethod(ANN_MLP::RPROP, 0.1, FLT_EPSILON);
}

当你调用train时,可能会调用init_weights()

bool train( const Ptr<TrainData>& trainData, int flags )
{
    // Some code
    // ... and link weights
    if( !(flags & UPDATE_WEIGHTS) )
        init_weights();
    // Even more code

这里是 init_weights()

void init_weights()
{
    //... More code
        // initialize weights using Nguyen-Widrow algorithm
        for( j = 0; j < n2; j++ )
        {
            double s = 0;
           // .. more initialization code

关于c++ - OpenCV是否用零初始化权重矩阵,cv::ml::ANN_MLP,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48078187/

相关文章:

c++ - 警告 : disabled use of C++11 features in Armadillo

c++ - 如何添加一个字符数组(并使它们变成整数)

C++ NetBeans : How to link my . o 文件到我的项目?

C++ 程序在 Visual Studio v.6 中挂起

c++ - 使用 mingw 将静态库 (.a) 链接到 exe

python - 将多个输入传递到 Keras 模型时出错

python - VGG16 Keras 微调 : low accuracy

python - 检测复选框是否被勾选的最佳方法

c++ - 相当于opencv中matlab的 "ismember"?

matlab - 粒子群优化训练神经网络的概念问题