Ask Your Question
0

MLP Same Data Different Results

asked 2015-06-12 16:04:14 -0600

TKJ gravatar image

updated 2015-06-16 14:14:03 -0600

Let Me simplify this question.

If I run opencv MLP train and classify consecutively on the same data, I get different results. Meaning, if I put training a new mlp on the same train data and classifying on the same test data in a for loop, each iteration will give me different results. Even though I am creating a new mlp object each iteration. However, if instead of using a for loop I just run the program a few times, restarting the program after each train and classify; the results are exactly the same.

So question is, does opencv use previous weights, variables, or something of the sorts from other mlp trains? Even though it is not the same mlp object. Anyone know why it does this?

Thanks for the time! -Tim

edit retag flag offensive close merge delete

1 answer

Sort by ยป oldest newest most voted
2

answered 2015-06-17 02:55:40 -0600

berak gravatar image

updated 2015-06-17 02:56:08 -0600

you're obviously using opencv24, where the global random generator is used to initialize the weights.

so, when you restart your prog, you will always start with the same seed, if you run it in a loop, - not so.

as a remedy, initialize the global seed for each train run:

theRNG().state = 12345679;

(note, that the opencv30 version does not suffer from this problem)

edit flag offensive delete link more

Comments

Yup! this was the problem, thanks!

TKJ gravatar imageTKJ ( 2015-06-20 01:02:30 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2015-06-12 16:04:14 -0600

Seen: 247 times

Last updated: Jun 16 '15