Source: https://goodhandover.co.uk/tools/softmax-calculator/

[Computer science maths](https://goodhandover.co.uk/tools/computer-science-maths/#year-3) / Year 3

🔒 Files never leave your device

# Softmax and cross-entropy calculator

Turn logits into probabilities and measure the loss for a target class. Your inputs stay on your device.

## Set up your task

Ready. Processing stays in this browser.

Files and text stay on your device. [Privacy details](https://goodhandover.co.uk/privacy/).

 

## How to use Softmax and cross-entropy calculator

Turn logits into probabilities and measure the loss for a target class. The pre-filled problem gives you a worked starting point. Compare the response with your own working before trying the self-check below.

 

- Check the example inputs: Logits in class order, Target position (starts at 1).

- Change the inputs for your problem. Results update as you type, so finish entering the values before copying an answer.

- Use the working to check an intermediate value or assumption. Then change the example as suggested in the self-check and compare the result.

 

## Supported inputs and limits

Use one to 64 real logits and a target class position starting at 1. The loss is reported in nats using natural logarithms.

 

## How it works

Softmax turns real scores called logits into class probabilities. It exponentiates every score and divides by the sum. Higher logits give larger probabilities. Cross-entropy for a single target class measures the negative natural logarithm of the probability assigned to that target.

Adding the same value to all logits leaves their softmax probabilities unchanged, because it multiplies the numerator and denominator by the same factor. Subtracting the largest logit before exponentiating uses this property to avoid overflow. The loss is calculated from shifted logits so it can remain finite when displayed probabilities round to zero.

 

## Example

Run the pre-filled example. Its first result is “Cross-entropy loss: 0.693147181 nats”.

Logits in class order

1000 1000

Target position (starts at 1)

1

Cross-entropy loss: 0.693147181 nats
Softmax probabilities: 0.5  0.5
Target class: 1
Subtract the largest logit before taking exponentials.

 

## Questions about Softmax and cross-entropy calculator

### What does target position 1 mean?

It refers to the first logit, counting from 1. This is different from code that indexes an array starting at zero.

### Does a large logit always give a probability near one?

Relative differences matter. Two equally large logits still share the probability mass equally if they are the only classes.

### Add 100 to both example logits.

The probabilities stay at one half each, and the loss stays at the natural logarithm of two.

 
 

## Related tools

[Year 3: Advanced and applied maths](https://goodhandover.co.uk/tools/computer-science-maths/#year-3)

- [Bernoulli naive Bayes calculator](https://goodhandover.co.uk/tools/naive-bayes-calculator/)

- [Gradient descent calculator](https://goodhandover.co.uk/tools/gradient-descent-calculator/)

- [ROC AUC calculator](https://goodhandover.co.uk/tools/roc-auc-calculator/)

- [2 × 2 eigenvalue calculator](https://goodhandover.co.uk/tools/eigenvalue-calculator/)

 

Last updated 24 November 2026
