mirror of
https://github.com/davisking/dlib.git
synced 2024-11-01 10:14:53 +08:00
Fix focal loss
The loss value should reflect the impact of the gamma parameter, as well.
This commit is contained in:
parent
5cb036564c
commit
9bb1b6f712
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user