---
title: "Categorical cross-entropy from logits"
description: "Converts unnormalized class logits into probabilities and penalizes low probability assigned to the observed target class."
canonical_url: "https://fanout.sh/labs/math-decoder/formula/categorical-cross-entropy-from-softmax"
md_url: "https://fanout.sh/labs/math-decoder/formula/categorical-cross-entropy-from-softmax.md"
last_updated: "2026-08-09"
access: "public"
---

# Categorical cross-entropy from logits

Converts unnormalized class logits into probabilities and penalizes low probability assigned to the observed target class.

## Public overview

Cross-entropy loss of logits z and target y equals the negative sum over classes i of target y i times the log of softmax z at class i.

Turn scores into probabilities, keep the log probability relevant to the target distribution, and make confident mistakes expensive.

The summation is the outer reduction, while softmax and logarithm transform each class score before aggregation.

This is an objective definition. Implementations usually fuse softmax and log-sum-exp for numerical stability rather than computing probabilities first.

---
This representation contains public Fanout content only. Protected Pro lessons, account data, billing, checkout, and pricing are not included.

Browse the public content map: https://fanout.sh/sitemap.md
