ag_softmax_cross_entropy_loss: Fused softmax + cross-entropy loss (numerically stable)

View source: R/autograd.R

ag_softmax_cross_entropy_lossR Documentation

Fused softmax + cross-entropy loss (numerically stable)

Description

Combines softmax and CE in one op using the fused gradient (p - y) / n. More numerically stable than chaining ag_softmax + ag_cross_entropy_loss. Use this when your last layer outputs raw logits.

Usage

ag_softmax_cross_entropy_loss(logits, target)

Arguments

logits

ag_tensor [classes, batch_size] raw (pre-softmax) scores

target

matrix [classes, batch_size] one-hot labels

Value

scalar ag_tensor


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