summaryrefslogtreecommitdiff
path: root/src/caffe/util/math_functions.cpp
diff options
context:
space:
mode:
authorJeff Donahue <jeff.donahue@gmail.com>2014-01-22 12:42:12 -0800
committerEvan Shelhamer <shelhamer@imaginarynumber.net>2014-03-21 13:52:35 -0700
commitb3e4ac55fe42e98809857edd7ec1d2f6fbbb2335 (patch)
tree18889b46c66e61939fa6c81f2e8f0ff96115579d /src/caffe/util/math_functions.cpp
parent4b1fba7be37f885a95807f3811852ac02bce8cbd (diff)
downloadcaffeonacl-b3e4ac55fe42e98809857edd7ec1d2f6fbbb2335.tar.gz
caffeonacl-b3e4ac55fe42e98809857edd7ec1d2f6fbbb2335.tar.bz2
caffeonacl-b3e4ac55fe42e98809857edd7ec1d2f6fbbb2335.zip
change all Rng's to use variate_generator for consistency
Diffstat (limited to 'src/caffe/util/math_functions.cpp')
-rw-r--r--src/caffe/util/math_functions.cpp16
1 files changed, 11 insertions, 5 deletions
diff --git a/src/caffe/util/math_functions.cpp b/src/caffe/util/math_functions.cpp
index 832f641c..3e27f8dd 100644
--- a/src/caffe/util/math_functions.cpp
+++ b/src/caffe/util/math_functions.cpp
@@ -402,9 +402,12 @@ void caffe_vRngUniform(const int n, Dtype* r,
boost::uniform_real<Dtype> random_distribution(
a, caffe_nextafter<Dtype>(b));
Caffe::random_generator_t &generator = Caffe::vsl_stream();
+ boost::variate_generator<Caffe::random_generator_t,
+ boost::uniform_real<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();
}
}
@@ -436,7 +439,7 @@ void caffe_vRngGaussian(const int n, Dtype* r, const Dtype a,
boost::normal_distribution<Dtype> > variate_generator(
generator, random_distribution);
- for(int i = 0; i < n; ++i) {
+ for (int i = 0; i < n; ++i) {
r[i] = variate_generator();
}
}
@@ -458,9 +461,12 @@ void caffe_vRngBernoulli(const int n, Dtype* r, const double p) {
// FIXME check if parameters are handled in the same way ?
boost::bernoulli_distribution<Dtype> random_distribution(p);
Caffe::random_generator_t &generator = Caffe::vsl_stream();
+ boost::variate_generator<Caffe::random_generator_t,
+ boost::bernoulli_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();
}
}