本文整理汇总了C++中random_distribution函数的典型用法代码示例。如果您正苦于以下问题:C++ random_distribution函数的具体用法?C++ random_distribution怎么用?C++ random_distribution使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了random_distribution函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: caffe_rng_uniform
void caffe_rng_uniform(const int n, const Dtype a, const Dtype b, Dtype* r) {
CHECK_GE(n, 0);
CHECK(r);
CHECK_LE(a, b);
std::uniform_real<Dtype> random_distribution(a, caffe_nextafter<Dtype>(b));
rng_t* engine = caffe_rng();
for (int i = 0; i < n; ++i) {
r[i] = random_distribution(*engine);
}
}
示例2: caffe_rng_bernoulli
void caffe_rng_bernoulli(const int n, const Dtype p, unsigned int* r) {
CHECK_GE(n, 0);
CHECK(r);
CHECK_GE(p, 0);
CHECK_LE(p, 1);
std::bernoulli_distribution random_distribution(p);
rng_t* engine = caffe_rng();
for (int i = 0; i < n; ++i) {
r[i] = static_cast<unsigned int>(random_distribution(*engine));
}
}
示例3: caffe_rng_gaussian
void caffe_rng_gaussian(const int n, const Dtype a,
const Dtype sigma, Dtype* r) {
CHECK_GE(n, 0);
CHECK(r);
CHECK_GT(sigma, 0);
std::normal_distribution<Dtype> random_distribution(a, sigma);
rng_t* engine = caffe_rng();
for (int i = 0; i < n; ++i) {
r[i] = random_distribution(*engine);
}
}
示例4: caffe_rng_uniform
void caffe_rng_uniform(const int n, const Dtype a, const Dtype b, Dtype* r) {
CHECK_GE(n, 0);
CHECK(r);
CHECK_LE(a, b);
boost::uniform_real<Dtype> random_distribution(a, caffe_nextafter<Dtype>(b));
boost::variate_generator<caffe::rng_t*, boost::uniform_real<Dtype> >
variate_generator(caffe_rng(), random_distribution);
for (int i = 0; i < n; ++i) {
r[i] = variate_generator();
}
}
示例5: caffe_rng_bernoulli
void caffe_rng_bernoulli(const int n, const Dtype p, unsigned int* r) {
CHECK_GE(n, 0);
CHECK(r);
CHECK_GE(p, 0);
CHECK_LE(p, 1);
boost::bernoulli_distribution<Dtype> random_distribution(p);
boost::variate_generator<caffe::rng_t*, boost::bernoulli_distribution<Dtype> >
variate_generator(caffe_rng(), random_distribution);
for (int i = 0; i < n; ++i) {
r[i] = static_cast<unsigned int>(variate_generator());
}
}
示例6: caffe_rng_gaussian
void caffe_rng_gaussian(const int n, const Dtype a,
const Dtype sigma, Dtype* r) {
CHECK_GE(n, 0);
CHECK(r);
CHECK_GT(sigma, 0);
boost::normal_distribution<Dtype> random_distribution(a, sigma);
boost::variate_generator<caffe::rng_t*, boost::normal_distribution<Dtype> >
variate_generator(caffe_rng(), random_distribution);
for (int i = 0; i < n; ++i) {
r[i] = variate_generator();
}
}
示例7: caffe_rng_bernoulli
void caffe_rng_bernoulli(const int n, const Dtype p, int* r) {
CHECK_GE(n, 0);
CHECK(r);
CHECK_GE(p, 0);
CHECK_LE(p, 1);
#ifdef USE_MKL
bernoulli_generate(n, p, r);
#else
boost::bernoulli_distribution<Dtype> random_distribution(p);
boost::variate_generator<caffe::rng_t*, boost::bernoulli_distribution<Dtype> >
variate_generator(caffe_rng(), random_distribution);
for (int i = 0; i < n; ++i) {
r[i] = variate_generator();
}
#endif
}