1 #ifndef CAFFE_RNG_CPP_HPP_ 2 #define CAFFE_RNG_CPP_HPP_ 7 #include "boost/random/mersenne_twister.hpp" 8 #include "boost/random/uniform_int.hpp" 10 #include "caffe/common.hpp" 14 typedef boost::mt19937 rng_t;
16 inline rng_t* caffe_rng() {
17 return static_cast<caffe::rng_t*
>(Caffe::rng_stream().generator());
21 template <
class RandomAccessIterator,
class RandomGenerator>
22 inline void shuffle(RandomAccessIterator begin, RandomAccessIterator end,
23 RandomGenerator* gen) {
24 typedef typename std::iterator_traits<RandomAccessIterator>::difference_type
26 typedef typename boost::uniform_int<difference_type> dist_type;
28 difference_type length = std::distance(begin, end);
29 if (length <= 0)
return;
31 for (difference_type i = length - 1; i > 0; --i) {
33 std::iter_swap(begin + i, begin + dist(*gen));
37 template <
class RandomAccessIterator>
38 inline void shuffle(RandomAccessIterator begin, RandomAccessIterator end) {
39 shuffle(begin, end, caffe_rng());
43 #endif // CAFFE_RNG_HPP_ A layer factory that allows one to register layers. During runtime, registered layers can be called b...
Definition: blob.hpp:14