cap second order gradient

This commit is contained in:
tqchen
2015-03-25 12:08:53 -07:00
parent 53c9a7b66b
commit 08fb205102
2 changed files with 7 additions and 3 deletions

View File

@@ -296,14 +296,16 @@ struct WXQSummary : public WQSummary<DType, RType> {
}
RType begin = src.data[0].rmax;
size_t n = maxsize - 1, nbig = 0;
const RType range = src.data[src.size - 1].rmin - begin;
RType range = src.data[src.size - 1].rmin - begin;
// prune off zero weights
if (range == 0) {
if (range == 0.0f) {
// special case, contain only two effective data pts
this->data[0] = src.data[0];
this->data[1] = src.data[src.size - 1];
this->size = 2;
return;
} else {
range = std::max(range, static_cast<RType>(1e-3f));
}
const RType chunk = 2 * range / n;
// minimized range