linear_softmax

mlpractice.linear_classifier.linear_softmax(X, W, target_index)

Performs linear classification and returns loss and gradient with respect to W.

Parameters
Xnp.ndarray, shape(batch_size, n_features)

Batch of images.

Wnp.ndarray, shape(n_features, n_classes)

Weights.

target_indexnp.ndarray, shape(batch_size)

Indices of the true classes for given samples.

Returns
lossfloat

Computed cross-entropy loss value.

gradientnp.ndarray, shape(n_features, n_classes)

Gradient of loss with respect to weights.