-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathRNN
172 lines (172 loc) · 14.5 KB
/
RNN
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
<mxfile host="app.diagrams.net" modified="2023-07-12T07:28:57.495Z" agent="Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.0.0.0 Safari/537.36 Edg/114.0.1823.18" etag="pcya1eZZtgiMjI1mcTgr" version="21.6.1" type="github">
<diagram name="Page-1" id="Hn9k9bEmCH6qr2DUw1FQ">
<mxGraphModel dx="720" dy="652" grid="1" gridSize="10" guides="1" tooltips="1" connect="1" arrows="1" fold="1" page="1" pageScale="1" pageWidth="850" pageHeight="1100" math="0" shadow="0">
<root>
<mxCell id="0" />
<mxCell id="1" parent="0" />
<mxCell id="x-2phjmjSEDHMF-AvRid-10" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="x-2phjmjSEDHMF-AvRid-1" target="x-2phjmjSEDHMF-AvRid-8">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-49" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0;entryY=0.5;entryDx=0;entryDy=0;" edge="1" parent="1" source="x-2phjmjSEDHMF-AvRid-1" target="x-2phjmjSEDHMF-AvRid-50">
<mxGeometry relative="1" as="geometry">
<mxPoint x="110" y="1400" as="targetPoint" />
<Array as="points">
<mxPoint x="110" y="1330" />
</Array>
</mxGeometry>
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-1" value="encode char &lt;-&gt; int<br>- int2char<br>- char2int" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="50" y="260" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-7" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="x-2phjmjSEDHMF-AvRid-2" target="x-2phjmjSEDHMF-AvRid-6">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-2" value="长度归一化<br>(for seq_len)" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="240" y="260" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-4" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="x-2phjmjSEDHMF-AvRid-3" target="x-2phjmjSEDHMF-AvRid-1">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-5" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="x-2phjmjSEDHMF-AvRid-3" target="x-2phjmjSEDHMF-AvRid-2">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-16" value="<ul><li>batch_size(sentence)</li><li>seq_len(char)</li></ul>" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="x-2phjmjSEDHMF-AvRid-5">
<mxGeometry x="-0.8588" y="-1" relative="1" as="geometry">
<mxPoint x="81" y="14" as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-3" value="sentences" style="ellipse;shape=cloud;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="140" y="50" width="120" height="80" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-9" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="x-2phjmjSEDHMF-AvRid-6" target="x-2phjmjSEDHMF-AvRid-8">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-6" value="掐头去尾<br>- input_seq<br>- output_seq" style="whiteSpace=wrap;html=1;rounded=0;" vertex="1" parent="1">
<mxGeometry x="240" y="360" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-12" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="x-2phjmjSEDHMF-AvRid-8" target="x-2phjmjSEDHMF-AvRid-11">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-15" value="<ul><li>batch_size</li><li>seq_len(int)</li></ul>" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="x-2phjmjSEDHMF-AvRid-12">
<mxGeometry x="-0.2048" y="2" relative="1" as="geometry">
<mxPoint x="58" y="4" as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-24" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="x-2phjmjSEDHMF-AvRid-8" target="x-2phjmjSEDHMF-AvRid-22">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-8" value="int 映射" style="whiteSpace=wrap;html=1;rounded=0;" vertex="1" parent="1">
<mxGeometry x="240" y="470" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-20" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="x-2phjmjSEDHMF-AvRid-11" target="x-2phjmjSEDHMF-AvRid-18">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-11" value="one-hot" style="whiteSpace=wrap;html=1;rounded=0;" vertex="1" parent="1">
<mxGeometry x="240" y="620" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-30" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="x-2phjmjSEDHMF-AvRid-13" target="x-2phjmjSEDHMF-AvRid-29">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-13" value="init hidden(status)" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="830" y="780" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-28" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="x-2phjmjSEDHMF-AvRid-18" target="x-2phjmjSEDHMF-AvRid-27">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-18" value="features<br>" style="ellipse;shape=cloud;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="240" y="720" width="120" height="80" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-21" value="<ul><li>batch_size</li><li>seq_len(one-hot vector)</li><li>dic_len</li></ul>" style="text;html=1;strokeColor=none;fillColor=none;align=center;verticalAlign=middle;whiteSpace=wrap;rounded=0;" vertex="1" parent="1">
<mxGeometry x="210" y="820" width="180" height="60" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-26" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="x-2phjmjSEDHMF-AvRid-22" target="x-2phjmjSEDHMF-AvRid-25">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-22" value="target_seq" style="ellipse;shape=cloud;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="425" y="540" width="120" height="80" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-41" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="x-2phjmjSEDHMF-AvRid-25" target="x-2phjmjSEDHMF-AvRid-39">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-25" value="Tensor" style="whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="610" y="550" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-31" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="x-2phjmjSEDHMF-AvRid-27" target="x-2phjmjSEDHMF-AvRid-13">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-32" value="batch_size<br>(=1 while inferring" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="x-2phjmjSEDHMF-AvRid-31">
<mxGeometry x="-0.0051" y="3" relative="1" as="geometry">
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-27" value="from_numpy" style="whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="425" y="730" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-34" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="x-2phjmjSEDHMF-AvRid-29" target="x-2phjmjSEDHMF-AvRid-33">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-29" value="rnn" style="whiteSpace=wrap;html=1;rounded=0;" vertex="1" parent="1">
<mxGeometry x="830" y="880" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-36" value="" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="x-2phjmjSEDHMF-AvRid-33" target="x-2phjmjSEDHMF-AvRid-35">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-33" value="contiguous" style="whiteSpace=wrap;html=1;rounded=0;" vertex="1" parent="1">
<mxGeometry x="830" y="980" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-48" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;" edge="1" parent="1" source="x-2phjmjSEDHMF-AvRid-35" target="x-2phjmjSEDHMF-AvRid-46">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-35" value="fc" style="whiteSpace=wrap;html=1;rounded=0;" vertex="1" parent="1">
<mxGeometry x="830" y="1080" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-37" value="" style="shape=flexArrow;endArrow=classic;html=1;rounded=0;" edge="1" parent="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="770" y="800" as="sourcePoint" />
<mxPoint x="770" y="1130" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-38" value="forward" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="x-2phjmjSEDHMF-AvRid-37">
<mxGeometry x="-0.0834" y="2" relative="1" as="geometry">
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-39" value="cross_entropyloss" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="1020" y="920" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-40" value="adam optim" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="1020" y="1010" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-42" value="" style="shape=flexArrow;endArrow=classic;html=1;rounded=0;" edge="1" parent="1">
<mxGeometry width="50" height="50" relative="1" as="geometry">
<mxPoint x="1180" y="1060" as="sourcePoint" />
<mxPoint x="1180" y="910" as="targetPoint" />
</mxGeometry>
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-43" value="backward" style="edgeLabel;html=1;align=center;verticalAlign=middle;resizable=0;points=[];" vertex="1" connectable="0" parent="x-2phjmjSEDHMF-AvRid-42">
<mxGeometry x="-0.3547" y="2" relative="1" as="geometry">
<mxPoint as="offset" />
</mxGeometry>
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-45" value="<h1>RNN&nbsp;</h1><div>sequence to (next) char application</div><p>use multiply times to generate a sentence</p><p>reference :&nbsp;https://blog.floydhub.com/a-beginners-guide-on-recurrent-neural-networks-with-pytorch/</p>" style="text;html=1;strokeColor=none;fillColor=none;spacing=5;spacingTop=-20;whiteSpace=wrap;overflow=hidden;rounded=0;" vertex="1" parent="1">
<mxGeometry x="545" y="230" width="585" height="120" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-51" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.5;entryY=0;entryDx=0;entryDy=0;" edge="1" parent="1" source="x-2phjmjSEDHMF-AvRid-46" target="x-2phjmjSEDHMF-AvRid-50">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-46" value="an int" style="ellipse;shape=cloud;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="830" y="1190" width="120" height="80" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-54" style="edgeStyle=orthogonalEdgeStyle;rounded=0;orthogonalLoop=1;jettySize=auto;html=1;entryX=0.506;entryY=0.112;entryDx=0;entryDy=0;entryPerimeter=0;" edge="1" parent="1" source="x-2phjmjSEDHMF-AvRid-50" target="x-2phjmjSEDHMF-AvRid-53">
<mxGeometry relative="1" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-50" value="char 映射" style="rounded=0;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="830" y="1300" width="120" height="60" as="geometry" />
</mxCell>
<mxCell id="x-2phjmjSEDHMF-AvRid-53" value="a char" style="ellipse;shape=cloud;whiteSpace=wrap;html=1;" vertex="1" parent="1">
<mxGeometry x="830" y="1400" width="120" height="80" as="geometry" />
</mxCell>
</root>
</mxGraphModel>
</diagram>
</mxfile>