BVLC/caffe — pull request #352 by jeffdonahue (2014-04-22 23:44:20+00:00)
Title: 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 `rand` in 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 find just by grepping for `rand(`, e.g. the use of std::shuffle which I had to replace.