use boost variate_generator to pass tests w/ boost 1.46 (Gaussian filler
authorJeff Donahue <jeff.donahue@gmail.com>
Wed, 22 Jan 2014 20:28:01 +0000 (12:28 -0800)
committerEvan Shelhamer <shelhamer@imaginarynumber.net>
Fri, 21 Mar 2014 20:52:35 +0000 (13:52 -0700)
previously filled in all NaNs for me, making many tests fail)

src/caffe/util/math_functions.cpp

index 812708f..832f641 100644 (file)
@@ -432,9 +432,12 @@ void caffe_vRngGaussian(const int n, Dtype* r, const Dtype a,
     // the tests are irrelevant to the random numbers.
   boost::normal_distribution<Dtype> random_distribution(a, sigma);
   Caffe::random_generator_t &generator = Caffe::vsl_stream();
+  boost::variate_generator<Caffe::random_generator_t,
+      boost::normal_distribution<Dtype> > variate_generator(
+      generator, random_distribution);
 
-  for(int i = 0; i < n; i += 1) {
-    r[i] = random_distribution(generator);
+  for(int i = 0; i < n; ++i) {
+    r[i] = variate_generator();
   }
 }