Sunday, December 11, 2022

SparseCategorialCrossentropy or CategoricalCrossEntropy

 

Tensorflow has two potential formats for target values and the selection of the loss defines which is expected.

  • SparseCategorialCrossentropy: expects the target to be an integer corresponding to the index. For example, if there are 10 potential target values, y would be between 0 and 9.
  • CategoricalCrossEntropy: Expects the target value of an example to be one-hot encoded where the value at the target index is 1 while the other N-1 entries are zero. An example with 10 potential target values, where the target is 2 would be [0,0,1,0,0,0,0,0,0,0].

No comments:

Post a Comment