-
Notifications
You must be signed in to change notification settings - Fork 36
/
Copy pathLSTM.tex
179 lines (117 loc) · 11 KB
/
LSTM.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
\documentclass[18pt]{article}
\usepackage{tikz}
\usetikzlibrary{positioning}
\usepackage{pdflscape}
\usepackage{geometry}
\geometry{top=5cm,bottom=0cm,left=5cm,right=5cm}
\usetikzlibrary{arrows}
\begin{document}
\pagestyle{empty}
\begin{landscape}
\begin{tikzpicture}
\coordinate (O) at (0, 0);
\def\offset{0}
% input
\filldraw[fill = red,fill opacity=0.2,draw=black,line width=1pt] (-1.2+\offset,0.7) circle (0.7) node[fill opacity=1]{\huge $\mathbf{x}_{t-1}$};
%LSTM
\filldraw[fill={rgb,255:red,204; green,255; blue,204},fill opacity=0.95,draw=green,line width=2pt,rounded corners=0.5cm] (-2+\offset,2.5) rectangle (6+\offset,7.5); % background
\filldraw[fill=blue,fill opacity=0.2,draw=black,line width=1pt] (-1.2+\offset,3.5) rectangle (-0.3+\offset,4)node[pos=.5,fill opacity=1]{\huge $\sigma$};
\filldraw[fill=blue,fill opacity=0.2,draw=black,line width=1pt] (0+\offset,3.5) rectangle (0.9+\offset,4)node[pos=.5,fill opacity=1]{\huge $\sigma$};
\filldraw[fill=blue,fill opacity=0.2,draw=black,line width=1pt] (1.2+\offset,3.5) rectangle (2.3+\offset,4)node[pos=.5,fill opacity=1]{\large tanh};
\filldraw[fill=blue,fill opacity=0.2,draw=black,line width=1pt] (2.6+\offset,3.5) rectangle (3.5+\offset,4)node[pos=.5,fill opacity=1]{\huge $\sigma$};
\filldraw[fill=pink,fill opacity=1,draw=black,line width=1pt] (-0.75+\offset,6.5) circle (0.25)node[fill opacity=1]{\Large $\times$};
\filldraw[fill=pink,fill opacity=1,draw=black,line width=1pt] (1.75+\offset,5) circle (0.25)node[fill opacity=1]{\Large $\times$};
\filldraw[fill=pink,fill opacity=1,draw=black,line width=1pt] (4.25+\offset,5) circle (0.25)node[fill opacity=1]{\Large $\times$};
\filldraw[fill=pink,fill opacity=1,draw=black,line width=1pt] (1.75+\offset,6.5) circle (0.25)node[fill opacity=1]{\Large $+$};
\filldraw[fill=pink,fill opacity=1,draw=black,line width=1pt] (4.25+\offset,5.8) ellipse (0.5cm and 0.25 cm) node[fill opacity=1]{\large tanh};
\draw[ultra thick,black,rounded corners=0.3cm,line width=3pt] (-1.2+\offset,1.4)-- (-1.2+\offset,3)-- (-0.75+\offset,3);
\draw[ultra thick,black,rounded corners=0.3cm,line width=3pt] (-2+\offset,3)-- (3.05+\offset,3)-- (3.05+\offset,3.5);
\draw[ultra thick,black,line width=3pt] (-0.75+\offset,3)-- (-0.75+\offset,3.5);
\draw[-latex,black,line width=3pt] (-0.75+\offset,4)-- (-0.75+\offset,6.25);
\draw[ultra thick,black,line width=3pt] (0.5+\offset,3)-- (0.5+\offset,3.5);
\draw[-latex,black,rounded corners=0.3cm,line width=3pt] (0.5+\offset,4)-- (0.5+\offset,5)-- (1.5+\offset,5);
\draw[ultra thick,black,line width=3pt] (1.75+\offset,3)-- (1.75+\offset,3.5);
\draw[ultra thick,black,line width=3pt] (1.75+\offset,4)-- (1.75+\offset,4.75);
\draw[-latex,black,rounded corners=0.3cm,line width=3pt] (1.75+\offset,5.25)-- (1.75+\offset,6.25);
\draw[ultra thick,black,line width=3pt] (-2+\offset,6.5)-- (-1+\offset,6.5);
\draw[ultra thick,black,line width=3pt] (-0.5+\offset,6.5)-- (1.5+\offset,6.5);
\draw[-latex,black,line width=3pt] (2+\offset,6.5)-- (7+\offset,6.5);
\draw[-latex,black,rounded corners=0.3cm,line width=3pt] (3+\offset,4)-- (3+\offset,5)-- (4+\offset,5);
\draw[ultra thick,black,line width=3pt] (4.25+\offset,6.5)-- (4.25+\offset,6.05);
\draw[ultra thick,black,line width=3pt] (4.25+\offset,5.55)-- (4.25+\offset,5.25);
\draw[-latex,black,rounded corners=0.3cm,line width=3pt] (4.25+\offset,4.75)-- (4.25+\offset,3)-- (7+\offset,3);
\draw[ultra thick,black,rounded corners=0.3cm,line width=3pt] (5+\offset,3)-- (5.3+\offset,3) -- (5.3+\offset,6.3);
\draw[-latex,black,line width=3pt] (5.3+\offset,6.7)-- (5.3+\offset,8.6);
\filldraw[fill = blue,fill opacity=0.2,draw=black,line width=1pt] (5.3+\offset,9.3) circle (0.7)node[fill opacity=1]{\huge $\mathbf{h}_{t-1}$};
\filldraw[fill={rgb,255:red,204; green,255; blue,204},fill opacity=0.9,draw=green,line width=3pt,rounded corners=0.5cm] (-2+\offset,2.5) rectangle (6+\offset,7.5)node[pos=.5,fill opacity=1]{\Huge \textbf{LSTM}};
\def\offset{9}
% input
\filldraw[fill = red,fill opacity=0.2,draw=black,line width=1pt] (-1.2+\offset,0.7) circle (0.7) node[fill opacity=1]{\huge $\mathbf{x}_{t}$};
%LSTM
\filldraw[fill={rgb,255:red,204; green,255; blue,204},fill opacity=0.95,draw=green,line width=2pt,rounded corners=0.5cm] (-2+\offset,2.5) rectangle (6+\offset,7.5); % background
\filldraw[fill=blue,fill opacity=0.2,draw=black,line width=1pt] (-1.2+\offset,3.5) rectangle (-0.3+\offset,4)node[pos=.5,fill opacity=1]{\huge $\sigma$};
\filldraw[fill=blue,fill opacity=0.2,draw=black,line width=1pt] (0+\offset,3.5) rectangle (0.9+\offset,4)node[pos=.5,fill opacity=1]{\huge $\sigma$};
\filldraw[fill=blue,fill opacity=0.2,draw=black,line width=1pt] (1.2+\offset,3.5) rectangle (2.3+\offset,4)node[pos=.5,fill opacity=1]{\large tanh};
\filldraw[fill=blue,fill opacity=0.2,draw=black,line width=1pt] (2.6+\offset,3.5) rectangle (3.5+\offset,4)node[pos=.5,fill opacity=1]{\huge $\sigma$};
\filldraw[fill=pink,fill opacity=1,draw=black,line width=1pt] (-0.75+\offset,6.5) circle (0.25)node[fill opacity=1]{\Large $\times$};
\filldraw[fill=pink,fill opacity=1,draw=black,line width=1pt] (1.75+\offset,5) circle (0.25)node[fill opacity=1]{\Large $\times$};
\filldraw[fill=pink,fill opacity=1,draw=black,line width=1pt] (4.25+\offset,5) circle (0.25)node[fill opacity=1]{\Large $\times$};
\filldraw[fill=pink,fill opacity=1,draw=black,line width=1pt] (1.75+\offset,6.5) circle (0.25)node[fill opacity=1]{\Large $+$};
\filldraw[fill=pink,fill opacity=1,draw=black,line width=1pt] (4.25+\offset,5.8) ellipse (0.5cm and 0.25 cm) node[fill opacity=1]{\large tanh};
\draw[ultra thick,black,rounded corners=0.3cm,line width=3pt] (-1.2+\offset,1.4)-- (-1.2+\offset,3)-- (-0.75+\offset,3);
\draw[ultra thick,black,rounded corners=0.3cm,line width=3pt] (-2+\offset,3)-- (3.05+\offset,3)-- (3.05+\offset,3.5);
\draw[ultra thick,black,line width=3pt] (-0.75+\offset,3)-- (-0.75+\offset,3.5);
\draw[-latex,black,line width=3pt] (-0.75+\offset,4)-- (-0.75+\offset,6.25);
\draw[ultra thick,black,line width=3pt] (0.5+\offset,3)-- (0.5+\offset,3.5);
\draw[-latex,black,rounded corners=0.3cm,line width=3pt] (0.5+\offset,4)-- (0.5+\offset,5)-- (1.5+\offset,5);
\draw[ultra thick,black,line width=3pt] (1.75+\offset,3)-- (1.75+\offset,3.5);
\draw[ultra thick,black,line width=3pt] (1.75+\offset,4)-- (1.75+\offset,4.75);
\draw[-latex,black,rounded corners=0.3cm,line width=3pt] (1.75+\offset,5.25)-- (1.75+\offset,6.25);
\draw[ultra thick,black,line width=3pt] (-2+\offset,6.5)-- (-1+\offset,6.5);
\draw[ultra thick,black,line width=3pt] (-0.5+\offset,6.5)-- (1.5+\offset,6.5);
\draw[-latex,black,line width=3pt] (2+\offset,6.5)-- (7+\offset,6.5);
\draw[-latex,black,rounded corners=0.3cm,line width=3pt] (3+\offset,4)-- (3+\offset,5)-- (4+\offset,5);
\draw[ultra thick,black,line width=3pt] (4.25+\offset,6.5)-- (4.25+\offset,6.05);
\draw[ultra thick,black,line width=3pt] (4.25+\offset,5.55)-- (4.25+\offset,5.25);
\draw[-latex,black,rounded corners=0.3cm,line width=3pt] (4.25+\offset,4.75)-- (4.25+\offset,3)-- (7+\offset,3);
\draw[ultra thick,black,rounded corners=0.3cm,line width=3pt] (5+\offset,3)-- (5.3+\offset,3) -- (5.3+\offset,6.3);
\draw[-latex,black,line width=3pt] (5.3+\offset,6.7)-- (5.3+\offset,8.6);
\filldraw[fill = blue,fill opacity=0.2,draw=black,line width=1pt] (5.3+\offset,9.3) circle (0.7)node[fill opacity=1]{\huge $\mathbf{h}_{t}$};
%\filldraw[fill={rgb,255:red,204; green,255; blue,204},fill opacity=0.9,draw=green,line width=3pt,rounded corners=0.5cm] (-2+\offset,2.5) rectangle (6+\offset,7.5)node[pos=.5,fill opacity=1]{\Huge \textbf{LSTM}};
\def\offset{18}
% input
\filldraw[fill = red,fill opacity=0.2,draw=black,line width=1pt] (-1.2+\offset,0.7) circle (0.7) node[fill opacity=1]{\huge $\mathbf{x}_{t+1}$};
%LSTM
\filldraw[fill={rgb,255:red,204; green,255; blue,204},fill opacity=0.95,draw=green,line width=2pt,rounded corners=0.5cm] (-2+\offset,2.5) rectangle (6+\offset,7.5); % background
\filldraw[fill=blue,fill opacity=0.2,draw=black,line width=1pt] (-1.2+\offset,3.5) rectangle (-0.3+\offset,4)node[pos=.5,fill opacity=1]{\huge $\sigma$};
\filldraw[fill=blue,fill opacity=0.2,draw=black,line width=1pt] (0+\offset,3.5) rectangle (0.9+\offset,4)node[pos=.5,fill opacity=1]{\huge $\sigma$};
\filldraw[fill=blue,fill opacity=0.2,draw=black,line width=1pt] (1.2+\offset,3.5) rectangle (2.3+\offset,4)node[pos=.5,fill opacity=1]{\large tanh};
\filldraw[fill=blue,fill opacity=0.2,draw=black,line width=1pt] (2.6+\offset,3.5) rectangle (3.5+\offset,4)node[pos=.5,fill opacity=1]{\huge $\sigma$};
\filldraw[fill=pink,fill opacity=1,draw=black,line width=1pt] (-0.75+\offset,6.5) circle (0.25)node[fill opacity=1]{\Large $\times$};
\filldraw[fill=pink,fill opacity=1,draw=black,line width=1pt] (1.75+\offset,5) circle (0.25)node[fill opacity=1]{\Large $\times$};
\filldraw[fill=pink,fill opacity=1,draw=black,line width=1pt] (4.25+\offset,5) circle (0.25)node[fill opacity=1]{\Large $\times$};
\filldraw[fill=pink,fill opacity=1,draw=black,line width=1pt] (1.75+\offset,6.5) circle (0.25)node[fill opacity=1]{\Large $+$};
\filldraw[fill=pink,fill opacity=1,draw=black,line width=1pt] (4.25+\offset,5.8) ellipse (0.5cm and 0.25 cm) node[fill opacity=1]{\large tanh};
\draw[ultra thick,black,rounded corners=0.3cm,line width=3pt] (-1.2+\offset,1.4)-- (-1.2+\offset,3)-- (-0.75+\offset,3);
\draw[ultra thick,black,rounded corners=0.3cm,line width=3pt] (-2+\offset,3)-- (3.05+\offset,3)-- (3.05+\offset,3.5);
\draw[ultra thick,black,line width=3pt] (-0.75+\offset,3)-- (-0.75+\offset,3.5);
\draw[-latex,black,line width=3pt] (-0.75+\offset,4)-- (-0.75+\offset,6.25);
\draw[ultra thick,black,line width=3pt] (0.5+\offset,3)-- (0.5+\offset,3.5);
\draw[-latex,black,rounded corners=0.3cm,line width=3pt] (0.5+\offset,4)-- (0.5+\offset,5)-- (1.5+\offset,5);
\draw[ultra thick,black,line width=3pt] (1.75+\offset,3)-- (1.75+\offset,3.5);
\draw[ultra thick,black,line width=3pt] (1.75+\offset,4)-- (1.75+\offset,4.75);
\draw[-latex,black,rounded corners=0.3cm,line width=3pt] (1.75+\offset,5.25)-- (1.75+\offset,6.25);
\draw[ultra thick,black,line width=3pt] (-2+\offset,6.5)-- (-1+\offset,6.5);
\draw[ultra thick,black,line width=3pt] (-0.5+\offset,6.5)-- (1.5+\offset,6.5);
\draw[-latex,black,line width=3pt] (2+\offset,6.5)-- (7+\offset,6.5);
\draw[-latex,black,rounded corners=0.3cm,line width=3pt] (3+\offset,4)-- (3+\offset,5)-- (4+\offset,5);
\draw[ultra thick,black,line width=3pt] (4.25+\offset,6.5)-- (4.25+\offset,6.05);
\draw[ultra thick,black,line width=3pt] (4.25+\offset,5.55)-- (4.25+\offset,5.25);
\draw[-latex,black,rounded corners=0.3cm,line width=3pt] (4.25+\offset,4.75)-- (4.25+\offset,3)-- (7+\offset,3);
\draw[ultra thick,black,rounded corners=0.3cm,line width=3pt] (5+\offset,3)-- (5.3+\offset,3) -- (5.3+\offset,6.3);
\draw[-latex,black,line width=3pt] (5.3+\offset,6.7)-- (5.3+\offset,8.6);
\filldraw[fill = blue,fill opacity=0.2,draw=black,line width=1pt] (5.3+\offset,9.3) circle (0.7)node[fill opacity=1]{\huge $\mathbf{h}_{t+1}$};
\filldraw[fill={rgb,255:red,204; green,255; blue,204},fill opacity=0.9,draw=green,line width=3pt,rounded corners=0.5cm] (-2+\offset,2.5) rectangle (6+\offset,7.5)node[pos=.5,fill opacity=1]{\Huge \textbf{LSTM}};
\end{tikzpicture}
\end{landscape}
\end{document}