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 Machine Learning at AI →

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 poweredSumulat ng LaTeX gamit ang AI

Pinakamahusay na AI LaTeX Editor, Alternatibo sa Overleaf

Tinutulungan ng Octree ang mga researcher mula sa 15+ na unibersidad na sumulat ng research papers nang mas mabilis gamit ang AI

  • Gumawa ng magagandang TikZ diagrams gamit ang AI
  • Mag-upload ng larawan at i-convert ito sa LaTeX nang walang problema
  • Makakuha ng instant na tulong sa pagsulat at pag-format ng research papers