Weight Matrix in LaTeX (\mathbf{W})

W\mathbf{W}
LaTeX command
\mathbf{W}
Package
No package needed: built into LaTeX
Mode
Math mode only

Where it is used

Bold upright W, the conventional notation for a weight matrix in a neural network layer.

Bold capitals denote matrices and bold lowercase letters denote vectors, so a dense layer is \mathbf{y} = \mathbf{W}\mathbf{x} + \mathbf{b}, with layer-specific weights written \mathbf{W}^{(l)} or \mathbf{W}_l. \mathbf produces upright bold Latin letters; it does not bold Greek letters or most symbols, so use \boldsymbol or \bm for \boldsymbol{\Sigma} or a bold \theta. Many deep learning papers drop the bold entirely and write W; choose one convention and keep it throughout. The transpose is usually \mathbf{W}^\top, which reads more cleanly than ^T.

Minimal compilable example

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

hl+1=σ(Wlhl+bl)\mathbf{h}_{l+1} = \sigma(\mathbf{W}_l \mathbf{h}_l + \mathbf{b}_l)
\documentclass{article}
\begin{document}
Weight Matrix: $\mathbf{W}$

\[ \mathbf{h}_{l+1} = \sigma(\mathbf{W}_l \mathbf{h}_l + \mathbf{b}_l) \]
\end{document}

Related symbols

All التعلم الآلي والذكاء الاصطناعي →

Frequently asked questions

How do I write Weight Matrix in LaTeX?
Type \mathbf{W} in math mode, for example $\mathbf{h}_{l+1} = \sigma(\mathbf{W}_l \mathbf{h}_l + \mathbf{b}_l)$. It works in plain LaTeX without loading any package.
Which package do I need for \mathbf{W}?
None. \mathbf{W} is part of standard LaTeX, so it compiles with nothing in the preamble but the document class.
Can I use \mathbf{W} in text mode, or only in math mode?
Only in math mode. Outside $...$ LaTeX stops with "Missing $ inserted", so write $\mathbf{W}$ in running text.
Math poweredاكتب LaTeX باستخدام الذكاء الاصطناعي

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

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

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