Skip to content

Losses

KeyDNN exposes common loss functions as functions in the public API.

Loss functions typically accept prediction tensors and target tensors and return a scalar Tensor (or a reduced tensor, depending on configuration).


Categorical Cross Entropy Loss (cce_loss)

Return a callable Categorical Cross Entropy loss compatible with Model.fit().

Mean Squared Error Loss (mse_loss)

Return a callable MSE loss compatible with Model.fit().

Sum of Squared Errors (sse_loss)

Return a callable SSE loss compatible with Model.fit().

Binary Cross Entropy Loss (bce_loss)

Return a callable Binary Cross Entropy loss compatible with Model.fit().


Notes

  • Make sure your targets match the expected format (e.g., class indices vs one-hot vectors).
  • If a loss supports logits vs probabilities, document it clearly in the docstring.
  • If reductions are supported (e.g., mean/sum), prefer documenting the default explicitly.