Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Random must not ignore seed in multiple instances #417

Closed
breznak opened this issue Apr 17, 2019 · 3 comments
Closed

Random must not ignore seed in multiple instances #417

breznak opened this issue Apr 17, 2019 · 3 comments
Labels
bug Something isn't working code code enhancement, optimization, cleanup..programmer stuff high wontfix This will not be worked on

Comments

@breznak
Copy link
Member

breznak commented Apr 17, 2019

Random should not use static members, esp static_gen and static_is_seeded, otherwise the first instance of random sets the seed, but seed is ignored for any other random instance during the runtime!

From Random.cpp

bool static_gen_seeded = false;  //TODO avoid the static variables?
std::mt19937 static_gen;

Example of the problem:

sp = SpatialPooler(..., seed = 42); //OK, has rng with seed 42
rng = Random(1); //has rng with seed 42, not 1!

and

rng = Random(1); //OK, seed = 1
sp = SpatialPooler(..., seed = 42); //has rng with seed 1!
@breznak breznak added bug Something isn't working high code code enhancement, optimization, cleanup..programmer stuff labels Apr 17, 2019
@breznak breznak added this to the Release version 1.0 milestone Apr 17, 2019
@ctrl-z-9000-times
Copy link
Collaborator

Random only uses the static generator if seed == 0. If seed > 0 then it uses the given seed.

This is from the unit tests for Random. I think it would reproduce this bug, if it existed:

  Random r1(1);
  Random r2(2);
  ASSERT_NE(r1.getUInt32(), r2.getUInt32());

@breznak
Copy link
Member Author

breznak commented Apr 17, 2019

This is from the unit tests for Random. I think it would reproduce this bug, if it existed:

yes, I was also looking into this and my description is imprecise.

Still, in WIP PR #397 I had different results for these scenarios (compared with deterministic/"gold" check for SP/TM):

Random r(1);
SP sp();

vs. 

SP sp;
Random r;

I'll verify if this is the case, or some other mistake on my side.

@breznak breznak added the wontfix This will not be worked on label Apr 17, 2019
@breznak
Copy link
Member Author

breznak commented Apr 17, 2019

Closing as won't fix, this was my mistake.
Sorry for confusion.

The above scenario passes OK in both cases. The "bug" was that I had mismatch between hand-written values for SP, encoder outputs using different rng seed.

@breznak breznak closed this as completed Apr 17, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working code code enhancement, optimization, cleanup..programmer stuff high wontfix This will not be worked on
Projects
None yet
Development

No branches or pull requests

2 participants