File: MLP.html

package info (click to toggle)
torch 2-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 5,488 kB
  • ctags: 3,217
  • sloc: cpp: 14,272; makefile: 201
file content (313 lines) | stat: -rw-r--r-- 14,996 bytes parent folder | download
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
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

<HTML>
<HEAD>
   <TITLE>class  MLP</TITLE>
   <META NAME="GENERATOR" CONTENT="DOC++ 3.4.8">
</HEAD>
<BODY BGCOLOR="#ffffff">

<H2>class  <A HREF="#DOC.DOCU">MLP</A></H2></H2><BLOCKQUOTE>This class is a simple interface to the <TT>ConnectedMachine</TT> class that ca be used to build the well-known Multi Layer Perceptron type of neural networks.</BLOCKQUOTE>
<HR>

<H2>Inheritance:</H2>
<APPLET CODE="ClassGraph.class" WIDTH=600 HEIGHT=155>
<param name=classes value="CObject,MObject.html,CMachine,MMachine.html,CGradientMachine,MGradientMachine.html,CConnectedMachine,MConnectedMachine.html,CMLP,MMLP.html">
<param name=before value="M,M,M,M,M">
<param name=after value="Md_SPSPSP,Md_SPSP,Md_SP,Md_,M">
<param name=indent value="0,1,2,3,4">
<param name=arrowdir value="down">
</APPLET>
<HR>

<DL>
<P><DL>
<DT><H3>Public Fields</H3><DD><DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif><!1><A HREF="Linear.html">Linear</A>* <B><A HREF="#DOC.114.1">hidden_layer</A></B>
<DD><I>the first <TT>Linear</TT> layer</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif><!1><A HREF="SparseLinear.html">SparseLinear</A>* <B><A HREF="#DOC.114.2">sparse_hidden_layer</A></B>
<DD><I>the first <TT>Linear</TT> layer for sparse mode</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif><!1><A HREF="Tanh.html">Tanh</A>* <B><A HREF="#DOC.114.3">hidden_tanh_layer</A></B>
<DD><I>the first <TT>Tanh</TT> layer</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif><!1><A HREF="Linear.html">Linear</A>* <B><A HREF="#DOC.114.4">outputs_layer</A></B>
<DD><I>the second <TT>Linear</TT> layer</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif><!1><A HREF="SparseLinear.html">SparseLinear</A>* <B><A HREF="#DOC.114.5">sparse_outputs_layer</A></B>
<DD><I>the second <TT>Linear</TT> layer for sparse mode, if there is no hidden units</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif><!1><A HREF="Softmax.html">Softmax</A>* <B><A HREF="#DOC.114.6">outputs_softmax_layer</A></B>
<DD><I>the optional second <TT>Softmax</TT> layer</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif><!1><A HREF="Sigmoid.html">Sigmoid</A>* <B><A HREF="#DOC.114.7">outputs_sigmoid_layer</A></B>
<DD><I>the optional second <TT>Sigmoid</TT> layer</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif><!1><A HREF="LogSoftmax.html">LogSoftmax</A>* <B><A HREF="#DOC.114.8">outputs_log_softmax_layer</A></B>
<DD><I>the optional second <TT>Softmax</TT> layer</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif><!1><A HREF="Tanh.html">Tanh</A>* <B><A HREF="#DOC.114.9">outputs_tanh_layer</A></B>
<DD><I>the optional second <TT>Tanh</TT> layer</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>int <B><A HREF="#DOC.114.10">n_hidden</A></B>
<DD><I>the number of hidden units</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>int <B><A HREF="#DOC.114.11">n_inputs</A></B>
<DD><I>the number of inputs</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>int <B><A HREF="#DOC.114.12">n_outputs</A></B>
<DD><I>the number of outputs</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>bool <B><A HREF="#DOC.114.15">is_sparse_inputs</A></B>
<DD><I>To know if the inputs are sparse</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>bool <B><A HREF="#DOC.114.16">inputs_to_outputs</A></B>
<DD><I>if this is true, add a direct connection from inputs to <TT>Linear</TT></I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>real <B><A HREF="#DOC.114.17">weight_decay</A></B>
<DD><I>the eventual weight_decay</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif><!1><A HREF="Linear.html">Linear</A>* <B><A HREF="#DOC.114.18">add_layer</A></B>
<DD><I>the direct <TT>Linear</TT> layer</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif><!1><A HREF="SumMachine.html">SumMachine</A>* <B><A HREF="#DOC.114.19">sum_layer</A></B>
<DD><I>if <TT>inputs_to_outputs</TT> is true, we also need a <TT>SumMachine</TT></I>
</DL></P>

<P><DL>
<DT><H3>Public Members</H3><DD><DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif> <B><A HREF="#DOC.114.13">if this is false, add a <TT>Tanh</TT> layer</A></B>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif> <B><A HREF="#DOC.114.14">Flags (in order of priority if several are true) to know what will be the output</A></B>
</DL></P>

