Skip to content

NaN leaf score #19

@JordanCheney

Description

@JordanCheney

Hello,

First of all thank you for open sourcing this code. It is excellent. I'm encountering an error during training where a leaf node can receive a NaN score. After this happens, training freezes. The error has to occur in the following block of code-

if (node_idx >= nodes_n / 2) {
    // we are on a leaf node
    const int idx = node_idx - nodes_n / 2;
    double pos_w, neg_w;
    pos_w = neg_w = c.esp;
    for (int i = 0; i < pos_n; i++)
        pos_w += pos.weights[pos_idx[i]];
    for (int i = 0; i < neg_n; i++)
        neg_w += neg.weights[neg_idx[i]];

    float score = 0.5 * log(pos_w / neg_w);
    scores[idx] = isnan(score) ? 0. : score;

    return;
}

I added the NaN check above the return myself to work around the issue, but I'm not sure setting the score to 0 is the proper solution. Do you have any insight on better ways to avoid this problem?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions