% superfig golden example 1 -- one horizontal paper-figure pipeline. % Main path is input -> model -> prediction. Loss is a side object, not a % station on the forward path. % ../scripts/build.sh pipeline.tex \documentclass[border=10pt]{standalone} \usepackage[cjk]{superfig} \sfsetrole{input}{sfTeal} \sfsetrole{model}{sfOrange} \sfsetrole{loss}{sfCoral} \sfsetrole{output}{sfViolet} \begin{document} \begin{tikzpicture} \sfstage{SA}{推理流程:一次前向} \sfrow{R1}{16mm} \sfnode[role=input]{x}{输入 $x$}{16mm}{12mm} \sfconn{e1}{预处理} \sfnode[role=model]{f}{模型 $f_\theta$}{18mm}{12mm} \sfconn{e2}{logits} \sfnode[role=output]{y}{预测 $\hat y$}{16mm}{12mm} \sfrowend % Loss compares the prediction with the target; it is not on the main path. % Hang it below ŷ with enough shaft that no caption sits on the arrow. \sfnode[role=loss, at={($(y.south)+(0,-22mm)$)}]{s}{损失 $L$}{14mm}{12mm} \sfarrowlabel{y.south}{s.north}{$L(\hat y,y)$} \sflane{R1} \sfcaption{x}{$x$}{原始输入} \sfcaption{f}{$f_\theta$}{可学习参数} \sfnolane \sfcaption{s}{$L$}{与真值比较} \sfbbox{all} \sftopformula{F}{% $x \;\xrightarrow{\;f_\theta\;}\; \hat y,\qquad \min_\theta\; L\bigl(f_\theta(x),\,y\bigr)$} \sfmeaningbox{mb}{96mm}{all} {一次从输入到预测的前向;损失在预测之后单独计算} {数据、模型参数、预测、损失} {预处理后送入模型;模型产生 logits 得到预测;损失比较预测与真值,梯度再回到参数} \sfsignature{推理流程示意}{mb} \end{tikzpicture} \end{document}