fix use of default_rng seeded with OS noise#54
Open
kelsohmm wants to merge 1 commit intooxwhirl:mainfrom
Open
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Some functions in the code utilize
np.random.default_rng()to create a random number generator, which causes indeterminism in environment behavior and ruins reproducibility.This function doesn't return the global object of random generator used by numpy, but returns a new
Generatorobject, with its own seed. When theseed=parameter is not used explicitly, "then fresh, unpredictable entropy will be pulled from the OS" and used for the seed of the generator.In RL environment, its standard to make the environment random number generation fully deterministic based on a global seed number, which usually is set for Python's own
randomlibrary, numpy'srandomand any other libraries used with their own random state (like Torch or Tensorflow). Setting the seeds on experiment launch should cause the randomness to be fully deterministic, thus yielding the exact same results when rerunning the same experiment with the same seed on same hardware.This pull requests replaces the use of
np.random.default_rng(seed=None)- seeded with OS noise - withnp.random.default_rng(seed=np.random.randint(9999999))- seeded with a random number, taken from global numpy generator based on the controllable global seed number, making the experiments fully deterministic yet still stochastic.BEFORE:

AFTER:
