Skip to content

Commit

Permalink
[onert-micro] Fix grad of Sparse Cross Entropy Loss
Browse files Browse the repository at this point in the history
- Fix wrong sparse CCE loss grad computation

ONE-DCO-1.0-Signed-off-by: Chunseok Lee <[email protected]>
  • Loading branch information
chunseoklee committed Sep 27, 2024
1 parent 06a536b commit 5de0859
Showing 1 changed file with 8 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,13 @@ void SparseCrossEntropy::calculateErrorBackpropagation(const uint32_t flat_size,

for (uint32_t i = 0; i < flat_size; ++i)
{
output_grad[i] = (calculated_data[i] + float(10.0e-32)) - (i == label);
if (i == label)
{
output_grad[i] = -1.0 / (calculated_data[i] + float(10.0e-20));
}
else
{
output_grad[i] = 0.0;
}
}
}

0 comments on commit 5de0859

Please sign in to comment.