</DL>
<HR><H3>Inherited from <A HREF="ConnectedMachine.html">ConnectedMachine</A>:</H3>
<DL>
<P><DL>
<DT><H3>Public Methods</H3><DD><DT>
<IMG ALT="o" SRC=icon2.gif>void <B>addFCL</B>(<!1><A HREF="GradientMachine.html">GradientMachine</A>* <!1><A HREF="FixedMachineDistribution.html#DOC.96.1">machine</A>)
<DT>
<IMG ALT="o" SRC=icon2.gif>void <B>addMachine</B>(<!1><A HREF="GradientMachine.html">GradientMachine</A>* <!1><A HREF="FixedMachineDistribution.html#DOC.96.1">machine</A>)
<DT>
<IMG ALT="o" SRC=icon2.gif>void <B>connectOn</B>(<!1><A HREF="GradientMachine.html">GradientMachine</A>* <!1><A HREF="FixedMachineDistribution.html#DOC.96.1">machine</A>)
<DT>
<IMG ALT="o" SRC=icon2.gif>void <B>addLayer</B>()
</DL></P>

</DL>
<HR><H3>Inherited from <A HREF="GradientMachine.html">GradientMachine</A>:</H3>
<DL>
<P><DL>
<DT><H3>Public Fields</H3><DD><DT>
<IMG ALT="o" SRC=icon2.gif>bool <B>is_free</B>
<DT>
<IMG ALT="o" SRC=icon2.gif><!1><A HREF="List.html">List</A>* <B>params</B>
<DT>
<IMG ALT="o" SRC=icon2.gif><!1><A HREF="List.html">List</A>* <B>der_params</B>
<DT>
<IMG ALT="o" SRC=icon2.gif>int <B>n_params</B>
<DT>
<IMG ALT="o" SRC=icon2.gif>real* <B>beta</B>
</DL></P>

<P><DL>
<DT><H3>Public Methods</H3><DD><DT>
<IMG ALT="o" SRC=icon2.gif>virtual   void <B>init</B>()
<DT>
<IMG ALT="o" SRC=icon2.gif>virtual   int <B>numberOfParams</B>()
<DT>
<IMG ALT="o" SRC=icon2.gif>virtual   void <B>iterInitialize</B>()
<DT>
<IMG ALT="o" SRC=icon2.gif>virtual   void <B>backward</B>(<!1><A HREF="List.html">List</A>* <!1><A HREF="SeqExample.html#DOC.107.3">inputs</A>, real* <!1><A HREF="QCMachine.html#DOC.40.5">alpha</A>)
<DT>
<IMG ALT="o" SRC=icon2.gif>virtual   void <B>allocateMemory</B>()
<DT>
<IMG ALT="o" SRC=icon2.gif>virtual   void <B>freeMemory</B>()
<DT>
<IMG ALT="o" SRC=icon2.gif>virtual   void <B>loadFILE</B>(FILE* <!1><A HREF="Measurer.html#DOC.30.2">file</A>)
<DT>
<IMG ALT="o" SRC=icon2.gif>virtual   void <B>saveFILE</B>(FILE* <!1><A HREF="Measurer.html#DOC.30.2">file</A>)
</DL></P>

</DL>
<HR><H3>Inherited from <A HREF="Machine.html">Machine</A>:</H3>
<DL>
<P><DL>
<DT><H3>Public Fields</H3><DD><DT>
<IMG ALT="o" SRC=icon2.gif><!1><A HREF="List.html">List</A>* <B>outputs</B>
</DL></P>

<P><DL>
<DT><H3>Public Methods</H3><DD><DT>
<IMG ALT="o" SRC=icon2.gif>virtual   void <B>forward</B>(<!1><A HREF="List.html">List</A>* <!1><A HREF="SeqExample.html#DOC.107.3">inputs</A>)
<DT>
<IMG ALT="o" SRC=icon2.gif>virtual   void <B>reset</B>()
</DL></P>

