Learn R Programming

ggmlR (version 0.6.1)

ag_softmax_cross_entropy_loss: 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)

Value

scalar ag_tensor

Arguments

logits

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

target

matrix [classes, batch_size] one-hot labels