loss_crossentropy: Categorical Cross-Entropy Loss

View source: R/losses.R

loss_crossentropyR Documentation

Categorical Cross-Entropy Loss

Description

Creates a categorical cross-entropy loss function object.

Usage

loss_crossentropy(epsilon = 1e-15)

Arguments

epsilon

A small positive numeric value used for numerical stability.

Value

An object of class "met_loss".

References

Bridle, J. S. (1990). Probabilistic Interpretation of Feedforward Classification Network Outputs, with Relationships to Statistical Pattern Recognition. In Neurocomputing: Algorithms, Architectures and Applications, 227–236. Springer.

Examples

loss <- loss_crossentropy()
y_true <- matrix(c(1, 0, 0, 0, 1, 0), nrow = 2, byrow = TRUE)
y_pred <- matrix(c(0.8, 0.1, 0.1, 0.2, 0.7, 0.1), nrow = 2, byrow = TRUE)
loss$fn(y_true, y_pred)

metANN documentation built on May 16, 2026, 1:06 a.m.