File: DiagonalGMM.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 (307 lines) | stat: -rw-r--r-- 14,959 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
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

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

<H2>class  <A HREF="#DOC.DOCU">DiagonalGMM</A></H2></H2><BLOCKQUOTE>This class can be used to model Diagonal Gaussian Mixture Models.</BLOCKQUOTE>
<HR>

<H2>Inheritance:</H2>
<APPLET CODE="ClassGraph.class" WIDTH=600 HEIGHT=185>
<param name=classes value="CObject,MObject.html,CMachine,MMachine.html,CGradientMachine,MGradientMachine.html,CDistribution,MDistribution.html,CDiagonalGMM,MDiagonalGMM.html,CKmeans,MKmeans.html">
<param name=before value="M,M,M,M,M,M^_">
<param name=after value="Md_SPSPSP,Md_SPSP,Md_SP,Md_,M,M">
<param name=indent value="0,1,2,3,4,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>int <B><A HREF="#DOC.89.1">n_gaussians</A></B>
<DD><I>number of Gaussians in the mixture</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>real <B><A HREF="#DOC.89.2">prior_weights</A></B>
<DD><I>prior weights of the Gaussians, used in EM to give  a small prior on each Gaussian</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif><!1><A HREF="EMTrainer.html">EMTrainer</A>* <B><A HREF="#DOC.89.3">initial_kmeans_trainer</A></B>
<DD><I>optional initializations if nothing is given, then random, at your own risks.</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif><!1><A HREF="List.html">List</A>* <B><A HREF="#DOC.89.4">initial_kmeans_trainer_measurers</A></B>
<DD><I>as well as a measurer of this trainer</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif><!1><A HREF="List.html">List</A>* <B><A HREF="#DOC.89.5">initial_params</A></B>
<DD><I>or one can give an initial parameter List</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>char* <B><A HREF="#DOC.89.6">initial_file</A></B>
<DD><I>or one can give an initial file</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>real* <B><A HREF="#DOC.89.7">log_weights</A></B>
<DD><I>the pointers to the parameters</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>real* <B><A HREF="#DOC.89.8">dlog_weights</A></B>
<DD><I>the pointers to the derivative of the parameters</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>real* <B><A HREF="#DOC.89.9">var_threshold</A></B>
<DD><I>this contains the minimal value of each variance</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>real** <B><A HREF="#DOC.89.10">log_probabilities_g</A></B>
<DD><I>for each frame, for each gaussian, keep its log probability</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>real* <B><A HREF="#DOC.89.11">sum_log_var_plus_n_obs_log_2_pi</A></B>
<DD><I>in order to faster the computation, we can do some "pre-computation" pre-computed sum_log_var + n_obs * log_2_pi</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>real** <B><A HREF="#DOC.89.12">minus_half_over_var</A></B>
<DD><I>pre-computed -05 / var</I>
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>real** <B><A HREF="#DOC.89.13">means_acc</A></B>
<DD><I>accumulators for EM</I>
</DL></P>

<P><DL>
<DT><H3>Public Methods</H3><DD><DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif> <B><A HREF="#DOC.89.14">DiagonalGMM</A></B>(int n_observations_, int n_gaussians_, real* var_threshold_, real prior_weights_)
<DT>
<IMG ALT="[more]" BORDER=0 SRC=icon1.gif>virtual   real <B><A HREF="#DOC.89.15">frameLogProbabilityOneGaussian</A></B>(real* <!1><A HREF="SeqExample.html#DOC.107.4">observations</A>, real* <!1><A HREF="SeqExample.html#DOC.107.3">inputs</A>, int g)
<DD><I>this method returns the log probability of the "g" Gaussian</I>
</DL></P>

</DL>
<HR><H3>Inherited from <A HREF="Distribution.html">Distribution</A>:</H3>
<DL>
<P><DL>
<DT><H3>Public Fields</H3><DD><DT>
<IMG ALT="o" SRC=icon2.gif>int <B>n_observations</B>
<DT>
<IMG ALT="o" SRC=icon2.gif>int <B>tot_n_frames</B>
<DT>
<IMG ALT="o" SRC=icon2.gif>int <B>max_n_frames</B>
<DT>
<IMG ALT="o" SRC=icon2.gif>real <B>log_probability</B>
<DT>
<IMG ALT="o" SRC=icon2.gif>real* <B>log_probabilities</B>
</DL></P>

