while defining losses,when to use sparse categorical loss and when to use categorical loss. kindly explain in a layman language as am new to this.if possible with an example.
Kindly have a look into this blog post for explanation about when to use sparse categorical loss and categorical loss.
Essentially, for categorical loss, you pass the ground truth as one-hot encodings, and for Sparse Categorical loss, you pass direct class indices as ground truth.
The above is with reference to Keras/TF.
In PyTorch, the
CrossEntropyLoss by default works in sparse ground truth mode.