Set a ANN_MLP as trained

asked 2019-03-07 08:29:30 -0600

wug gravatar image

Hello,

We are using ANN_MLP in a special way. We train a ANN_MLP and we save the network configuration in a .hpp file. Then we need to load the network configuration. We can not use the load function. Therefore we have to set the weight using getWeights() like that:

cv::Mat((128+1) , 100, CV_64F, WEIGHTS_01 ).copyTo(getWeights(1));

Is that correct?

We also need to set the attribut trained to True. We not find the way to do that. Do you know how to do that?

Thank you,

edit retag flag offensive close merge delete

Comments

about : cv::Mat((128+1) , 100, CV_64F, WEIGHTS_01 ).copyTo(getWeights(1));

it is not correct but it works!

How to set trained to true? Trained your network with 1 iteration and updatWeighte or save your network in temporary yml file and reload it

or make a PR

LBerger gravatar imageLBerger ( 2019-03-07 15:01:34 -0600 )edit

we train the network then we put the weights in a static array in a hpp. Above WEIGHTS_01 is a static array. What do you mean by: "it is not correct but it works" ?

wug gravatar imagewug ( 2019-03-08 02:45:20 -0600 )edit

Method is getWeights and not setWeights. Usually there is a get and set method

LBerger gravatar imageLBerger ( 2019-03-08 02:52:09 -0600 )edit

But not in the ANN_MLP class of opencv: you can not set the weight is there a reason for that? I am using still opencv 3...

wug gravatar imagewug ( 2019-03-08 02:55:18 -0600 )edit

so, what you want, is not builtin (though it makes some sense)

maybe you can add a setWeights(vector<Mat>) function, that:

  • sets up the layer sizes according to the resp. weights
  • sets the actual weights
  • sets the trained flag
berak gravatar imageberak ( 2019-03-09 05:06:30 -0600 )edit