File: GradientMachine.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 (243 lines) | stat: -rw-r--r-- 11,560 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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

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

<H2>class  <A HREF="#DOC.DOCU">GradientMachine</A></H2></H2><BLOCKQUOTE>Gradient machine: machine which can be trained with a gradient descent.</BLOCKQUOTE>
<HR>

<H2>Inheritance:</H2>
<APPLET CODE="ClassGraph.class" WIDTH=600 HEIGHT=545>
<param name=classes value="CObject,MObject.html,CMachine,MMachine.html,CGradientMachine,MGradientMachine.html,CTanh,MTanh.html,CSumMachine,MSumMachine.html,CSparseLinear,MSparseLinear.html,CSoftmax,MSoftmax.html,CSigmoid,MSigmoid.html,CMixer,MMixer.html,CLogSoftmax,MLogSoftmax.html,CLogSigmoid,MLogSigmoid.html,CLogRBF,MLogRBF.html,CLinear,MLinear.html,CInputsSelect,MInputsSelect.html,CExp,MExp.html,CDistribution,MDistribution.html,CCriterion,MCriterion.html,CConnectedMachine,MConnectedMachine.html">
<param name=before value="M,M,M,M|_,MR_,MR_,MR_,MR_,MR_,MR_,MR_,MR_,MR_,MR_,MR_,MR_,MR_,Mr_">
<param name=after value="Md_SP,Md_,M,M,M,M,M,M,M,M,M,M,M,M,M,M,M,M">
<param name=indent value="0,1,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2,2">
<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>bool <B><A HREF="#DOC.16.1">is_free</A></B>
<DD><I><TT>true</TT> if <TT>freeMemory()</TT> has been already called</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif><!1><A HREF="List.html">List</A>* <B><A HREF="#DOC.16.2">params</A></B>
<DD><I>Contains all parameters which will be updated with the gradient descent.</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif><!1><A HREF="List.html">List</A>* <B><A HREF="#DOC.16.3">der_params</A></B>
<DD><I>Contains the derivatives for all parameters.</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>int <B><A HREF="#DOC.16.4">n_params</A></B>
<DD><I>Contains the number of parameters.</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>real* <B><A HREF="#DOC.16.5">beta</A></B>
<DD><I>Contains the derivative with respect to the inputs</I>
</DL></P>

<P><DL>
<DT><H3>Public Methods</H3><DD><DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif> <B><A HREF="#DOC.16.6">GradientMachine</A></B>()
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>virtual   void <B><A HREF="#DOC.16.7">init</A></B>()
<DD><I>It only calls <TT>allocateMemory()</TT></I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>virtual   int <B><A HREF="#DOC.16.8">numberOfParams</A></B>() = 0
<DD><I>Return the size of <TT>params</TT>.</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>virtual   void <B><A HREF="#DOC.16.9">iterInitialize</A></B>()
<DD><I>This function is called before each training iteration.</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>virtual   void <B><A HREF="#DOC.16.10">backward</A></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>) = 0
<DD><I>Given the <TT>inputs</TT> and the derivatives <TT>alpha</TT> with respect to the outputs, update <TT>beta</TT> and <TT>der_params</TT></I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>virtual   void <B><A HREF="#DOC.16.11">allocateMemory</A></B>()
<DD><I>Allocate memory.</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>virtual   void <B><A HREF="#DOC.16.12">freeMemory</A></B>()
<DD><I>Free the memory allocated with <TT>allocateMemory()</TT> <EM>Do nothing</EM> if <TT>is_free</TT> is <TT>true</TT>.</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>virtual   void <B><A HREF="#DOC.16.13">loadFILE</A></B>(FILE* <!1><A HREF="Measurer.html#DOC.30.2">file</A>)
<DD><I>By default, load the <TT>params</TT></I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>virtual   void <B><A HREF="#DOC.16.14">saveFILE</A></B>(FILE* <!1><A HREF="Measurer.html#DOC.30.2">file</A>)
<DD><I>By default, save the <TT>params</TT></I>
</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>int <B>n_inputs</B>
<DT>
<IMG ALT="o" SRC=icon2.gif>int <B>n_outputs</B>
<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>Gradient machine: machine which can
be trained with a gradient descent.

<P></BLOCKQUOTE>
<DL>

