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

changed behavior of rand_seed in BRSA #239

Merged
merged 33 commits into from
Jul 13, 2017
Merged

changed behavior of rand_seed in BRSA #239

merged 33 commits into from
Jul 13, 2017

Conversation

lcnature
Copy link
Contributor

Per request by @mshvartsman, rand_seed argument now defaults to None, and BRSA won't reset random seed if None is provided.
The suppression of warning is also removed.

lcnature and others added 30 commits September 2, 2016 10:12
a
 Changes to be committed:
	new file: brainiak/brsa/test.txt
a
 Changes to be committed:
	new file: brainiak/brsa/test.txt
a
 Changes to be committed:
	new file: brainiak/brsa/test.txt
a
 Changes to be committed:
	new file: brainiak/brsa/test.txt
a
 Changes to be committed:
	new file: brainiak/brsa/test.txt
a
 Changes to be committed:
	new file: brainiak/brsa/test.txt
a
 Changes to be committed:
	new file: brainiak/brsa/test.txt
a
 Changes to be committed:
	new file: brainiak/brsa/test.txt
Copy link
Member

@mihaic mihaic left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We now have guidelines on using random numbers:
https://github.com/IntelPNI/brainiak/blob/master/CONTRIBUTING.rst#standards

Therefore, all new commits should conform to the standard. Specifically, you should not use numpy.random.random(); you should use numpy.random.RandomState.

@lcnature
Copy link
Contributor Author

Hi @mihaic Sorry I am a bit confused. How should numpy.random.RandomState replace numpy.random.random()? I thought the former sets the state while the latter just return a random number.
Thanks!

@lcnature
Copy link
Contributor Author

Does that mean I should call this random_state = check_random_state(random_state), and from then on, replace all np.random with random_state?

@mihaic
Copy link
Member

mihaic commented Jul 13, 2017

RandomState objects also have several methods for generating random numbers. RandomState.random_sample() is a good replacement for numpy.random.random():
https://docs.scipy.org/doc/numpy/reference/generated/numpy.random.RandomState.random_sample.html

You do not need to use check_random_state.

@lcnature
Copy link
Contributor Author

Please see if the new commit is correct. Thanks!

@@ -686,7 +688,7 @@ def _fit_RSA_UV(self, X, Y, X0,
n_C = np.size(X, axis=1)
l_idx = np.tril_indices(n_C)

np.random.seed(self.rand_seed)
self.random_state_ = check_random_state(self.random_state)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please document this attribute in the class docstring. Could be something like this:

random_state_: `RandomState`
    Random number generator initialized using random_state

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. Just added exactly this text.

@mihaic mihaic merged commit e230a01 into brainiak:master Jul 13, 2017
@lcnature lcnature deleted the fix_rng branch August 10, 2017 21:58
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

Successfully merging this pull request may close these issues.

2 participants