figure-lstm01.tex 4.46 KB
Newer Older
曹润柘 committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17


%-----------------------------------------------

    \begin{tikzpicture}
        \setlength{\base}{0.6cm}

        \tikzstyle{wordnode} = [font=\scriptsize]
        \tikzstyle{auxnode} = [inner sep=0pt,outer sep=0pt,opacity=0,draw=red,fill=red,circle,minimum size=3pt]
        \tikzstyle{opnode} = [inner sep=0pt,outer sep=0pt,draw,fill=green!30!white,font=\scriptsize,minimum size=10pt]
        \tikzstyle{standard} = [rounded corners=5pt,thick]
        \tikzstyle{emph} = [rounded corners=5pt,thick,draw=red]
        \tikzstyle{formulanode} = [font=\scriptsize,align=left,draw=red,rectangle,fill=red!10!white,rounded corners=2pt,drop shadow]

        % Skeleton
        \begin{scope}[every label/.append style={label distance=1pt,font=\tiny,inner sep=0pt,opacity=0}]
            \coordinate (aux12) at (0,0);
zengxin committed
18
            %\node[auxnode,label={-45:12}] () at (aux12) {};
曹润柘 committed
19 20

            \coordinate (aux22) at ([yshift=\base]aux12);
zengxin committed
21
            %\node[auxnode,label={-45:22}] () at (aux22) {};
曹润柘 committed
22
            \coordinate (aux21) at ([xshift=-2\base]aux22);
zengxin committed
23
            %\node[auxnode,label={-45:21}] () at (aux21) {};
曹润柘 committed
24
            \coordinate (aux23) at ([xshift=\base]aux22);
zengxin committed
25
            %\node[auxnode,label={-45:23}] () at (aux23) {};
曹润柘 committed
26
            \coordinate (aux24) at ([xshift=\base]aux23);
zengxin committed
27
            %\node[auxnode,label={-45:24}] () at (aux24) {};
曹润柘 committed
28
            \coordinate (aux25) at ([xshift=\base]aux24);
zengxin committed
29
            %\node[auxnode,label={-45:25}] () at (aux25) {};
曹润柘 committed
30
            \coordinate (aux26) at ([xshift=\base]aux25);
zengxin committed
31
            %\node[auxnode,label={-45:26}] () at (aux26) {};
曹润柘 committed
32
            \coordinate (aux27) at ([xshift=\base]aux26);
zengxin committed
33
            %\node[auxnode,label={-45:27}] () at (aux27) {};
曹润柘 committed
34
            \coordinate (aux28) at ([xshift=\base]aux27);
zengxin committed
35
            %\node[auxnode,label={-45:28}] () at (aux28) {};
曹润柘 committed
36
            \coordinate (aux29) at ([xshift=2\base]aux28);
zengxin committed
37
            %\node[auxnode,label={-45:29}] () at (aux29) {};
曹润柘 committed
38 39

            \coordinate (aux33) at ([yshift=\base]aux23);
zengxin committed
40
            %\node[auxnode,label={-45:33}] () at (aux33) {};
曹润柘 committed
41
            \coordinate (aux34) at ([yshift=\base]aux24);
zengxin committed
42
            %\node[auxnode,label={-45:34}] () at (aux34) {};
曹润柘 committed
43
            \coordinate (aux35) at ([yshift=\base]aux25);
zengxin committed
44
            %\node[auxnode,label={-45:35}] () at (aux35) {};
曹润柘 committed
45
            \coordinate (aux37) at ([yshift=\base]aux27);
zengxin committed
46
            %\node[auxnode,label={-45:37}] () at (aux37) {};
曹润柘 committed
47 48

            \coordinate (aux45) at ([yshift=\base]aux35);
zengxin committed
49
            %\node[auxnode,label={-45:45}] () at (aux45) {};
曹润柘 committed
50 51

            \coordinate (aux55) at ([yshift=\base]aux45);
zengxin committed
52
            %\node[auxnode,label={-45:55}] () at (aux55) {};
曹润柘 committed
53 54 55
            \ExtractX{$(aux21)$}
            \ExtractY{$(aux55)$}
            \coordinate (aux51) at (\XCoord,\YCoord);
zengxin committed
56
            %\node[auxnode,label={-45:51}] () at (aux51) {};
曹润柘 committed
57 58 59
            \ExtractX{$(aux23)$}
            \ExtractY{$(aux55)$}
            \coordinate (aux53) at (\XCoord,\YCoord);
zengxin committed
60
            %\node[auxnode,label={-45:53}] () at (aux53) {};
曹润柘 committed
61 62 63
            \ExtractX{$(aux28)$}
            \ExtractY{$(aux55)$}
            \coordinate (aux58) at (\XCoord,\YCoord);
zengxin committed
64
            %\node[auxnode,label={-45:58}] () at (aux58) {};
曹润柘 committed
65 66 67
            \ExtractX{$(aux29)$}
            \ExtractY{$(aux55)$}
            \coordinate (aux59) at (\XCoord,\YCoord);
zengxin committed
68
            %\node[auxnode,label={-45:59}] () at (aux59) {};
曹润柘 committed
69 70

            \coordinate (aux68) at ([yshift=\base]aux58);
zengxin committed
71
            %\node[auxnode,label={-45:68}] () at (aux68) {};
曹润柘 committed
72 73 74 75 76 77 78 79 80 81 82
        \end{scope}

        \begin{scope}
            \node[opnode,circle,opacity=0] (f53) at (aux53) {};
            \node[opnode,circle,opacity=0] (u55) at (aux55) {};
            % forget gate
            {
                \draw[emph] (aux21) -- (aux23) -- (aux33);
                \draw[-latex,emph] (aux12) -- (aux22) -- (aux23) -- (f53);
                \node[opnode,circle,draw=red,thick] () at (aux33) {$\sigma$};
            }
曹润柘 committed
83
            
曹润柘 committed
84 85 86 87 88 89
        \end{scope}

        \begin{scope}
            \node[wordnode,anchor=south] () at ([xshift=0.5\base]aux21) {$\mathbf{h}_{t-1}$};
            \node[wordnode,anchor=west] () at (aux12) {$\mathbf{x}_t$};
            \node[wordnode,anchor=south] () at ([xshift=0.5\base]aux51) {$\mathbf{c}_{t-1}$};
曹润柘 committed
90
           
曹润柘 committed
91 92 93 94 95
        \end{scope}

           \node[ ] (o27) at (aux27) { };

        \begin{pgfonlayer}{background}
曹润柘 committed
96
            \node[draw,very thick,rectangle,fill=blue!10!white,rounded corners=5pt,inner sep=4pt,fit=(aux22) (aux58) (u55) (o27)] (LSTM) {};
曹润柘 committed
97 98
        \end{pgfonlayer}

曹润柘 committed
99 100
   
    \end{tikzpicture}