<A NAME="is_free"></A>
<A NAME="DOC.16.1"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>bool is_free</B></TT>
<DD><TT>true</TT> if <TT>freeMemory()</TT> has been already called
<DL><DT><DD></DL><P>
<A NAME="params"></A>
<A NAME="DOC.16.2"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B><!1><A HREF="List.html">List</A>* params</B></TT>
<DD>Contains all parameters which will be
updated with the gradient descent.
Almost all machines will have only one
node for this list.
Note that the integer for each node
is the number of parameters contained
in the pointer of this node.
<DL><DT><DD></DL><P>
<A NAME="der_params"></A>
<A NAME="DOC.16.3"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B><!1><A HREF="List.html">List</A>* der_params</B></TT>
<DD>Contains the derivatives for all parameters.
Warning: <TT>params</TT> and <TT>der_params</TT>
must have the same structure.
(same number of nodes, same lenghts)
<DL><DT><DD></DL><P>
<A NAME="n_params"></A>
<A NAME="DOC.16.4"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>int n_params</B></TT>
<DD>Contains the number of parameters.
It's in fact the sum of all node size
contained in <TT>params</TT> or <TT>der_params</TT>.
<DL><DT><DD></DL><P>
<A NAME="beta"></A>
<A NAME="DOC.16.5"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>real* beta</B></TT>
<DD>Contains the derivative with respect to the inputs
<DL><DT><DD></DL><P>
<A NAME="GradientMachine"></A>
<A NAME="DOC.16.6"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B> GradientMachine()</B></TT>
<DL><DT><DD></DL><P>
<A NAME="init"></A>
<A NAME="DOC.16.7"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>virtual   void init()</B></TT>
<DD>It only calls <TT>allocateMemory()</TT>
<DL><DT><DD></DL><P>
<A NAME="numberOfParams"></A>
<A NAME="DOC.16.8"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>virtual   int numberOfParams() = 0</B></TT>
<DD>Return the size of <TT>params</TT>.
Note: it's the sum of the size in each node
of <TT>params</TT>.
<DL><DT><DD></DL><P>
<A NAME="iterInitialize"></A>
<A NAME="DOC.16.9"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>virtual   void iterInitialize()</B></TT>
<DD>This function is called before each
training iteration.
By default, do nothing.
<DL><DT><DD></DL><P>
<A NAME="backward"></A>
<A NAME="DOC.16.10"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>virtual   void backward(<!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>) = 0</B></TT>
<DD>Given the <TT>inputs</TT> and the derivatives <TT>alpha</TT> with
respect to the outputs, update <TT>beta</TT> and <TT>der_params</TT>
<DL><DT><DD></DL><P>
<A NAME="allocateMemory"></A>
<A NAME="DOC.16.11"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>virtual   void allocateMemory()</B></TT>
<DD>Allocate memory.
By default, given <TT>n_inputs</TT>, <TT>n_outputs</TT> and <TT>n_params</TT>,
allocate <TT>beta</TT>, <TT>outputs</TT>, <TT>params</TT> and <TT>der_params</TT>.
<DL><DT><DD></DL><P>
<A NAME="freeMemory"></A>
<A NAME="DOC.16.12"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>virtual   void freeMemory()</B></TT>
<DD>Free the memory allocated with <TT>allocateMemory()</TT>
<EM>Do nothing</EM> if <TT>is_free</TT> is <TT>true</TT>.
Set <TT>is_free</TT> to <TT>true</TT>.
This function <EM>have to set</EM> <TT>n_params</TT>.
All classes which redefine this function should call
it in the destructor.
<DL><DT><DD></DL><P>
<A NAME="loadFILE"></A>
<A NAME="DOC.16.13"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>virtual   void loadFILE(FILE* <!1><A HREF="Measurer.html#DOC.30.2">file</A>)</B></TT>
<DD>By default, load the <TT>params</TT>
<DL><DT><DD></DL><P>
<A NAME="saveFILE"></A>
<A NAME="DOC.16.14"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>virtual   void saveFILE(FILE* <!1><A HREF="Measurer.html#DOC.30.2">file</A>)</B></TT>
<DD>By default, save the <TT>params</TT>
<DL><DT><DD></DL><P></DL>
<HR>
<DL><DT><B>Direct child classes:
</B><DD><A HREF="Tanh.html">Tanh</A><BR>
<A HREF="SumMachine.html">SumMachine</A><BR>
<A HREF="SparseLinear.html">SparseLinear</A><BR>
<A HREF="Softmax.html">Softmax</A><BR>
<A HREF="Sigmoid.html">Sigmoid</A><BR>
<A HREF="Mixer.html">Mixer</A><BR>
<A HREF="LogSoftmax.html">LogSoftmax</A><BR>
<A HREF="LogSigmoid.html">LogSigmoid</A><BR>
<A HREF="LogRBF.html">LogRBF</A><BR>
<A HREF="Linear.html">Linear</A><BR>
<A HREF="InputsSelect.html">InputsSelect</A><BR>
<A HREF="Exp.html">Exp</A><BR>
<A HREF="Distribution.html">Distribution</A><BR>
<A HREF="Criterion.html">Criterion</A><BR>
<A HREF="ConnectedMachine.html">ConnectedMachine</A><BR>
</DL>

<DL><DT><DT><B>Author:</B><DD>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>