Skip to content

Commit

Permalink
Avoid generating NaNs in UnwoundPathSum.
Browse files Browse the repository at this point in the history
Kudos to Jakub Zakrzewski for tracking down the bug.
  • Loading branch information
Kodiologist committed Nov 28, 2018
1 parent 9c4ff50 commit 945f6e7
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion include/xgboost/tree_model.h
Original file line number Diff line number Diff line change
Expand Up @@ -720,9 +720,11 @@ inline bst_float UnwoundPathSum(const PathElement *unique_path, unsigned unique_
total += tmp;
next_one_portion = unique_path[i].pweight - tmp * zero_fraction * ((unique_depth - i)
/ static_cast<bst_float>(unique_depth + 1));
} else {
} else if (zero_fraction != 0) {
total += (unique_path[i].pweight / zero_fraction) / ((unique_depth - i)
/ static_cast<bst_float>(unique_depth + 1));
} else {
assert(unique_path[i].pweight == 0);
}
}
return total;
Expand Down

0 comments on commit 945f6e7

Please sign in to comment.