-
Notifications
You must be signed in to change notification settings - Fork 18.6k
Eliminate use of "rand" in code; enable deterministic results via solver seed #352
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
Conversation
|
Nice! Can you add a lint check that greps for calls to rand() and company to keep Le mardi 22 avril 2014, Jeff Donahue notifications@github.com a écrit :
Evan Shelhamer |
|
There are also random(), *rand48() and the *_r() variants to grep for (not On Tue, Apr 22, 2014 at 5:02 PM, Evan Shelhamer notifications@github.comwrote:
|
|
@shelhamer lint already checks for uses of @rbgirshick thanks, I just grepped for these -- the only one I found was a call to |
|
@shelhamer decided not to be lazy and added a special |
already works for lenet, doesn't work for imagenet w/ rand() calls
rand -- seeded tests still fail
|
Nice side-issue progress on pulling prefetch out of the data layers and reduce code duplication. Thanks for adding the |
|
This all looks right and orderly and it tests fine. Note that I did not look for further, less obvious examples of |
Eliminate use of "rand" in code; enable deterministic results via solver seed
Eliminate use of "rand" in code; enable deterministic results via solver seed
This PR allows one to add "random_seed: 4" (or any other uint) to the bottom of a solver prototxt to ensure results are exactly consistent across runs. Enabling this involved removing every use of
randin the codebase* and replacing with a use of the internal Caffe RNG. For the prefetch threads in the data layers, I've given them their own private RNG engine which is seeded by the current main thread's RNG when the thread is created, which I think should ensure robustness to differences in the interleaving of the execution of the main thread and prefetch thread.After this PR no future Caffe code should call
rand(or any other function from the stdlib relying on it).*might have missed something as some can't be found just by grepping for
rand(, e.g. the use of std::shuffle which I had to replace.