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

how do I sample a consistent random seem in pyll? #4

Open
yamins81 opened this issue Feb 17, 2012 · 5 comments
Open

how do I sample a consistent random seem in pyll? #4

yamins81 opened this issue Feb 17, 2012 · 5 comments

Comments

@yamins81
Copy link
Contributor

e.g. the replacement of

genson_template.sample(seed)

?

Right now,

 stochastic.sample(template, np.random.RandomState(seed))

does NOT yield the same result on each call with a fixed seed, e.g. 0. Is it supposed to? If so, I'll submit a test

@jaberg
Copy link
Owner

jaberg commented Feb 17, 2012

True, that function makes no attempt to replicate the traversal order of genSON.

See #2 for the need for genson-compatible sampling and grid iteration.

@jaberg
Copy link
Owner

jaberg commented Feb 18, 2012

The ticket is worded ambiguously and suggests that calling sample twice with the same seed yields two different results. This would be terrible, but it is not what happens. There are unit tests protecting against this behaviour. Given the scary suggestion of the issue's wording and the redundancy with #2, I'm closing it.

@jaberg jaberg closed this as completed Feb 18, 2012
@yamins81
Copy link
Contributor Author

The situation described above IS what happens, in some sense In other words, two calls of exactly this:
stochastic.sample(T, np.random.RandomState(0))
one right after the other, yield different results. It seems to be required that one re-initialize the T object to get back to the original state ... I was expecting a different behavior, one in which the passed RandomState object somehow is the only source of randomness -- and not some state that is set/saved in the T object.

@jaberg
Copy link
Owner

jaberg commented Feb 18, 2012

Need an example then, because test_repeatable passes, as expected. There's something subtler going on.

@jaberg jaberg reopened this Feb 18, 2012
@yamins81
Copy link
Contributor Author

eccv12.lfw.MainBandit has this issue. e.g.

In [124]: L = eccv12.lfw.MainBandit()

In [125]: pyll.stochastic.sample(L.template, np.random.RandomState(0))['slm'][-1][-1][-1]['kwargs']['stretch']
Out[125]: array(6.527903170054908)

In [126]: pyll.stochastic.sample(L.template, np.random.RandomState(0))['slm'][-1][-1][-1]['kwargs']['stretch']
Out[126]: array(3.1720174206929608)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants