l2_regularization

mlpractice.linear_classifier.l2_regularization(W, reg_strength)

Computes L2 regularization loss on weights and its gradient.

Parameters
Wnp.ndarray, shape(n_features, n_classes)

Weights.

reg_strengthfloat

Strength of regularization.

Returns
lossfloat

L2 regularization loss.

gradientnp.ndarray, shape(n_features, n_classes)

Gradient of L2 loss value with respect to weights.