经过断言 咱们能够知道是代码:dom
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();
}函数
这里出现的错。调试
调用的他的函数是:
void SampleBBox(const Sampler& sampler, NormalizedBBox* sampled_bbox) {
。。。。
caffe_rng_uniform(1, 0.f, 1.0 - bbox_width, &w_off);
caffe_rng_uniform(1, 0.f, 1.0 - bbox_height, &w_off);
。。。。
}orm
经过调试,我已开始觉得是精度不够致使的,因此我试着改成使用double型号来处理。结果依然数据最后的精度致使 1.0-bbox_width 仍是为负数.
结果问题依然没有解决,调试过程我中,我发现,有时候bbox_width 是能够为1.0generator
caffe_rng_uniform(1, 0.f, 1.0 - bbox_width, &w_off);
既然能够这样,那就对于精度致使问题,咱们能够直接改了数据,去掉后面精度部分。 按照这个思路。我把下面的调用函数改为了以下:io
float fHight0 = 0.f;
float fHight = 1.0 - bbox_height;
if (fHight0 > fHight)
{
fHight = 0.f;
}form
float fWidtdh0 = 0.f;
float fWidth = 1.0 - bbox_width;
if (fWidtdh0 > fWidth)
{
fWidth = 0.f;
}float
caffe_rng_uniform(1, 0.f, fWidth, &w_off);
caffe_rng_uniform(1, 0.f, fHight, &h_off);
后面这里就不在报错了
next