Skip to content

Commit

Permalink
[onert-micro] Fix grad of Sparse Cross Entropy Loss (#14119)
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 authored Oct 10, 2024
1 parent 36e422a commit c507999
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 c507999

Please sign in to comment.