cross_entropy_sparse

cross_entropy_sparse#

class brainpy.losses.cross_entropy_sparse(predicts, targets)[source]#

Computes the softmax cross-entropy loss.

Parameters:
  • predicts – (batch, …, #class) tensor of logits.

  • targets – (batch, …) integer tensor of label indexes in {0, …,#nclass-1} or just a single integer.

Returns:

(batch, …) tensor of the cross-entropy for each entry.