This repository has been archived by the owner on Nov 17, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
[MXNET-262] Implement mx.random.seed_context to seed random number generators of a specific device context #10367
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
I would add a |
@piiswrong Omitting |
I still think its better than adding an API. |
maybe you can make it defaults to 'all' |
`mx.random.seed_context` is to seed the random number generator of a specific device context. The random number sequence on the deivce is completly determined by the given seed and is independent of the device id. This is in contrast to `mx.random.seed` which seeds all generators using the device id implicitly.
I removed |
@piiswrong can this be merged. will add this to api changes in release notes. |
Thanks a lot for this change, this really something we've been looking for! |
rahul003
pushed a commit
to rahul003/mxnet
that referenced
this pull request
Jun 4, 2018
…nerators of a specific device context (apache#10367) * Implement mx.random.seed_context `mx.random.seed_context` is to seed the random number generator of a specific device context. The random number sequence on the deivce is completly determined by the given seed and is independent of the device id. This is in contrast to `mx.random.seed` which seeds all generators using the device id implicitly. * Fix lint * Adding ctx argument to random.seed instead of new function random.seed_context * Doc fix
zheng-da
pushed a commit
to zheng-da/incubator-mxnet
that referenced
this pull request
Jun 28, 2018
…nerators of a specific device context (apache#10367) * Implement mx.random.seed_context `mx.random.seed_context` is to seed the random number generator of a specific device context. The random number sequence on the deivce is completly determined by the given seed and is independent of the device id. This is in contrast to `mx.random.seed` which seeds all generators using the device id implicitly. * Fix lint * Adding ctx argument to random.seed instead of new function random.seed_context * Doc fix
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR is modified to add an optional argument
ctx
tomx.random.seed
instead of introducing a new functionseed_context
. Seeding withctx
option produces random number sequence independent of device id. The below is the original description before the modification.Description
This PR introduces a function
mx.random.seed_context
to seed random number generators of a specific device context.mx.random.seed_context(seed, ctx)
seeds the parallel and non-parallel generators ofctx
wherectx
is optional and the default is the current context. The random number sequence generated on the device is completely determined byseed
, differently from existingmx.random.seed
which implicitly uses the device id of each context together with the given seed. Using device id is reasonable to seed all generators at once with a given seed, but to reproduce the same random number sequence we need to set the running context besides seeding with the same number. Sometimes setting a context would be inconvenient or the running context could be not deterministic.mx.random.seed_context
would be helpful in such cases.The implementation is simple. It just hands over the given seed to the underlying generators. The unit tests are an adaptation of the existing tests for
mx.random.seed
.Here is an example.
Checklist
Essentials
Please feel free to remove inapplicable items for your PR.