答案1
为什么你不在新的一年里用一个简单的 TikZ 答案来回答没有 MWE 的问题呢?
从技术上讲,此 TikZ 图形使用node
和的相关组合pic
。一些曲线是使用to[bend left]
或to[bend right]
选项绘制的。操作|-
意味着先垂直移动,然后水平移动。箭头是另一个问题;在这里我选择>=stealth
。
PS:我认为对于这样的图形来说,TikZ 比 Asymptote 更方便。
\documentclass[tikz,border=5mm]{standalone}
\begin{document}
\begin{tikzpicture}[>=stealth]
\tikzset{Xshape/.pic={\draw[red] (45:.1)--(-135:.1) (-45:.1)--(135:.1);}}
\tikzset{Sshape/.pic={
\draw[teal,line width=1pt] (35:.3) .. controls +(180:.3) and +(0:.3) .. (-145:.3);}}
\path[nodes={circle,draw,thick}]
(0,0) node[fill=pink,minimum size=10mm] (ct) {$c_t$}
(-1.5,1.25) node[fill=blue!30] (it) {$i_t$}
(-1.5,0) node (Xleft) {}
(0,-1) node (Xbelow) {}
(3,0) node (Xright) {}
(2,2) node[fill=green!50] (ot) {$o_t$}
(2,0) node[minimum size=7mm] (Sright) {}
(-2.5,0) node[minimum size=7mm] (Sleft) {}
(0,-2) node[fill=yellow] (ft) {$f_t$}
;
\path
(Xleft.center) pic{Xshape}
(Xright.center) pic{Xshape}
(Xbelow.center) pic{Xshape}
(Sleft.center) pic{Sshape}
(Sright.center) pic{Sshape}
(ct) +(30:.5) node[right,scale=.8]{Cell}
(ot) node[right=4mm,scale=.8]{Output Gate}
(it) node[right=4mm,scale=.8]{Input Gate}
(ft) node[right=4mm,scale=.8]{Forget Gate}
;
\foreach \p/\q in {ct/Sright,Sright/Xright,ct/ot,ot/Xright,ct/it,Sleft/Xleft,Xleft/ct,ft/Xbelow,it/Xleft}
\draw[->] (\p)--(\q);
\draw[->] (Xright)--+(0:2) node[above left]{$h_t$};
\draw[<-] (Sleft)--+(180:2.25) node[above right]{$x_t$};
\draw[->] (Sleft)+(180:.8) |-(ot);
\draw[->] (Sleft)+(180:.8) |-(ft);
\draw[->] (Sleft)+(180:.8) |-(it);
\draw[->] (ct) to[bend left] (Xbelow.20);
\draw[->] (Xbelow.160) to[bend left] (ct);
\draw[->] (ct.210) to[bend right=80] (ft.150);
\draw[very thick] (-4,-2.5) rectangle (4.25,2.5);
\end{tikzpicture}
\end{document}