0

I am having some difficulties in making my arrow match the rounded rectangle, is this possible? This is the connection c7 to 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}

Furthermore, would it be possible for the connections to be round? Here I mean hidden nodes that I have made, to have a path inside the green rectangle.

Something like the repeating module in a standard RNN figure, if you scroll a bit down in this page https://colah.github.io/posts/2015-08-Understanding-LSTMs/

1
  • 2
    Welcome to TeX.SE! Please make your code snippet compilable! Then we do not have to guess what you are doing ...
    – Mensch
    Commented Jul 30, 2019 at 19:15

1 Answer 1

1

This does something along the lines you are asking but I would not use this strategy. You can match the boundary by using intersections and use backgrounds to make TikZ appreciate the opacity you're using.

\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}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .