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

Be careful with np.random.seed #8

Open
mpvanderschelling opened this issue Aug 8, 2024 · 0 comments
Open

Be careful with np.random.seed #8

mpvanderschelling opened this issue Aug 8, 2024 · 0 comments

Comments

@mpvanderschelling
Copy link

The problem

What can happen, is that you initialize this class with a seed, an set the numpy RNG: (numpy.random.set_seed(seed))
Then in your code, you decide to set the seed again, but then the np.random.seed is changed and the class seed is also changed unintenionally.

Possible solution

Use numpy generator, this is advised by the numpy community.

Assignees:
Labels:
Milestone:

# set random seed
self.seed = seed
np.random.seed(seed)

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

No branches or pull requests

1 participant