% \documentclass[tikz,14pt,border=10pt]{standalone}
% 
% \usepackage{verbatim}
% \usepackage{bm}
% 
% \usetikzlibrary{%
%   arrows,%
%   shapes.misc,% wg. rounded rectangle
%   shapes.arrows,%
%   chains,%
%   matrix,%
%   positioning,% wg. " of "
%   scopes,%
%   decorations.pathmorphing,% /pgf/decoration/random steps | erste Graphik
%   shadows%
% }
% \begin{document}

\definecolor{c1}{HTML}{8097e9}
\definecolor{c2}{HTML}{c6dea2}
\definecolor{c3}{HTML}{ffb200}
\definecolor{c4}{HTML}{b6b6b6}

\tikzset{
  function/.style={
    % The shape:
    rectangle,
    rounded corners=4,
    % The size:
    minimum height=6mm,
    % The border:
    thick,
    draw=black,         % 50% red and 50% black,
                                  % and that mixed with 50% white
    % The filling:
    top color=c1,              % a shading that is white at the top...
    bottom color=c1, % and something else at the bottom
    % Font
    font=\tt
  },
  vector/.style={
    % The shape:
    rounded rectangle,
    minimum size=6mm,
    % The rest
    thick,draw=black,
    top color=c2!80,
    bottom color=c2!80,
    font=\ttfamily},
  weight/.style={
    % The shape:
    rounded rectangle,
    minimum size=6mm,
    % The rest
    thick,draw=black,
    top color=c3!80,
    bottom color=c3!80,
    font=\ttfamily},
  skip loop/.style={to path={-- ++(0,#1) -| (\tikztotarget)}}
}

{
  \tikzset{vector/.append style={text height=1.5ex,text depth=.25ex}}
  \tikzset{function/.append style={text height=1.5ex,text depth=.25ex}}
}

\begin{tikzpicture}[
        point/.style={coordinate},>=stealth',thick,draw=black!90,
        tip/.style={->,shorten >=0.007pt},every join/.style={rounded corners},
        fat/.style={-, ultra thick, opacity=0.5},every join/.style={rounded corners},
        hv path/.style={to path={-| (\tikztotarget)}},
        vh path/.style={to path={|- (\tikztotarget)}},
        text height=1.5ex,text depth=.25ex % align text horizontally
    ]
    \fill [c4, rounded corners=20, draw, opacity=0.5] (-4.7,-2.0) rectangle (4.5,2.0);
    \matrix[column sep=2mm, row sep=1mm] {
      % First row
      & & \node (r) [vector] {$\bm r$};&
        \node (log) [function] {log}; & &
        \node (wr1) [function] {matmul}; & & \\

      % Second row
      & \node (abs) [function] {abs}; & & & & &
        \node (wi1) [function] {matmul};& & \node (plus) [function] {$\bm -$}; & &
        \node (exp) [function] {exp};\\

      % middle row
      \node (in) [vector] {$\bm x$}; & \node (p2) [point] {};&
      \node (clip) [point] {}; & & &
      \node (wr) [weight] {$\bm W_r$}; & \node (wi) [weight] {$\bm W_i$}; & & & & &
      \node (mul) [function] {$\bm\odot$}; & &
      \node (out) [vector] {$\bm y$};\\

      % fourth row
      & \node (0pi) [function] {0:$\pi$}; & & & & & 
        \node (wi2) [function] {matmul};& & \node (minus) [function] {$\bm +$};& &
        \node (cos) [function] {cos};\\

      % bottom row
      & & \node (k) [vector] {$\bm k$}; & &
          \node (beforewr2) [point] {}; & 
        \node (wr2) [function] {matmul}; & & & \\
    };

    { [start chain]
      \chainin (in);
      \chainin (p2) [join];
      { [start branch=rbr]
        \chainin (abs) [join];
        \chainin (r) [join=by {vh path}];
        \chainin (log) [join=by tip];
        { [start branch=rbrup]
          \chainin (wr1) [join=by tip];
          \chainin (plus) [join=by {tip, hv path}];
        }
        { [start branch=rbrdown]
          \chainin (wi2) [join=by {vh path, tip}];
          \chainin (minus) [join=by tip];
        }
        \chainin (plus);
        \chainin (exp) [join=by tip];
        \chainin (mul) [join=by {hv path,tip}];
      }
      { [start branch=kbr]
        \chainin (0pi) [join];
        \chainin (k) [join=by {vh path}];
        \chainin (beforewr2) [join];
        { [start branch=kbrdown]
          \chainin (wr2) [join=by tip];
          \chainin (minus) [join=by {hv path,tip}];
        }
        { [start branch=kbrup]
          \chainin (wi1) [join=by {vh path,tip}];
          \chainin (plus) [join=by tip];
        }
        \chainin (minus);
        \chainin (cos) [join=by tip];
        \chainin (mul) [join=by {hv path,tip}];
        \chainin (out) [join=by tip];
      }
    }

    { [start chain]
      \chainin (wr2);
      \chainin (wr) [join=by fat];
      \chainin (wr1) [join=by fat];
    }

    { [start chain]
      \chainin (wi2);
      \chainin (wi) [join=by fat];
      \chainin (wi1) [join=by fat];
    }


\end{tikzpicture}

% \end{document}
