Neuralnetworks 包不允许我定义自定义标签

Neuralnetworks 包不允许我定义自定义标签

遵循这个帖子,我尝试定义以下神经网络

\usepackage{xpatch}
\makeatletter
% \linklayers have \nn@lastnode instead of \lastnode,
% patch it to replace the former with the latter, and similar for thisnode
\xpatchcmd{\linklayers}{\nn@lastnode}{\lastnode}{}{}
\xpatchcmd{\linklayers}{\nn@thisnode}{\thisnode}{}{}
\makeatother

\begin{figure}[!h]
    \centering
    \begin{neuralnetwork}
        \newcommand{\x}[2]{\ifnum #2=5 $x_n$ \else $x_#2$ \fi}
        \newcommand{\add}[2]{$+$}
        \newcommand{\act}[2]{$g$}
        \newcommand{\y}[2]{$v_#2$}
        \newcommand{\linklabelsW}[4]{\ifnum #2=5 $x_n#4$ \else $w_#2#4$ \fi}
        \inputlayer[count=5, bias=false, exclude={4}, text=\x]
        \hiddenlayer[count=1, bias=false, text=\add] 
            \linklayers[not from={4}, labels=\linklabelsW]
        \hiddenlayer[count=1, bias=false, text=\act] 
            \linklayers
        \outputlayer[count=1, text=\y] 
            \linklayers
    
        \path (L0-3) -- node{$\vdots$} (L0-5);
    \end{neuralnetwork}
\end{figure}

但是,这一直给我“未定义控制序列。\nn”错误。有什么想法可以解决这个问题吗?神经网络包没有文档,所以我自己很难调试东西。

相关内容