Ask Your Question

Neural Networks UPDATE_WEIGHTS does not work

asked 2015-06-18 13:35:01 -0600

zugo gravatar image

updated 2015-06-20 08:19:07 -0600

Hi, I'm trying to develop a neural network, where my weights are trained on-line, i.e. training algorithms should be called more times, and each time the net should keep learning starting from the current weights. So I added UPDATE_WEIGHTS flag, but when I use it, prediction and other methods return 0 or nan values. Is there a bug with this flag or am I supposed to do something different? Here the code I used:

    Mat classificationResult(1, 100, CV_32F);
    Mat training_set = Mat::zeros(100,1,CV_8U); //fill it with something at each step in the loop
    Mat test_set = Mat::zeros(100,1,CV_8U); //fill it either
    Mat layers(3,1,CV_32S);
    layers.row(0)  = Scalar(100);
    layers.row(1)  = Scalar(10);
    layers.row(2)  = Scalar(100);

    CvANN_MLP aann(layers,CvANN_MLP::SIGMOID_SYM,1,1); //aann initialization
    CvANN_MLP_TrainParams params( cvTermCriteria(CV_TERMCRIT_ITER+CV_TERMCRIT_EPS, 1000, 0.0001), CvANN_MLP_TrainParams::BACKPROP, 0.1, 0.1);
    while(1){   //run it for a while
          int iterations = aann.train(training_set, training_set,Mat(),Mat(),params, CvANN_MLP::UPDATE_WEIGHTS);
   aann.predict(test_set, classificationResult);
   cout << classificationResult << endl;

Since I'd like to create an autoassociator supervision coincides with the pattern features. If, instead, I train my network without using UPDATE_WEIGHTS, I get consistent results.

edit retag flag offensive close merge delete



a short, reproducable code snippet would definitely help with your issue

berak gravatar imageberak ( 2015-06-18 13:40:11 -0600 )edit

1 answer

Sort by ยป oldest newest most voted

answered 2016-06-02 10:42:37 -0600

majkel gravatar image

You can't train NN with UPDATE_WEIGHTS flag at start. Firstly, you have to make an iteration without this flag - the initial weights will be computed with Nguyen-Widrow algorithm.

Then you can train the NN with UPDATE_WEIGHTS in loop.

edit flag offensive delete link more

Question Tools

1 follower


Asked: 2015-06-18 13:35:01 -0600

Seen: 553 times

Last updated: Jun 02 '16