softmax_with_cross_entropy

mlpractice.linear_classifier.softmax_with_cross_entropy(predictions, target_index)

Computes softmax and cross-entropy loss for model predictions, including the gradient.

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

Classifier output.

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.

d_predictionsnp.ndarray

Array, with the same shape as predictions. Gradient of loss value with respect to predictions.