</DL>
<HR><H3>Inherited from <A HREF="Object.html">Object</A>:</H3>
<DL>
<P><DL>
<DT><H3>Public Methods</H3><DD><DT>
<IMG ALT="o" SRC=icon2.gif>void <B>addOption</B>(const char* <!1><A HREF="SeqExample.html#DOC.107.9">name</A>, int size, void* <!1><A HREF="Vec.html#DOC.81.3">ptr</A>, const char* <!1><A HREF="CmdLine.html#DOC.7.3">help</A>="", bool is_allowed_after_init=false)
<DT>
<IMG ALT="o" SRC=icon2.gif>void <B>addIOption</B>(const char* <!1><A HREF="SeqExample.html#DOC.107.9">name</A>, int* <!1><A HREF="Vec.html#DOC.81.3">ptr</A>, int init_value, const char* <!1><A HREF="CmdLine.html#DOC.7.3">help</A>="", bool is_allowed_after_init=false)
<DT>
<IMG ALT="o" SRC=icon2.gif>void <B>addROption</B>(const char* <!1><A HREF="SeqExample.html#DOC.107.9">name</A>, real* <!1><A HREF="Vec.html#DOC.81.3">ptr</A>, real init_value, const char* <!1><A HREF="CmdLine.html#DOC.7.3">help</A>="", bool is_allowed_after_init=false)
<DT>
<IMG ALT="o" SRC=icon2.gif>void <B>addBOption</B>(const char* <!1><A HREF="SeqExample.html#DOC.107.9">name</A>, bool* <!1><A HREF="Vec.html#DOC.81.3">ptr</A>, bool init_value, const char* <!1><A HREF="CmdLine.html#DOC.7.3">help</A>="", bool is_allowed_after_init=false)
<DT>
<IMG ALT="o" SRC=icon2.gif>void <B>setOption</B>(const char* <!1><A HREF="SeqExample.html#DOC.107.9">name</A>, void* <!1><A HREF="Vec.html#DOC.81.3">ptr</A>)
<DT>
<IMG ALT="o" SRC=icon2.gif>void <B>setIOption</B>(const char* <!1><A HREF="SeqExample.html#DOC.107.9">name</A>, int option)
<DT>
<IMG ALT="o" SRC=icon2.gif>void <B>setROption</B>(const char* <!1><A HREF="SeqExample.html#DOC.107.9">name</A>, real option)
<DT>
<IMG ALT="o" SRC=icon2.gif>void <B>setBOption</B>(const char* <!1><A HREF="SeqExample.html#DOC.107.9">name</A>, bool option)
<DT>
<IMG ALT="o" SRC=icon2.gif>void <B>load</B>(const char* filename)
<DT>
<IMG ALT="o" SRC=icon2.gif>void <B>save</B>(const char* filename)
</DL></P>

</DL>

<A NAME="DOC.DOCU"></A>
<HR>
<H2>Documentation</H2>
<BLOCKQUOTE>This class is a simple interface to the <TT>ConnectedMachine</TT> class that
ca be used to build the well-known Multi Layer Perceptron type of
neural networks. It contains a layer of <TT>Linear</TT> followed by a layer
of <TT>Tanh</TT>, followed by a layer of <TT>Linear</TT> and optionally
<UL>
<LI> a layer of softmax
<LI> or a layer of sigmoid
<LI> or a layer of log-softmax
<LI> or a layer of tanh
</UL>
Optionally, it also contains a direct connection from the inputs
to the linear layer, and if you want, you can choose sparse inputs.

<P>Options:
<TABLE BORDER>
<TR><TD>
"inputs to outputs"   </TD><TD> bool   </TD><TD> connections from inputs to outputs        </TD><TD> [false]</TD></TR><TR><TD>
"weight decay"        </TD><TD> real   </TD><TD> the weight decay                          </TD><TD> [0]</TD></TR><TR><TD>
"softmax outputs"     </TD><TD> bool   </TD><TD> softmax outputs                           </TD><TD> [false]</TD></TR><TR><TD>
"sigmoid outputs"     </TD><TD> bool   </TD><TD> sigmoid outputs                           </TD><TD> [false]</TD></TR><TR><TD>
"log-softmax outputs" </TD><TD> bool   </TD><TD> log-softmax outputs                       </TD><TD> [false]</TD></TR><TR><TD>
"tanh outputs"        </TD><TD> bool   </TD><TD> tanh outputs                              </TD><TD> [false]</TD></TR><TR><TD>
"sparse inputs"       </TD><TD> bool   </TD><TD> sparse inputs (to use with SparseDataSet) </TD><TD> [false]
</TR></TABLE>

<P></BLOCKQUOTE>
<DL>

