神经网络插图

神经网络插图

我正在尝试使用该包创建一个神经网络图示neuralnetwork。我想单独标记我的偏置神经元。

现在我有代码:

\documentclass[fleqn,11pt,a4paper,final]{article} 
\usepackage{neuralnetwork}
\begin{document}

\begin{figure}[h!]
\begin{neuralnetwork}[height=1.5 ,maintitleheight=1cm,layertitleheight=3cm]
  \newcommand{\nodetextx}[2]{$x_{#2}$}
  \newcommand{\nodetextz}[2]{$y$}
  \newcommand{\nodetexth}[2]{$h_{#2,1}$}
  \newcommand{\nodetexthto}[2]{$h_{#2,2}$}
  \inputlayer[count=3, title={Input-lag}, text=\nodetextx]
  \hiddenlayer[count=5, title={Skjult lag}, text=\nodetexth]
  \linklayers
  \hiddenlayer[count=4, title={Skjult lag}, text=\nodetexthto]
   \linklayers
  \outputlayer[count=1, title={Output-lag}, text=\nodetextz] 
  \linklayers
\end{neuralnetwork}
\end{figure}
\end{document}

这给了我以下的说明: 在此处输入图片描述

我想要x_0标记 -神经元\textbf{c_1}h_{0,1}标记 -神经元\textbf{c_2},最后h_{0,2}标记 -神经元b。我该怎么做?

非常感谢您的帮助。谢谢

答案1

这可能比它需要的更复杂,但它似乎确实有效。

在此处输入图片描述

\documentclass[border=5mm]{standalone}
\usepackage{xpatch}
\usepackage{neuralnetwork}
% this is the command that prints the first node in a layer
%    \node[bias neuron] (L\nn@layerindex-0) at (\nn@node@xb, \nn@node@y) {\nn@nodecaption{\nn@layerindex}{0}};
% we want to modify the last bit to use the loop macro \nn@nodeindex instead of 0
\makeatletter
\xpatchcmd{\layer}{\nn@nodecaption{\nn@layerindex}{0}}{\nn@nodecaption{\nn@layerindex}{\nn@nodeindex}}{}{}

% define the nodeindex to be zero initially
\newcommand\nn@nodeindex{0}

\newcommand{\nodetextx}[2]{
  \ifnum \nn@nodeindex=0
     $\mathbf{c_1}$
  \else
     $x_{#2}$
  \fi
}

\newcommand{\nodetextz}[2]{$y$}

\newcommand{\nodetexth}[2]{
  \ifnum \nn@nodeindex=0
    $\mathbf{c_2}$
  \else
    $h_{#2,1}$
  \fi
}

\newcommand{\nodetexthto}[2]{
  \ifnum \nn@nodeindex=0
    $b$
  \else
    $h_{#2,2}$
  \fi
}
\makeatother

\begin{document}
\begin{neuralnetwork}[height=1.5 ,maintitleheight=1cm,layertitleheight=3cm]
  \inputlayer[count=3, title={Input-lag}, text=\nodetextx]
  \hiddenlayer[count=5, title={Skjult lag}, text=\nodetexth]
  \linklayers
  \hiddenlayer[count=4, title={Skjult lag}, text=\nodetexthto]
  \linklayers
  \outputlayer[count=1, title={Output-lag}, text=\nodetextz] 
  \linklayers
\end{neuralnetwork}
\end{document}

答案2

解决

在此处输入图片描述

我想为我的解决方案做出贡献。通过添加标签来解决问题bias = false。我不知道偏见是什么,我在另一个博客上找到了它,它有效。

\documentclass[border=5mm]{standalone}
\usepackage{xpatch}
\usepackage{neuralnetwork}
  % this is the command that prints the first node in a layer
%    \node[bias neuron] (L\nn@layerindex-0) at (\nn@node@xb, \nn@node@y) {\nn@nodecaption{\nn@layerindex}{0}};
% we want to modify the last bit to use the loop macro \nn@nodeindex instead of 0
\makeatletter
\xpatchcmd{\layer}{\nn@nodecaption{\nn@layerindex}{0}}{\nn@nodecaption{\nn@layerindex}{\nn@nodeindex}}{}{}

% define the nodeindex to be zero initially
\newcommand\nn@nodeindex{0}

\newcommand{\nodetextx}[2]{
  \ifnum \nn@nodeindex=0
     $\mathbf{c_1}$
  \else
     $i_{#2}$
  \fi
}

\newcommand{\nodetextz}[2]{$o_1$}

\newcommand{\nodetexth}[2]{
  \ifnum \nn@nodeindex=0
    $\mathbf{c_2}$
  \else
    $h_{1, #2}$
  \fi
}

\newcommand{\nodetexthto}[2]{
  \ifnum \nn@nodeindex=0
    $b$
  \else
    $h_{2, #2}$
  \fi
}
\makeatother

\begin{document}
\begin{neuralnetwork}[height=1.5 ,maintitleheight=1cm,layertitleheight=5cm]
  \inputlayer[count=5, bias=false, title={Input}, text=\nodetextx]

  \hiddenlayer[count=10, bias=false, title={Oc1}, text=\nodetexth]
  \linklayers
  \hiddenlayer[count=10, bias=false, title={Oc2}, text=\nodetexthto]
  \linklayers

  \outputlayer[count=1, title={Output}, text=\nodetextz] 
  \linklayers
\end{neuralnetwork}
\end{document}

相关内容