ytm.guided.backends.act_loss.ActLoss#

class ytm.guided.backends.act_loss.ActLoss#

Bases: object

Base class for an output activation paired with a loss.

A subclass sets act ("softmax", "sigmoid" or "identity") and src, the C source of compute_loss(y, y_hat, grad, loss). Given targets y and activations y_hat for one sample, it writes the summed loss to loss and, per class, the negative gradient of the loss with respect to the pre-activation to grad. Either pointer can be NULL, then that output is skipped.