<P><DL>
<DT><H3>Public Methods</H3><DD><DT>
<IMG ALT="o" SRC=icon2.gif>virtual   real <B>logProbability</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   real <B>viterbiLogProbability</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   real <B>frameLogProbability</B>(real* <!1><A HREF="SeqExample.html#DOC.107.4">observations</A>, real* <!1><A HREF="SeqExample.html#DOC.107.3">inputs</A>, int t)
<DT>
<IMG ALT="o" SRC=icon2.gif>virtual   void <B>frameExpectation</B>(real* <!1><A HREF="SeqExample.html#DOC.107.4">observations</A>, real* <!1><A HREF="SeqExample.html#DOC.107.3">inputs</A>, int t)
<DT>
<IMG ALT="o" SRC=icon2.gif>virtual   void <B>eMIterInitialize</B>()
<DT>
<IMG ALT="o" SRC=icon2.gif>virtual   void <B>iterInitialize</B>()
<DT>
<IMG ALT="o" SRC=icon2.gif>virtual   void <B>eMSequenceInitialize</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>sequenceInitialize</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>eMAccPosteriors</B>(<!1><A HREF="List.html">List</A>* <!1><A HREF="SeqExample.html#DOC.107.3">inputs</A>, real log_posterior)
<DT>
<IMG ALT="o" SRC=icon2.gif>virtual   void <B>frameEMAccPosteriors</B>(real* <!1><A HREF="SeqExample.html#DOC.107.4">observations</A>, real log_posterior, real* <!1><A HREF="SeqExample.html#DOC.107.3">inputs</A>, int t)
<DT>
<IMG ALT="o" SRC=icon2.gif>virtual   void <B>viterbiAccPosteriors</B>(<!1><A HREF="List.html">List</A>* <!1><A HREF="SeqExample.html#DOC.107.3">inputs</A>, real log_posterior)
<DT>
<IMG ALT="o" SRC=icon2.gif>virtual   void <B>frameViterbiAccPosteriors</B>(real* <!1><A HREF="SeqExample.html#DOC.107.4">observations</A>, real log_posterior, real* <!1><A HREF="SeqExample.html#DOC.107.3">inputs</A>, int t)
<DT>
<IMG ALT="o" SRC=icon2.gif>virtual   void <B>eMUpdate</B>()
<DT>
<IMG ALT="o" SRC=icon2.gif>virtual   void <B>decode</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>eMForward</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>viterbiForward</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>frameBackward</B>(real* <!1><A HREF="SeqExample.html#DOC.107.4">observations</A>, real* <!1><A HREF="QCMachine.html#DOC.40.5">alpha</A>, real* <!1><A HREF="SeqExample.html#DOC.107.3">inputs</A>, int t)
<DT>
<IMG ALT="o" SRC=icon2.gif>virtual   void <B>viterbiBackward</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>)
</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>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>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>This class can be used to model Diagonal Gaussian Mixture Models.
They can be trained using either EM (with EMTrainer) or gradient descent
(with GMTrainer).

<P></BLOCKQUOTE>
<DL>

<A NAME="n_gaussians"></A>
<A NAME="DOC.89.1"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>int n_gaussians</B></TT>
<DD>number of Gaussians in the mixture
<DL><DT><DD></DL><P>
<A NAME="prior_weights"></A>
<A NAME="DOC.89.2"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>real prior_weights</B></TT>
<DD>prior weights of the Gaussians, used in EM to give 
a small prior on each Gaussian
<DL><DT><DD></DL><P>
<A NAME="initial_kmeans_trainer"></A>
<A NAME="DOC.89.3"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B><!1><A HREF="EMTrainer.html">EMTrainer</A>* initial_kmeans_trainer</B></TT>
<DD>optional initializations
if nothing is given, then random, at your own risks.
one can give a initial trainer containing a kmeans
<DL><DT><DD></DL><P>
<A NAME="initial_kmeans_trainer_measurers"></A>
<A NAME="DOC.89.4"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B><!1><A HREF="List.html">List</A>* initial_kmeans_trainer_measurers</B></TT>
<DD>as well as a measurer of this trainer
<DL><DT><DD></DL><P>
<A NAME="initial_params"></A>
<A NAME="DOC.89.5"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B><!1><A HREF="List.html">List</A>* initial_params</B></TT>
<DD>or one can give an initial parameter List
<DL><DT><DD></DL><P>
<A NAME="initial_file"></A>
<A NAME="DOC.89.6"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>char* initial_file</B></TT>
<DD>or one can give an initial file
<DL><DT><DD></DL><P>
<A NAME="log_weights"></A>
<A NAME="DOC.89.7"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>real* log_weights</B></TT>
<DD>the pointers to the parameters
<DL><DT><DD></DL><P>
<A NAME="dlog_weights"></A>
<A NAME="DOC.89.8"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>real* dlog_weights</B></TT>
<DD>the pointers to the derivative of the parameters
<DL><DT><DD></DL><P>
<A NAME="var_threshold"></A>
<A NAME="DOC.89.9"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>real* var_threshold</B></TT>
<DD>this contains the minimal value of each variance
<DL><DT><DD></DL><P>
<A NAME="log_probabilities_g"></A>
<A NAME="DOC.89.10"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>real** log_probabilities_g</B></TT>
<DD>for each frame, for each gaussian, keep its log probability
<DL><DT><DD></DL><P>
<A NAME="sum_log_var_plus_n_obs_log_2_pi"></A>
<A NAME="DOC.89.11"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>real* sum_log_var_plus_n_obs_log_2_pi</B></TT>
<DD>in order to faster the computation, we can do some "pre-computation"
pre-computed sum_log_var + n_obs * log_2_pi
<DL><DT><DD></DL><P>
<A NAME="minus_half_over_var"></A>
<A NAME="DOC.89.12"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>real** minus_half_over_var</B></TT>
<DD>pre-computed -05 / var
<DL><DT><DD></DL><P>
<A NAME="means_acc"></A>
<A NAME="DOC.89.13"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>real** means_acc</B></TT>
<DD>accumulators for EM
<DL><DT><DD></DL><P>
<A NAME="DiagonalGMM"></A>
<A NAME="DOC.89.14"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B> DiagonalGMM(int n_observations_, int n_gaussians_, real* var_threshold_, real prior_weights_)</B></TT>
<DL><DT><DD></DL><P>
<A NAME="frameLogProbabilityOneGaussian"></A>
<A NAME="DOC.89.15"></A>
<DT><IMG ALT="o" BORDER=0 SRC=icon2.gif><TT><B>virtual   real frameLogProbabilityOneGaussian(real* <!1><A HREF="SeqExample.html#DOC.107.4">observations</A>, real* <!1><A HREF="SeqExample.html#DOC.107.3">inputs</A>, int g)</B></TT>
<DD>this method returns the log probability of the "g" Gaussian
<DL><DT><DD></DL><P></DL>
<HR>
<DL><DT><B>Direct child classes:
</B><DD><A HREF="Kmeans.html">Kmeans</A><BR>
</DL>

<DL><DT><DT><B>Author:</B><DD>Samy Bengio (bengio@idiap.ch)
<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>