Softmax in LaTeX (\text{softmax})

softmax\text{softmax}
LaTeX command
\text{softmax}
Package
Add to your preamble:\usepackage{amsmath}
Mode
Text and math mode

Where it is used

Softmax function name: maps a vector of logits to a probability distribution by exponentiating and normalizing.

Softmax is defined componentwise as \text{softmax}(z)_i = e^{z_i} / \sum_j e^{z_j}, and it closes nearly every classifier and the attention mechanism, where \text{softmax}(QK^\top/\sqrt{d_k})V. Because \text{} uses the surrounding text font, it turns italic inside theorem or emphasis environments. \operatorname{softmax} is usually the better choice: it is always upright and adds operator spacing before the parenthesis, just like \sin. A temperature parameter is written as \text{softmax}(z/T). Use \left( \right) when the argument contains a fraction. In code-heavy papers, say which axis softmax normalizes over, such as the class dimension.

Minimal compilable example

Paste this into an empty .tex file and compile it with pdfLaTeX, XeLaTeX or LuaLaTeX.

softmax(z)i=ezi∑j=1Kezj\text{softmax}(z)_i = \frac{e^{z_i}}{\sum_{j=1}^{K} e^{z_j}}
\documentclass{article}
\usepackage{amsmath}
\begin{document}
Softmax: $\text{softmax}$

\[ \text{softmax}(z)_i = \frac{e^{z_i}}{\sum_{j=1}^{K} e^{z_j}} \]
\end{document}

Related symbols

All 機械学習・AI →

Frequently asked questions

How do I write Softmax in LaTeX?
Type \text{softmax} in math mode, for example $\text{softmax}(z)_i = \frac{e^{z_i}}{\sum_{j=1}^{K} e^{z_j}}$. Load amsmath first with \usepackage{amsmath}.
Which package do I need for \text{softmax}?
\text{softmax} needs amsmath: add \usepackage{amsmath} to your preamble before the document starts.
Can I use \text{softmax} in text mode, or only in math mode?
Both. \text{softmax} compiles in running text as well as inside $...$; in a formula keep it in math mode so it gets math fonts and spacing.
Math poweredAIでLaTeXを書く

最高のAI LaTeXエディタ、Overleaf代替

Octreeは15以上の大学の研究者がAIを使って論文をより速く書くのを支援

  • AIで美しいTikZダイアグラムを生成
  • 画像をアップロードしてシームレスにLaTeXに変換
  • 論文の執筆とフォーマットに即座にサポートを取得