Skip to content

    Cross-Entropy Loss

    AI fundamentals & modelsCross entropy loss functionCross entropyCross Entropy
    Reading time: 2 min.Editorially reviewed on:

    Definition

    Loss function that compares predicted class distributions to target classes or target distributions.

    For a unique target class, cross entropy penalises a low predicted probability for that class. For multiclass classification, PyTorch CrossEntropyLoss expects unnormalized logits and processes the necessary normalization internally. Training loss and practical classification quality are different sizes.

    Simply explained

    A self-confident wrong answer gets a stronger correction than a suitable prediction.

    Why it matters in practice

    Relevant for training classifiers and predicting tokens.

    Example from business

    Example scenario: A ticket model learns concern classes based on labeled examples with cross-entropy loss.

    Limits and pitfalls

    • Double-apply Softmax before PyTorch CrossEntropyLoss; false label types or shapes; ignore class imbalance and data errors.

    Origin & history

    Based on concepts of information theory and became a standard loss function in training probabilistic classifiers.

    Use in mid-sized companies

    • Ensure label definition and data quality; additionally evaluate confusion matrix, recall and technical error costs on independent data.

    Frequently asked questions

    Is smaller loss always higher accuracy?

    No. Are logits probabilities? No. Does every classification require the same loss variant? No.

    Sources

    Source check: 10/09/2026. Definition and documented classification verified; examples describe possible applications.

    Editorially reviewed on:

    On this page

    Next step

    Put knowledge into practice