Skip to content

changed behavior of rand_seed in BRSA - #239

Merged
mihaic merged 33 commits into
brainiak:masterfrom
lcnature:fix_rng
Jul 13, 2017
Merged

mihaic merged 33 commits into
brainiak:masterfrom
lcnature:fix_rng

Conversation

@lcnature

Copy link
Copy Markdown
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
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

@mihaic mihaic left a comment

Copy link
Copy Markdown
Member

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
Copy Markdown
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
Copy Markdown
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

mihaic commented Jul 13, 2017

Copy link
Copy Markdown
Member

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
Copy Markdown
Contributor Author

Please see if the new commit is correct. Thanks!

l_idx = np.tril_indices(n_C)

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

Copy link
Copy Markdown
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
Copy Markdown
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