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

Fix: random seed set to int if not provided, support reproducible runs #61

Merged
merged 1 commit into from
Jun 18, 2020

Conversation

amoodie
Copy link
Member

@amoodie amoodie commented Jun 14, 2020

set random seed to an int in 0 to (2**32)-1 if it is not specified in the YAML configuration file. This enables runs to be reproducible, even if the seed is not set explicitly.

closes #58

… the yaml configuration file. This enables runs to be reproducible, even if the seed is not set explicitly.
@amoodie amoodie added bug Something isn't working enhancement New feature or request labels Jun 14, 2020
@amoodie amoodie added this to In progress in Version 2.0 via automation Jun 14, 2020
@ericbarefoot
Copy link
Collaborator

I see, so we set the seed by default and record it, which gets around the whole "random states are easily recorded and reinstantiated." problem.

However, I am curious how we should handle starting from checkpoints in this framework. Should we also eventually include a way to record the random state and just start by using the random state?

@amoodie
Copy link
Member Author

amoodie commented Jun 15, 2020

I am curious how we should handle starting from checkpoints in this framework. Should we also eventually include a way to record the random state and just start by using the random state?

Good question, I hadn't thought about checkpointing.

I think the way to implement checkpointing (#57) is to write a single .npy file to disk every N timesteps. In the OG checkpointing implementation, the grids are all written to different .npy files, but it should be straightforward to pack the grids, time-status, etc, into one file and write to disk.

So, for the random state, I agree with your idea. We would do a quick rs = np.random.get_state(), and then pack rs into the checkpointed .npy file. Then when loading, just set the random state to rs.

@amoodie amoodie merged commit 5828072 into DeltaRCM:develop Jun 18, 2020
Version 2.0 automation moved this from In progress to Done Jun 18, 2020
@elbeejay elbeejay mentioned this pull request Jul 14, 2020
amoodie added a commit to amoodie/pyDeltaRCM that referenced this pull request Feb 25, 2021
Fix: random seed set to int if not provided, support reproducible runs
@amoodie amoodie deleted the fix_randomseed_setting branch February 25, 2021 17:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working enhancement New feature or request
Projects
Version 2.0
  
Done
Development

Successfully merging this pull request may close these issues.

recording random seed
2 participants