我在使箭头与圆角矩形匹配时遇到了一些困难,这可能吗?这是 c7 到 rect_rnn 的连接
\begin{tikzpicture}[node distance=0.6cm and 0.4cm]
\node (rect_rnn) [rectangle, draw=black, ultra thick, minimum height=2cm, minimum width=3cm, fill=green, fill opacity=0.2,rounded corners=.55cm] at (0,0) {};
\node (tanh_rnn) [draw=black, fill=yellow!20, rectangle, rounded corners=0.15cm] at (0,0) {tanh};
\node (in_rnn) [below = of rect_rnn, circle, draw=black, thick, fill=blue!20, xshift=-1.2cm] {$x_{t}$};
\node (out_rnn) [above = of rect_rnn, circle, draw=black, thick, fill=blue!20, xshift=1.2cm] {$h_{t}$};
\node (c1) [inner sep=0, minimum size=0,above = of in_rnn, yshift=0.3cm] {};
\node (c2) [inner sep=0, minimum size=0] at (tanh_rnn |- c1.base) {};
\node (c1_5) [inner sep=0, minimum size=0] at ($(c1)!0.5!(c2)$) {};
\node (c3) [inner sep=0, minimum size=0,below = of out_rnn, yshift=-0.3cm] {};
\node (c4) [inner sep=0, minimum size=0] at (tanh_rnn |- c3.base) {};
\node (c5) [inner sep=0, minimum size=0] at (c1 |- c4.base) {};
\node (c6) [inner sep=0, minimum size=0] at (c1_5 |- c4.base) {};
\node (c7) [left =1cm of c5, inner sep=0, minimum size=0] {};
\node (c8) [right =1cm of c3, inner sep=0, minimum size=0] {};
\draw[-, line width = 0.3mm] (c7) -- (c5);
\draw[->, line width = 0.5mm] (c7.east) -- (c7.east-| rect_rnn.west);
\draw[-, line width = 0.3mm, rounded corners] (in_rnn) -- (c1) -- (c2);
\draw[->, line width = 0.3mm] (c2) -- (tanh_rnn);
\draw[-, line width = 0.3mm] (tanh_rnn) -- (c4) -- (c3);
\draw[->, line width = 0.3mm] (c3) -- (out_rnn);
\draw[-, line width = 0.3mm, rounded corners] (c5) -- (c6) -- (c1_5);
\draw[->, line width = 0.5mm] (c3) -- (c8);
\end{tikzpicture}
此外,连接是否可以是圆形的?这里我指的是我制作的隐藏节点,在绿色矩形内有一条路径。
如果你在这个页面向下滚动一点,就会看到类似于标准 RNN 图中重复模块的东西https://colah.github.io/posts/2015-08-Understanding-LSTMs/
答案1
这和你问的类似,但我不会使用这种策略。你可以使用intersections
和 使用来匹配边界backgrounds
,以使 Ti钾Z 很欣赏您使用的不透明度。
\documentclass[tikz,border=3.14mm]{standalone}
\usetikzlibrary{positioning,calc,intersections,backgrounds}
\begin{document}
\begin{tikzpicture}[circ/.style={circle, draw=black, thick,
fill=blue!20},>=stealth]
\path node[circ] (x_t) {$x_t$} (2.2,3.5) node[circ] (h_t) {$h_t$}
($(x_t)!0.5!(h_t)$)
node[draw=black, fill=yellow!20, rectangle, rounded corners=0.15cm]
(tanh_rnn) {tanh};
\draw[<-,line width = 0.3mm,rounded corners] (tanh_rnn) -- ++ (0,-0.8) -|
(x_t) coordinate[pos=0.27] (aux1);
\draw[->,line width = 0.3mm,rounded corners] (tanh_rnn) -- ++ (0,0.7) -|
(h_t) coordinate[pos=0.5] (aux2);
\node[rectangle, draw=black, ultra thick, minimum
height=2cm, minimum width=3cm, fill=green, fill
opacity=0.8,rounded corners=.55cm,name path=wild west] (rect_rnn) at (tanh_rnn) {};
\begin{scope}[on background layer]
\draw[->,line width = 0.3mm,rounded corners,name path global=l]
([xshift=-2em]rect_rnn.west|-aux2) coordinate (l) -| (aux1);
\draw[line width = 0.3mm,name path global=r] ([xshift=-2em]aux2) -- ([xshift=2em]rect_rnn.east|-aux2)
coordinate (r);
\end{scope}
\draw[->, line width = 0.5mm,name intersections={of=wild west and l}]
(l) -- (intersection-1);
\draw[->, line width = 0.5mm,name intersections={of=wild west and r}]
(intersection-1)--(r);
\end{tikzpicture}
\end{document}