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 التعلم الآلي والذكاء الاصطناعي →

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 poweredاكتب LaTeX باستخدام الذكاء الاصطناعي

أفضل محرر LaTeX بالذكاء الاصطناعي، بديل Overleaf

يساعد Octree الباحثين من أكثر من 15 جامعة على كتابة أوراق البحث بشكل أسرع باستخدام الذكاء الاصطناعي

  • أنشئ رسوم TikZ جميلة باستخدام الذكاء الاصطناعي
  • ارفع صورة وحولها إلى LaTeX بسلاسة
  • احصل على مساعدة فورية في كتابة وتنسيق أوراق البحث