cross_entropy_loss

mlpractice.linear_classifier.cross_entropy_loss(probs, target_index)

Computes cross-entropy loss.

Parameters
probsnp.ndarray, shape(n_classes) or shape(batch_size, n_classes)

Array with probabilities of belonging to each of the classes.

target_indexnp.ndarray, shape(1) or shape(batch_size)

Index(indices) of the true class(es) for given sample(s).

Returns
lossfloat

Computed cross-entropy loss value.