Compute the categorical cross-entropy loss of one example from its raw logits and the index of the true class, using the log-sum-exp trick for stability.
Implement solve(logits, target).
Returns. Return a non-negative float: log∑jezj−ztarget.
Example 1
Input:
solve([1.0, 2.0, 3.0], 2)
Output:
0.407606
Example 2
Input:
solve([5.0], 0)
Output:
0.0
Example 3
Input:
solve([1000.0, 0.0], 0)
Output:
0.0
No results yet
Run your code to check it against the examples, or submit to run every test.