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

@lcnature lcnature commented Jul 13, 2017

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 Sep 2, 2016
lcnature
a
 Changes to be committed:
	new file: brainiak/brsa/test.txt
lcnature
a
 Changes to be committed:
	new file: brainiak/brsa/test.txt
lcnature
a
 Changes to be committed:
	new file: brainiak/brsa/test.txt
lcnature
a
 Changes to be committed:
	new file: brainiak/brsa/test.txt
lcnature
a
 Changes to be committed:
	new file: brainiak/brsa/test.txt
lcnature
a
 Changes to be committed:
	new file: brainiak/brsa/test.txt
lcnature
a
 Changes to be committed:
	new file: brainiak/brsa/test.txt
lcnature
a
 Changes to be committed:
	new file: brainiak/brsa/test.txt
Mingbo Cai
Copy link
Contributor

@mihaic mihaic left a comment

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

@lcnature lcnature commented Jul 13, 2017

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

@lcnature lcnature commented Jul 13, 2017

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
Contributor

@mihaic 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

@lcnature lcnature commented Jul 13, 2017

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)

This comment has been minimized.

@mihaic

mihaic Jul 13, 2017
Contributor

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

random_state_: `RandomState`
    Random number generator initialized using random_state

This comment has been minimized.

@lcnature

lcnature Jul 13, 2017
Author Contributor

Thanks. Just added exactly this text.

Mingbo Cai
@mihaic
mihaic approved these changes Jul 13, 2017
@mihaic mihaic merged commit e230a01 into brainiak:master Jul 13, 2017
2 of 3 checks passed
2 of 3 checks passed
continuous-integration/travis-ci/pr The Travis CI build is in progress
Details
linux Build finished.
Details
macos Build finished.
Details
@lcnature lcnature deleted the lcnature:fix_rng branch Aug 10, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants