本文整理汇总了C++中caffe_rng函数的典型用法代码示例。如果您正苦于以下问题:C++ caffe_rng函数的具体用法?C++ caffe_rng怎么用?C++ caffe_rng使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了caffe_rng函数的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: caffe_rng_rand
unsigned int caffe_rng_rand() {
#ifdef DETERMINISTIC
return 5153;
#else
return (*caffe_rng())();
#endif
}
开发者ID:crobertob,项目名称:caffe,代码行数:7,代码来源:math_functions.cpp
示例2: 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
示例3: 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
示例4: 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
示例5: 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
示例6: 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
示例7: 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
示例8: 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
示例9: caffe_rng_rand
unsigned int caffe_rng_rand() {
return (*caffe_rng())();
}
开发者ID:flair2005,项目名称:mmd-caffe,代码行数:3,代码来源:math_functions.cpp
示例10: return
uint64_t Caffe::next_seed() {
return (*caffe_rng())();
}
开发者ID:Caffe-MPI,项目名称:Caffe-MPI.github.io,代码行数:3,代码来源:common.cpp
示例11: switch
void PixelFeatureLayer<Dtype>::Forward_cpu(
const vector<Blob<Dtype>*>& bottom, const vector<Blob<Dtype>*>& top) {
const PixelFeatureParameter& parameter =
this->layer_param_.pixel_feature_param();
Dtype* top_data = top[0]->mutable_cpu_data();
switch (this->layer_param_.pixel_feature_param().type()) {
case PixelFeatureParameter_Feature_POSITION: {
if (!ran_once) {
const Dtype scale = parameter.pos_scale();
const Dtype offset_h = parameter.offset_h();
const Dtype offset_w = parameter.offset_w();
for (unsigned int n = 0; n < num_; ++n) {
for (unsigned int y = 0; y < height_; ++y) {
Dtype y_offset = scale * y + offset_h;
for (unsigned int x = 0; x < width_; ++x) {
top_data[top[0]->offset(n, 0, y, x)] = y_offset;
top_data[top[0]->offset(n, 1, y, x)] = scale * x + offset_w;
}
}
}
}
break;
}
case PixelFeatureParameter_Feature_POSITION_AND_RGB: {
const Dtype scale = parameter.pos_scale();
const Dtype color_scale = parameter.color_scale();
const Dtype offset_h = parameter.offset_h();
const Dtype offset_w = parameter.offset_w();
for (unsigned int n = 0; n < num_; ++n) {
for (unsigned int y = 0; y < height_; ++y) {
Dtype y_offset = scale * y + offset_h;
for (unsigned int x = 0; x < width_; ++x) {
top_data[top[0]->offset(n, 0, y, x)] = y_offset;
top_data[top[0]->offset(n, 1, y, x)] = scale * x + offset_w;
for (unsigned int c = 0; c < bottom[0]->channels(); ++c) {
top_data[top[0]->offset(n, c+2, y, x)] =
color_scale * bottom[0]->data_at(n, c, y, x);
}
}
}
}
break;
}
case PixelFeatureParameter_Feature_RGB_AND_POSITION: {
const Dtype scale = parameter.pos_scale();
const Dtype color_scale = parameter.color_scale();
const Dtype offset_h = parameter.offset_h();
const Dtype offset_w = parameter.offset_w();
for (unsigned int n = 0; n < num_; ++n) {
for (unsigned int y = 0; y < height_; ++y) {
Dtype y_offset = scale * y + offset_h;
for (unsigned int x = 0; x < width_; ++x) {
for (unsigned int c = 0; c < bottom[0]->channels(); ++c) {
top_data[top[0]->offset(n, c, y, x)] =
color_scale * bottom[0]->data_at(n, c, y, x);
}
top_data[top[0]->offset(n, bottom[0]->channels(), y, x)] = y_offset;
top_data[top[0]->offset(n, bottom[0]->channels() + 1, y, x)] =
scale * x + offset_w;
}
}
}
break;
}
case PixelFeatureParameter_Feature_RGB: {
const Dtype color_scale = parameter.color_scale();
for (unsigned int n = 0; n < num_; ++n) {
for (unsigned int y = 0; y < height_; ++y) {
for (unsigned int x = 0; x < width_; ++x) {
for (unsigned int c = 0; c < bottom[0]->channels(); ++c) {
top_data[top[0]->offset(n, c, y, x)] =
color_scale * bottom[0]->data_at(n, c, y, x);
}
}
}
}
break;
}
case PixelFeatureParameter_Feature_RANDOM_POSITION:
case PixelFeatureParameter_Feature_NUM_RANDOM_POSITION: {
if (!ran_once) {
const int input_height = bottom[0]->height();
const int input_width = bottom[0]->width();
const Dtype scale = parameter.pos_scale();
boost::uniform_real<Dtype> random_height(0, input_height);
boost::variate_generator<caffe::rng_t*, boost::uniform_real<Dtype> >
variate_height(caffe_rng(), random_height);
boost::uniform_real<Dtype> random_width(0, input_width);
boost::variate_generator<caffe::rng_t*, boost::uniform_real<Dtype> >
variate_width(caffe_rng(), random_width);
for (unsigned int n = 0; n < num_; ++n) {
//.........这里部分代码省略.........
开发者ID:MPI-IS,项目名称:bilateralNN,代码行数:101,代码来源:pixel_feature_layer.cpp
示例12: shuffle
inline void shuffle(RandomAccessIterator begin, RandomAccessIterator end) {
shuffle(begin, end, caffe_rng());
}
开发者ID:maony,项目名称:cnn-soc,代码行数:3,代码来源:rng.hpp
注:本文中的caffe_rng函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论