Commit 9bb1b6f7 authored by Adrià Arrufat's avatar Adrià Arrufat Committed by Davis E. King
Browse files

Fix focal loss

The loss value should reflect the impact of the gamma parameter, as well.
parent 5cb03656
......@@ -850,14 +850,14 @@ namespace dlib
{
const float temp = log1pexp(-out_data[idx]);
const float focus = std::pow(1 - g[idx], gamma);
loss += y * scale * temp;
loss += y * scale * temp * focus;
g[idx] = y * scale * focus * (g[idx] * (gamma * temp + 1) - 1);
}
else
{
const float temp = -(-out_data[idx] - log1pexp(-out_data[idx]));
const float focus = std::pow(g[idx], gamma);
loss += -y * scale * temp;
loss += -y * scale * temp * focus;
g[idx] = -y * scale * focus * g[idx] * (gamma * temp + 1);
}
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment