当前位置: 首页>>代码示例>>C++>>正文


C++ random_distribution函数代码示例

本文整理汇总了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);
  }
}
开发者ID:ArtHacker123,项目名称:mini-caffe,代码行数:10,代码来源:math_functions.cpp

示例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));
  }
}
开发者ID:ArtHacker123,项目名称:mini-caffe,代码行数:11,代码来源:math_functions.cpp

示例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);
  }
}
开发者ID:ArtHacker123,项目名称:mini-caffe,代码行数:11,代码来源:math_functions.cpp

示例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();
    }
}
开发者ID:flair2005,项目名称:mmd-caffe,代码行数:11,代码来源:math_functions.cpp

示例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());
    }
}
开发者ID:flair2005,项目名称:mmd-caffe,代码行数:12,代码来源:math_functions.cpp

示例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();
    }
}
开发者ID:flair2005,项目名称:mmd-caffe,代码行数:12,代码来源:math_functions.cpp

示例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
}
开发者ID:crobertob,项目名称:caffe,代码行数:16,代码来源:math_functions.cpp


注:本文中的random_distribution函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。