我需要关于如何绘制神经网络图的指点

我需要关于如何绘制神经网络图的指点

请帮我画一下这个图。我在 TikZ 上练习,但是太难了。

在此处输入图片描述

我不知道应该使用哪个库,矩阵/链还是其他什么?我也不知道如何绘制像图片这样的圆形连接器。请帮我画这幅图。

答案1

一种使用 TikZ 的选项;唯一可能值得评论的点是使用路径arc和装饰生成的弯曲箭头:

\documentclass{article}
\usepackage{amsmath}
\usepackage{tikz}
\usetikzlibrary{positioning,decorations.markings,calc}

\begin{document}

\begin{tikzpicture}[
node distance=2cm and 1cm,
mynode/.style={
  draw,
  text width=6cm,
  align=center,
  text height=3ex,
  text depth=1.5ex,
}
]
\node[mynode] (out) {Output};
\node[mynode,text width=4cm,below=of out] (sh) {State/Hidden};
\node[mynode,below=of sh] (in) {Input};

\draw[-latex] (in) -- node[fill=white] {Weights $V$}(sh);
\draw[-latex] (sh) -- node[fill=white] {Weights $W$}(out);

\begin{scope}[radius=1.2cm]
\draw[
decoration={
  markings,
  mark=at position 0.999 with {\arrow{latex}}
  },
postaction=decorate
]
(sh.16) arc[start angle=160,end angle=-150] (sh.-17);

\node[xshift=1.3cm,anchor=west,text width=2.8cm,align=center] 
at (sh.east) {Weights $U$\\(dealyed)};
\end{scope}

\node[anchor=west,text width=4cm] at ([xshift=4cm] $ (in.north)!0.5!(sh.south)$ ) {%
        $\displaystyle
        \begin{aligned}
            &y_j(t)=f(\mathrm{net}_j)\\
            &\mathrm{net}_j(t)=\sum_i v_{ji} x_i(t)+\sum_h u_{jh}y_h(t-1)+\theta_j
        \end{aligned}$
};

\node[anchor=west,text width=4cm] at ([xshift=4cm] $ (sh.north)!0.5!(out.south)$ ) {%
        $\displaystyle
        \begin{aligned}
            &y_k(t)=g(\mathrm{net}_k)\\
            &\mathrm{net}_k(t)=\sum_j w_{kj} y_j(t)+\theta_k
        \end{aligned}$
};
\end{tikzpicture}

\end{document}

在此处输入图片描述

答案2

使用 PSTricks。只是为了好玩!

\documentclass[preview,border={15pt 15pt 170pt 15pt}]{standalone}
\usepackage{pst-node}
\usepackage{amsmath}
\usepackage{palatino}
\begin{document}
\offinterlineskip
\psmatrix[mnode=r,rowsep=2.5cm]
    \psframebox{\parbox{4cm}{\centering Output}}\\
    \psframebox{\parbox{3cm}{\centering State/hidden}}\\
    \psframebox{\parbox{5cm}{\centering Input}}
\endpsmatrix
\psset{arrows=->}
% bottom
\ncline{3,1}{2,1}\ncput*{Weights V}
\nbput[npos=.3,labelsep=1.5]{%
    \parbox{4cm}{%
        $\displaystyle
        \begin{aligned}
            &y_j(t)=f(net_j)\\
            &net_j(t)=\sum_i v_{ji} x_i(t)+\sum_h u_{jh}y_h(t-1)+\theta_j
        \end{aligned}$
}}
% middle
\ncloop[angleA=90,angleB=-90,arm=.5,linearc=.3,loopsize=1.5,offset=-1]{2,1}{2,1}
\naput{\parbox{2cm}{Weights U\\\centering(delayed)}}
% top
\ncline{2,1}{1,1}\ncput*{Weights W}
\nbput[npos=.6,labelsep=1.5]{%
    \parbox{4cm}{%
        $\displaystyle
        \begin{aligned}
            &y_k(t)=g(net_k)\\
            &net_k(t)=\sum_j w_{kj} y_j(t)+\theta_k
        \end{aligned}$
}}
\end{document}

在此处输入图片描述

相关内容