<A NAME="hidden_layer"></A>
<A NAME="DOC.114.1"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B><!1><A HREF="Linear.html">Linear</A>* hidden_layer</B></TT>
<DD>the first <TT>Linear</TT> layer
<DL><DT><DD></DL><P>
<A NAME="sparse_hidden_layer"></A>
<A NAME="DOC.114.2"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B><!1><A HREF="SparseLinear.html">SparseLinear</A>* sparse_hidden_layer</B></TT>
<DD>the first <TT>Linear</TT> layer for sparse mode
<DL><DT><DD></DL><P>
<A NAME="hidden_tanh_layer"></A>
<A NAME="DOC.114.3"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B><!1><A HREF="Tanh.html">Tanh</A>* hidden_tanh_layer</B></TT>
<DD>the first <TT>Tanh</TT> layer
<DL><DT><DD></DL><P>
<A NAME="outputs_layer"></A>
<A NAME="DOC.114.4"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B><!1><A HREF="Linear.html">Linear</A>* outputs_layer</B></TT>
<DD>the second <TT>Linear</TT> layer
<DL><DT><DD></DL><P>
<A NAME="sparse_outputs_layer"></A>
<A NAME="DOC.114.5"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B><!1><A HREF="SparseLinear.html">SparseLinear</A>* sparse_outputs_layer</B></TT>
<DD>the second <TT>Linear</TT> layer for sparse mode, if there is no hidden units
<DL><DT><DD></DL><P>
<A NAME="outputs_softmax_layer"></A>
<A NAME="DOC.114.6"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B><!1><A HREF="Softmax.html">Softmax</A>* outputs_softmax_layer</B></TT>
<DD>the optional second <TT>Softmax</TT> layer
<DL><DT><DD></DL><P>
<A NAME="outputs_sigmoid_layer"></A>
<A NAME="DOC.114.7"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B><!1><A HREF="Sigmoid.html">Sigmoid</A>* outputs_sigmoid_layer</B></TT>
<DD>the optional second <TT>Sigmoid</TT> layer
<DL><DT><DD></DL><P>
<A NAME="outputs_log_softmax_layer"></A>
<A NAME="DOC.114.8"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B><!1><A HREF="LogSoftmax.html">LogSoftmax</A>* outputs_log_softmax_layer</B></TT>
<DD>the optional second <TT>Softmax</TT> layer
<DL><DT><DD></DL><P>
<A NAME="outputs_tanh_layer"></A>
<A NAME="DOC.114.9"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B><!1><A HREF="Tanh.html">Tanh</A>* outputs_tanh_layer</B></TT>
<DD>the optional second <TT>Tanh</TT> layer
<DL><DT><DD></DL><P>
<A NAME="n_hidden"></A>
<A NAME="DOC.114.10"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>int n_hidden</B></TT>
<DD>the number of hidden units
<DL><DT><DD></DL><P>
<A NAME="n_inputs"></A>
<A NAME="DOC.114.11"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>int n_inputs</B></TT>
<DD>the number of inputs
<DL><DT><DD></DL><P>
<A NAME="n_outputs"></A>
<A NAME="DOC.114.12"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>int n_outputs</B></TT>
<DD>the number of outputs
<DL><DT><DD></DL><P>
<A NAME="if this is false, add a #Tanh# layer"></A>
<A NAME="DOC.114.13"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B> if this is false, add a <TT>Tanh</TT> layer</B></TT>
<DD>if this is false, add a <TT>Tanh</TT> layer
<DL><DT><DD></DL><P>
<A NAME="Flags (in order of priority if several are true) to know what will be the output"></A>
<A NAME="DOC.114.14"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B> Flags (in order of priority if several are true) to know what will be the output</B></TT>
<DD>Flags (in order of priority if several are true)
to know what will be the output
<DL><DT><DD></DL><P>
<A NAME="is_sparse_inputs"></A>
<A NAME="DOC.114.15"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>bool is_sparse_inputs</B></TT>
<DD>To know if the inputs are sparse
<DL><DT><DD></DL><P>
<A NAME="inputs_to_outputs"></A>
<A NAME="DOC.114.16"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>bool inputs_to_outputs</B></TT>
<DD>if this is true, add a direct connection from inputs to <TT>Linear</TT>
<DL><DT><DD></DL><P>
<A NAME="weight_decay"></A>
<A NAME="DOC.114.17"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>real weight_decay</B></TT>
<DD>the eventual weight_decay
<DL><DT><DD></DL><P>
<A NAME="add_layer"></A>
<A NAME="DOC.114.18"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B><!1><A HREF="Linear.html">Linear</A>* add_layer</B></TT>
<DD>the direct <TT>Linear</TT> layer
<DL><DT><DD></DL><P>
<A NAME="sum_layer"></A>
<A NAME="DOC.114.19"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B><!1><A HREF="SumMachine.html">SumMachine</A>* sum_layer</B></TT>
<DD>if <TT>inputs_to_outputs</TT> is true, we also need a <TT>SumMachine</TT>
<DL><DT><DD></DL><P></DL>

<HR><DL><DT><B>This class has no child classes.</B></DL>

<DL><DT><DT><B>Author:</B><DD>Samy Bengio (bengio@idiap.ch)
Ronan Collobert (collober@iro.umontreal.ca)
<DD></DL><P><P><I><A HREF="index.html">Alphabetic index</A></I> <I><A HREF="HIER.html">HTML hierarchy of classes</A> or <A HREF="HIERjava.html">Java</A></I></P><HR>
<BR>
This page was generated with the help of <A HREF="http://docpp.sourceforge.net">DOC++</A>.
</BODY>
</HTML>