← browse the library
Training pipeline (with loss/optimizer loop) preview
template

Training pipeline (with loss/optimizer loop)

Supervised training loop: forward path Dataset -> Model -> Loss (with labels feeding the loss), and a backward path Loss -> Optimizer -> Model for gradients and the weight update. Parametric spacing and labels.

This template ships an edit contract (in its meta.json) that the repo-wide using-opentikz skill reads to edit it reliably — the parameters and safe operations are listed below.

idtraining-pipeline
typetemplate
domainml
venueNeurIPS, ICML, CVPR, ACL
requirestikz, arrows.meta, positioning
licenseCC0-1.0
authorOpenTikZ contributors

trainingpipelinelossoptimizerbackpropgradient descentloopsupervised learningarchitecture

Download SVG
template.tex
\documentclass[border=6pt]{standalone}

% --- packages (mirror these in template.meta.json "requires") ---
\usepackage{tikz}
\usetikzlibrary{positioning, arrows.meta}

% --- palette (canonical source: reference/color-palettes/color-palettes.md; light variant) ---
\definecolor{otblue}{HTML}{0072B2}
\definecolor{otorange}{HTML}{E69F00}
\definecolor{otteal}{HTML}{009E73}
\definecolor{otpurple}{HTML}{CC79A7}
\definecolor{otgray}{HTML}{5A5A5A}

\begin{document}
% ==== parameters (edit these) ============================================
\def\nodesep{1.2}   % horizontal gap between forward stages (cm)
\def\loopdrop{1.6}  % how far below the model the optimizer sits (cm)
\def\boxminw{1.9}   % minimum stage width (cm)
\def\boxminh{1.0}   % minimum stage height (cm)
% labels
\def\datalabel{Dataset}
\def\modellabel{Model}
\def\losslabel{Loss}
\def\optlabel{Optimizer}
\def\labelslabel{Labels $y$}
\def\predlabel{$\hat{y}$}
\def\gradlabel{gradients $\nabla\mathcal{L}$}
\def\updatelabel{update $\theta$}
% =========================================================================

\begin{tikzpicture}[
    node distance=\nodesep cm,
    >={Stealth[length=2.4mm]},
    stage/.style={
      draw=otgray!55, line width=0.7pt, rounded corners=3pt, align=center,
      minimum width=\boxminw cm, minimum height=\boxminh cm, font=\sffamily\small,
    },
    io/.style={stage, fill=otgray!12},
    fwd/.style={draw=otgray!70, line width=0.9pt, ->},
    back/.style={draw=otpurple!85!black, line width=1.0pt, ->},
    elabel/.style={font=\sffamily\footnotesize, text=otgray},
    blabel/.style={font=\sffamily\footnotesize, text=otpurple!85!black},
  ]

  % --- forward path: Dataset -> Model -> Loss, with Labels feeding the Loss ---
  \node[io] (data) {\datalabel};
  \node[stage, fill=otblue!18, right=of data] (model) {\modellabel};
  \node[stage, fill=otorange!20, right=of model] (loss) {\losslabel};
  \node[io, above=of loss] (labels) {\labelslabel};

  % --- optimizer sits below the model on the return path ---
  \node[stage, fill=otteal!18, below=\loopdrop cm of model] (opt) {\optlabel};

  % forward arrows
  \draw[fwd] (data) -- (model);
  \draw[fwd] (model) -- (loss) node[midway, above, elabel] {\predlabel};
  \draw[fwd] (labels) -- (loss);

  % --- training loop: backprop gradients then the optimizer update ---
  \draw[back] (loss.south) |- (opt.east)
    node[pos=0.65, above, blabel] {\gradlabel};
  \draw[back] (opt.north) -- (model.south)
    node[midway, right, blabel] {\updatelabel};

\end{tikzpicture}
\end{document}

Edit contract — how the AI edits this template

using-opentikz skill →
Parameters & safe edit operations

Parameters

\nodesephorizontal gap between forward stages (tikz node distance) default 1.2
\loopdrophow far below the model the optimizer sits default 1.6
\boxminwminimum stage width default 1.9
\boxminhminimum stage height default 1.0
\datalabeldataset stage label (use \\ for two lines)
\modellabelmodel stage label
\losslabelloss stage label
\optlabeloptimizer stage label
\labelslabelground-truth labels node text (math allowed)
\predlabelprediction edge label on model->loss
\gradlabelgradients edge label on the backward path
\updatelabelweight-update edge label on the backward path

Node naming

fixed semantic node names: (data) (model) (loss) (labels) (opt); give any added stage a clear semantic name

Operations

  • rename-stage — edit the matching label macro; use \\ for two-line labels
  • insert-forward-stage — add a node right=of the previous stage with a semantic name and re-point the forward arrows
  • recolor — change the palette name on the node fill/draw or the back/blabel styles; never a hex/stock color
  • drop-optimizer — delete the (opt) node and its two back arrows; replace with a single curved return arrow from (loss) to (model)
  • add-validation-branch — add another node and connect with a fwd arrow, keeping the main loop intact

Use it

The file compiles on its own (\documentclass{standalone}). Drop it into your project and \input it, or copy the tikzpicture into your figure. Colours come from the shared palette defined in the preamble — edit those named colours, not raw hex.

Graphic content is CC0 1.0 (public domain) — reuse freely, no attribution required.