ag_cross_entropy_loss: Categorical Cross-Entropy loss

View source: R/autograd.R

ag_cross_entropy_lossR Documentation

Categorical Cross-Entropy loss

Description

Generic CE: -sum(target * log(pred)) / batch_size. The gradient w.r.t. pred is -target / pred / n. Use ag_softmax_cross_entropy_loss() for the numerically stable combined softmax + CE (fused gradient (p - y) / n).

Usage

ag_cross_entropy_loss(pred, target)

Arguments

pred

ag_tensor [classes, batch_size] probabilities (any, not just softmax)

target

matrix [classes, batch_size] one-hot (or soft) labels

Value

scalar ag_tensor


ggmlR documentation built on July 14, 2026, 1:08 a.m.