Error with UPDATE_WEIGHTS and neural networks

asked 2012-09-30 11:13:47 -0600

jmr gravatar image

updated 2012-09-30 11:14:42 -0600


I get an error when using UPDATE_WEIGHTS in order to adapt the weights of a neural network without reinitializing them. The error states:

OpenCV Error: One of arguments' values is out of range (Some of new output train ing vector components run exceed the original range too much) in CvANN_MLP::calc _output_scale, file ......\src\opencv\modules\ml\src\ann_mlp.cpp, line 638

I am using OpenCV 2.4.2 (before I tried with 2.3.1 and got the same error). My code looks like this:

int numiter = 0;
for(size_t n=0; n<_num_trn_cycles; ++n)
        flags = flags | CvANN_MLP::UPDATE_WEIGHTS;
    numiter += _mlp.train(trnfeat, trnlabs, Mat(), Mat(), params, flags);
    cout << numiter << endl;

My feature vectors have been previously normalized to have zero mean and unit standard deviation. The first iteration of the loop executes correctly, but afterwards once the UPDATE_WEIGHTS flag is set, the program stops. Is this a bug in the OpenCV code or should I do something else?

Thanks in advance!


edit retag flag offensive close merge delete


have you checked neural layer...check the layer size if there may be wrong configuration..

Shivanshu gravatar imageShivanshu ( 2018-04-26 09:22:47 -0600 )edit