pymlkit
API reference

Losses

HalfMSE and CrossEntropy.

Losses is an enum passed to set_loss.

python
from pymlkit import Losses

HalfMSE

Half the mean squared error, ½ · (ŷ − y)². The ½ cancels the 2 in the derivative. This is the default and suits regression and sigmoid outputs.

CrossEntropy

Cross-entropy for classification. Pair it with a Softmax output layer and one-hot targets.

python
model = Network(4)
model.add_dense(16, Activations.ReLU)
model.add_dense(3, Activations.Softmax)
model.set_loss(Losses.CrossEntropy)

# three classes -> one-hot targets, flattened
train_y = [1, 0, 0,   0, 1, 0,   0, 0, 1]