經過斷言 咱們能夠知道是代碼: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