blairzheng commited on
Commit
12f3253
1 Parent(s): 188c37a

first normal version

Browse files
App.py ADDED
@@ -0,0 +1,396 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import random
2
+
3
+ import gradio as gr
4
+ from DPMInteractive import g_st, g_et, g_num, g_res
5
+ from DPMInteractive import init_change, shrink_change, conv_change
6
+ from DPMInteractive import cond_prob_init_change, cond_prob_alpha_change, cond_prob_cond_change
7
+ from DPMInteractive import forward_init_change, forward_seq_apply
8
+ from DPMInteractive import backward_seq_apply, fit_and_backward_apply
9
+ from DPMInteractive import contraction_init_change, contraction_alpha_change, change_two_inputs_seed, contraction_apply
10
+ from DPMInteractive import fixed_point_init_change, fixed_point_apply_iterate
11
+ from DPMInteractive import forward_plot_part, backward_plot_part, fit_plot_part, fixed_plot_part
12
+ from RenderMarkdown import md_introduction_block, md_transform_block, md_likelihood_block, md_posterior_block
13
+ from RenderMarkdown import md_forward_process_block, md_backward_process_block, md_fit_posterior_block
14
+ from RenderMarkdown import md_posterior_transform_block, md_deconvolution_block, md_reference_block, md_about_block
15
+ from Misc import g_css, js_head, js_load
16
+
17
+
18
+ def gr_empty_space(size=1):
19
+ space = gr.Markdown(" "*size, elem_classes="bgc")
20
+ return space
21
+
22
+
23
+ def gr_number(label=None, minimum=None, maximum=None, value=None, step=1.0, precision=0, min_width=160):
24
+ number = gr.Number(label=label, minimum=minimum, maximum=maximum, value=value, step=step,
25
+ precision=precision, min_width=min_width)
26
+ return number
27
+
28
+
29
+ def gr_val(val):
30
+ return gr.Number(value=val, visible=False)
31
+
32
+
33
+ def apply_listener(apply_button, apply_func, plot_func, reseted_state, apply_inputs, apply_outputs,
34
+ plot_inputs, plot_outputs):
35
+ def enable_button(value):
36
+ button = gr.Button(value=value, interactive=True)
37
+ return button
38
+
39
+ def disable_button(value):
40
+ button = gr.Button(value=value, interactive=False)
41
+ return button, None
42
+
43
+ listener = apply_button.click(disable_button, [apply_button], [apply_button, reseted_state])
44
+ listener = listener.then(apply_func, apply_inputs, apply_outputs, show_progress="minimal")
45
+ listener = listener.then(plot_func, plot_inputs + [gr_val(0)], plot_outputs, show_progress="minimal")
46
+ listener = listener.then(plot_func, plot_inputs + [gr_val(1)], plot_outputs, show_progress="minimal")
47
+ listener = listener.then(plot_func, plot_inputs + [gr_val(2)], plot_outputs, show_progress="minimal")
48
+ listener = listener.then(enable_button, [apply_button], apply_button)
49
+
50
+ return
51
+
52
+
53
+ def transform_block():
54
+ x_state = gr.State(value=None)
55
+ x_pdf_state = gr.State(value=None)
56
+
57
+ title = "Demo 1 - Random Variable Transform In DPM"
58
+ with gr.Accordion(label=title, elem_classes="first_demo"):
59
+ with gr.Group(elem_classes="normal"):
60
+ with gr.Row():
61
+ init_seed = gr.Number(label="random seed", value=100, minimum=0, step=1)
62
+ shrink_alpha = gr.Slider(label="alpha of linear transform", value=0.7, minimum=0.3, maximum=0.999, step=0.001)
63
+ conv_alpha = gr.Slider(label="alpha of add noises", value=0.995, minimum=0.3, maximum=0.999, step=0.001)
64
+ gr_empty_space(10)
65
+ gr_empty_space(5)
66
+
67
+ with gr.Row():
68
+ inp_plot = gr.Plot(label="input random variable's pdf", show_label=False)
69
+ shrink_plot = gr.Plot(label="pdf after linear transform", show_label=False)
70
+ conv_plot = gr.Plot(label="pdf after add noises", show_label=False)
71
+ shrink_conv_plot = gr.Plot(label="pdf after linear transform and add noises", show_label=False)
72
+ gr_empty_space(5)
73
+
74
+ init_inputs = [init_seed, shrink_alpha, conv_alpha]
75
+ init_outputs = [inp_plot, x_state, x_pdf_state, shrink_plot, conv_plot, shrink_conv_plot]
76
+ init_seed.change(init_change, init_inputs, init_outputs, show_progress="minimal")
77
+
78
+ shrink_inputs = [x_state, x_pdf_state, shrink_alpha, conv_alpha]
79
+ shrink_outputs = [shrink_plot, shrink_conv_plot]
80
+ shrink_alpha.change(shrink_change, shrink_inputs, shrink_outputs, show_progress="minimal")
81
+
82
+ conv_inputs = [x_state, x_pdf_state, shrink_alpha, conv_alpha]
83
+ conv_outputs = [conv_plot, shrink_conv_plot]
84
+ conv_alpha.change(conv_change, conv_inputs, conv_outputs, show_progress="minimal")
85
+
86
+ init_param = dict(method=init_change, inputs=init_inputs, outputs=init_outputs)
87
+ return init_param
88
+
89
+
90
+ def cond_prob_block():
91
+ x_state = gr.State(value=None)
92
+ x_pdf_state = gr.State(value=None)
93
+
94
+ z_state = gr.State(value=None)
95
+ xcz_pdf_state = gr.State(value=None)
96
+
97
+ title = "Demo 2 - Likelihood and Posterior of Transform"
98
+ with gr.Accordion(label=title, elem_classes="first_demo"):
99
+ with gr.Group(elem_classes="normal"):
100
+ with gr.Row():
101
+ seed = gr_number("random seed", 0, 1E6, 100, 1, 0, min_width=80)
102
+ alpha = gr_number("alpha", 0.001, 0.999, 0.98, 0.001, 3, min_width=80)
103
+ cond_val = gr.Slider(label="fixed condition value", value=0.2, minimum=g_st, maximum=g_et, step=0.1)
104
+ gr_empty_space(5)
105
+ gr_empty_space(5)
106
+
107
+ with gr.Row():
108
+ inp_plot = gr.Plot(label="input variable's pdf", min_width=80, show_label=False)
109
+ out_plot = gr.Plot(label="output variable's pdf", min_width=80, show_label=False)
110
+ forward_cond_plot = gr.Plot(label="forward conditional pdf", min_width=80, show_label=False)
111
+ backward_cond_plot = gr.Plot(label="backward conditional pdf", min_width=80, show_label=False)
112
+ fixed_cond_plot = gr.Plot(label="backward fixed conditional pdf", min_width=80, show_label=False)
113
+
114
+ init_inputs = [seed, alpha, cond_val]
115
+ init_outputs = [x_state, x_pdf_state, z_state, xcz_pdf_state, inp_plot, out_plot,
116
+ forward_cond_plot, backward_cond_plot, fixed_cond_plot]
117
+ seed.change(cond_prob_init_change, init_inputs, init_outputs, show_progress="minimal")
118
+
119
+ alpha_inputs = [x_state, x_pdf_state, alpha, cond_val]
120
+ alpha_outputs = [z_state, xcz_pdf_state, out_plot, forward_cond_plot, backward_cond_plot, fixed_cond_plot]
121
+ alpha.change(cond_prob_alpha_change, alpha_inputs, alpha_outputs, show_progress="minimal")
122
+
123
+ cond_inputs = [x_state, x_pdf_state, z_state, xcz_pdf_state, alpha, cond_val]
124
+ cond_outputs = [backward_cond_plot, fixed_cond_plot]
125
+ cond_val.change(cond_prob_cond_change, cond_inputs, cond_outputs, show_progress="minimal")
126
+
127
+ init_param = dict(method=cond_prob_init_change, inputs=init_inputs, outputs=init_outputs)
128
+
129
+ return init_param
130
+
131
+
132
+ def forward_block(seq_info_state):
133
+ x_state = gr.State(value=None)
134
+ x_pdf_state = gr.State(value=None)
135
+
136
+ plot_state = gr.State(value=None)
137
+
138
+ title = "Demo 3.1 - Transform To Normal Distribution Iteratively"
139
+ with gr.Accordion(label=title, elem_classes="first_demo"):
140
+ with gr.Group(elem_classes="normal"):
141
+ with gr.Row():
142
+ seed = gr_number("random seed", 0, 1E6, 100, 1, 0, min_width=80)
143
+ st_alpha = gr_number("start alpha", 0.5, 0.999, 0.98, 0.001, 3, min_width=80)
144
+ et_alpha = gr_number("end alpha", 0.5, 0.999, 0.98, 0.001, 3, min_width=80)
145
+ step = gr.Slider(label="step", value=7, minimum=2, maximum=15, step=1, min_width=80)
146
+ apply_button = gr.Button(value="apply", min_width=80)
147
+
148
+ node_plot = gr.Plot(label="latent variable's pdf", show_label=False)
149
+ with gr.Accordion("posterior pdf", elem_classes="second"):
150
+ cond_plot = gr.Plot(show_label=False)
151
+
152
+ apply_inputs = [x_state, x_pdf_state, st_alpha, et_alpha, step]
153
+ apply_outputs = [seq_info_state, plot_state]
154
+ plot_outputs = [node_plot, cond_plot]
155
+ apply_listener(apply_button, forward_seq_apply, forward_plot_part,
156
+ seq_info_state, apply_inputs, apply_outputs, [plot_state], plot_outputs)
157
+
158
+ init_outputs = [x_state, x_pdf_state, node_plot, cond_plot]
159
+ seed.change(forward_init_change, inputs=[seed], outputs=init_outputs, show_progress="minimal")
160
+
161
+ init_param = dict(method=forward_init_change, inputs=[seed], outputs=init_outputs)
162
+
163
+ return init_param
164
+
165
+
166
+ def backward_block(seq_info_state):
167
+ plot_state = gr.State(value=None)
168
+ placeholder = gr.State(value=None)
169
+
170
+ title = "Demo 3.2 - Recover From Normal Distribution Iteratively"
171
+ with gr.Accordion(label=title, elem_classes="first_demo"):
172
+ with gr.Group(elem_classes="normal"):
173
+ with gr.Row():
174
+ is_forward_pdf = gr.Checkbox(label="forward pdf", value=True)
175
+ is_backward_pdf = gr.Checkbox(label="backward pdf", value=True)
176
+ noise_seed = gr_number("nose random seed", 0, 1E6, 200, 1, 0, min_width=80)
177
+ noise_ratio = gr_number("noise ratio", 0, 1, 0.0, 0.1, 1, min_width=80)
178
+ apply_button = gr.Button(value="apply")
179
+
180
+ node_plot = gr.Plot(label="each variable's pdf", show_label=False)
181
+
182
+ inputs = [seq_info_state, is_forward_pdf, is_backward_pdf, noise_seed, noise_ratio]
183
+ outputs = [node_plot, plot_state]
184
+ apply_listener(apply_button, backward_seq_apply, backward_plot_part,
185
+ placeholder, inputs, outputs, [plot_state], [node_plot])
186
+ return
187
+
188
+
189
+ def fit_posterior_block(seq_info_state):
190
+ plot_state = gr.State(value=None)
191
+ placeholder = gr.State(value=None)
192
+
193
+ title = "Demo 3.3 - Fitting Posterior with Conditional Gaussian Model"
194
+ with gr.Accordion(label=title, elem_classes="first_demo"):
195
+ with gr.Group(elem_classes="normal"):
196
+ with gr.Row():
197
+ info = "show forward pdf"
198
+ is_forward_pdf = gr.Checkbox(label="forward pdf", info=info, value=True)
199
+ info = "show origin backward pdf"
200
+ is_backward_pdf = gr.Checkbox(label="backward pdf", info=info, value=False)
201
+ info = "show backward pdf after fitting posterior with conditonal Gaussian"
202
+ is_show_pos = gr.Checkbox(label="fitted posterior", info=info, value=True)
203
+ apply_button = gr.Button(value="apply")
204
+
205
+ node_plot = gr.Plot(label="each variable's pdf", show_label=False)
206
+ with gr.Accordion("fitted posterior's pdf", elem_classes="second"):
207
+ cond_plot = gr.Plot(show_label=False)
208
+
209
+ inputs = [seq_info_state, is_forward_pdf, is_backward_pdf]
210
+ outputs = [node_plot, cond_plot, plot_state]
211
+ apply_listener(apply_button, fit_and_backward_apply, fit_plot_part,
212
+ placeholder, inputs, outputs, [plot_state, is_show_pos], [node_plot, cond_plot])
213
+
214
+ return
215
+
216
+
217
+ def contraction_block():
218
+ x_state = gr.State(value=None)
219
+ x_pdf_state = gr.State(value=None)
220
+ z_state = gr.State(value=None)
221
+ xcz_pdf_state = gr.State(value=None)
222
+ zt_state = gr.State(value=None)
223
+ zt_pdf_state = gr.State(value=None)
224
+
225
+ plot_state = gr.State(value=None)
226
+ placeholder = gr.State(value=None)
227
+
228
+ ctr_title = "Demo 4.1 - Posterior Transform is a Contraction Mapping"
229
+ with gr.Accordion(label=ctr_title, elem_classes="first_demo"):
230
+ with gr.Row(elem_classes="normal"):
231
+ with gr.Column(scale=3):
232
+ with gr.Group():
233
+ with gr.Row():
234
+ ctr_init_seed = gr_number("random seed", 0, 1E6, 100, 1, 0, min_width=80)
235
+ ctr_alpha = gr_number("alpha", 0.001, 0.999, 0.95, 0.001, 3, min_width=80)
236
+ gr_empty_space(5)
237
+
238
+ with gr.Row():
239
+ inp_plot = gr.Plot(label="input variable pdf", min_width=80, show_label=False)
240
+ pos_plot = gr.Plot(label="posterior pdf", min_width=80, show_label=False)
241
+ out_plot = gr.Plot(label="output variable pdf", min_width=80, show_label=False)
242
+
243
+ with gr.Column(scale=2):
244
+ with gr.Group():
245
+ with gr.Row():
246
+ change_inputs_seed = gr.Button(value="change inputs seed")
247
+ two_inputs_seed = gr_number("two inputs random seed", 0, 1E9, 100, 1, 0)
248
+ inp_out_plot = gr.Plot(label="input and output pdf of inverse transform", show_label=False)
249
+
250
+ fixed_title = "Demo 4.2 - Posterior Transform Have a Converging Point"
251
+ with gr.Accordion(label=fixed_title, elem_classes="first_demo"):
252
+ with gr.Group(elem_classes="normal"):
253
+ with gr.Row():
254
+ fixed_point_seed = gr_number("input seed", 0, 1E6, 200, 1, 0, min_width=80)
255
+ iterate_number = gr_number("iterate number", 0, 1E6, 500, 1, 0, min_width=80)
256
+ is_show_pow = gr.Checkbox(label="show power matrix", value=True)
257
+ fixed_iterate_btn = gr.Button(value="apply iteration transform")
258
+ gr_empty_space(5)
259
+ gr_empty_space(5)
260
+ fixed_point_plot = gr.Plot(label="result of iteration of inverse transform", show_label=False)
261
+ with gr.Accordion("power matrix of posterior", elem_classes="second"):
262
+ power_mat_plot = gr.Plot(show_label=False)
263
+
264
+ ctr_init_inputs = [ctr_init_seed, ctr_alpha, two_inputs_seed]
265
+ ctr_init_outputs = [inp_plot, x_state, x_pdf_state, pos_plot, out_plot, z_state, xcz_pdf_state, inp_out_plot]
266
+ ctr_init_seed.change(contraction_init_change, ctr_init_inputs, ctr_init_outputs, show_progress="minimal")
267
+
268
+ ctr_alpha_inputs = [x_state, x_pdf_state, ctr_alpha, two_inputs_seed]
269
+ ctr_alpha_outputs = [pos_plot, out_plot, z_state, xcz_pdf_state, inp_out_plot]
270
+ ctr_alpha.change(contraction_alpha_change, ctr_alpha_inputs, ctr_alpha_outputs, show_progress="minimal")
271
+
272
+ ctr_apply_inputs, ctr_apply_outputs = [x_state, x_pdf_state, xcz_pdf_state, two_inputs_seed], [inp_out_plot]
273
+ two_inputs_seed.change(contraction_apply, ctr_apply_inputs, ctr_apply_outputs, show_progress="minimal")
274
+ change_inputs_seed.click(change_two_inputs_seed, None, two_inputs_seed, show_progress="minimal")
275
+
276
+ fixed_init_inputs = [fixed_point_seed, x_state, x_pdf_state]
277
+ fixed_init_outputs = [fixed_point_plot, zt_state, zt_pdf_state, power_mat_plot]
278
+ fixed_point_seed.change(fixed_point_init_change, fixed_init_inputs, fixed_init_outputs, show_progress="minimal")
279
+
280
+ iterate_inputs = [x_state, x_pdf_state, zt_state, zt_pdf_state, xcz_pdf_state, iterate_number, is_show_pow]
281
+ iterate_outputs = [fixed_point_plot, power_mat_plot, plot_state]
282
+ plot_outputs = [fixed_point_plot, power_mat_plot]
283
+ apply_listener(fixed_iterate_btn, fixed_point_apply_iterate, fixed_plot_part, placeholder,
284
+ iterate_inputs, iterate_outputs, [plot_state], plot_outputs)
285
+
286
+ ctr_init_param = dict(method=contraction_init_change, inputs=ctr_init_inputs, outputs=ctr_init_outputs)
287
+ fixed_init_param = dict(method=fixed_point_init_change, inputs=fixed_init_inputs, outputs=fixed_init_outputs)
288
+ return ctr_init_param, fixed_init_param
289
+
290
+
291
+ def md_header_block():
292
+ gr.Markdown(""" </br> </br>
293
+ <center>
294
+ <h1 style="display:block">
295
+ Understanding Diffusion Probability Model<span style='color: orange'>&nbsp;Interactively </span>
296
+ </h1>
297
+ </center>
298
+ </br> </br> </br>""")
299
+ return
300
+
301
+
302
+ def run_app():
303
+
304
+ with gr.Blocks(css=g_css, head=js_head, js=js_load) as demo:
305
+ seq_info_state = gr.State(value=None)
306
+
307
+ # this is needed for offline render markdown in order to import katex.css
308
+ gr.Markdown("$$ $$", visible=False)
309
+
310
+ md_header_block()
311
+
312
+ md_introduction_block()
313
+
314
+ md_transform_block()
315
+
316
+ rets = transform_block()
317
+ trans_param = rets
318
+
319
+ md_likelihood_block()
320
+
321
+ md_posterior_block()
322
+
323
+ rets = cond_prob_block()
324
+ cond_param = rets
325
+
326
+ md_forward_process_block()
327
+
328
+ rets = forward_block(seq_info_state)
329
+ fore_param = rets
330
+
331
+ md_backward_process_block()
332
+
333
+ backward_block(seq_info_state)
334
+
335
+ md_fit_posterior_block()
336
+
337
+ fit_posterior_block(seq_info_state)
338
+
339
+ md_posterior_transform_block()
340
+
341
+ rets = contraction_block()
342
+ ctr_param, fixed_param = rets
343
+
344
+ md_deconvolution_block()
345
+
346
+ md_reference_block()
347
+
348
+ md_about_block()
349
+
350
+ # running initiation consecutively because of the bug of multithreading rendering mathtext in matplotlib
351
+ demo.load(trans_param["method"], trans_param["inputs"], trans_param["outputs"], show_progress="minimal").\
352
+ then(cond_param["method"], cond_param["inputs"], cond_param["outputs"], show_progress="minimal"). \
353
+ then(fore_param["method"], fore_param["inputs"], fore_param["outputs"], show_progress="minimal"). \
354
+ then(ctr_param["method"], ctr_param["inputs"], ctr_param["outputs"], show_progress="minimal"). \
355
+ then(fixed_param["method"], fixed_param["inputs"], fixed_param["outputs"], show_progress="minimal")
356
+
357
+ demo.launch(allowed_paths=["/"])
358
+
359
+ return
360
+
361
+
362
+ def gtx():
363
+
364
+ with gr.Blocks(css=g_css, head=js_head, js=js_load) as demo:
365
+ gr.Markdown("$$ $$", visible=False)
366
+
367
+ md_introduction_block()
368
+
369
+ md_transform_block()
370
+
371
+ md_likelihood_block()
372
+
373
+ md_posterior_block()
374
+
375
+ md_forward_process_block()
376
+
377
+ md_backward_process_block()
378
+
379
+ md_fit_posterior_block()
380
+
381
+ md_posterior_transform_block()
382
+
383
+ md_deconvolution_block()
384
+
385
+ md_reference_block()
386
+
387
+ md_about_block()
388
+
389
+ demo.queue()
390
+ demo.launch(allowed_paths=["/"])
391
+ return
392
+
393
+
394
+ if __name__ == "__main__":
395
+ run_app()
396
+ # gtx()
DPMInteractive.py ADDED
@@ -0,0 +1,906 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import os
3
+ import random
4
+ import time
5
+
6
+ import numpy as np
7
+ import pandas as pd
8
+ import gradio as gr
9
+ import copy
10
+ import scipy
11
+ import scipy.signal
12
+ from scipy.stats import norm
13
+ import matplotlib
14
+ import matplotlib.pyplot as plt
15
+ from scipy.spatial.distance import jensenshannon
16
+ from scipy.optimize import curve_fit
17
+
18
+ # import multiprocessing
19
+ # from multiprocessing import Pool, Queue, Manager
20
+
21
+ plt.rcParams['figure.constrained_layout.use'] = True
22
+ plt.rcParams['figure.max_open_warning'] = 50
23
+ plt.rcParams['interactive'] = False
24
+ plt.ioff()
25
+
26
+
27
+ g_st, g_et, g_num = -2.3, 2.3, 460
28
+ g_res = (g_et-g_st)/g_num
29
+ g_fw, g_fh = 3, 3.2
30
+
31
+
32
+ ###################################################################################
33
+ # common function
34
+ ###################################################################################
35
+
36
+ def rs(str_label):
37
+ return str_label.replace("z_{0}", "x").replace("z_0", "x")
38
+
39
+
40
+ def set_axis(axis, x_range, y_range, x_label, y_label):
41
+ matplotlib.rcParams.update({'font.size': 10, "axes.linewidth": 0.5, "lines.linewidth": 0.7, "figure.dpi": 100})
42
+
43
+ if x_range is not None:
44
+ axis.set_xlim(*x_range)
45
+ if y_range is not None:
46
+ axis.set_ylim(*y_range)
47
+ if x_label is not None:
48
+ axis.set_xlabel(x_label)
49
+ if y_label is not None:
50
+ axis.set_ylabel(y_label)
51
+
52
+ axis.xaxis.set_major_locator(plt.MultipleLocator(1))
53
+ st, et = x_range[0]//0.2*0.2, x_range[1]//0.2*0.2
54
+ count = int((et - st)/0.2)
55
+ axis.set_xticks(np.linspace(st, et, count+1), minor=True)
56
+
57
+ return
58
+
59
+
60
+ def plot_pdf(x, x_pdf, max_y=3.2, title=None, titlesize=10,
61
+ label=None, xlabel="domain", ylabel="pdf", style="solid", color="blue"):
62
+ fig = plt.figure(figsize=(g_fw, g_fh))
63
+ ax = fig.add_subplot(111)
64
+ axis_pdf(ax, x, x_pdf, max_y, title, titlesize, label, xlabel, ylabel, style, color)
65
+ return fig
66
+
67
+
68
+ def plot_2d_pdf(x, y, pdf, cond_val=None, label=None, title=None, titlesize=10, xlabel="x", ylabel="y"):
69
+ fig = plt.figure(figsize=(g_fw, g_fh))
70
+ ax = fig.add_subplot(111)
71
+ axis_2d_pdf(ax, x, y, pdf, cond_val, title, titlesize, label, xlabel, ylabel)
72
+ return fig
73
+
74
+
75
+ def axis_pdf(ax, x, x_pdf, max_y=3.2, title=None, titlesize=10,
76
+ label=None, xlabel="domain", ylabel="pdf", style="solid", color="blue"):
77
+ set_axis(ax, (x[0], x[-1]), (0, max_y), xlabel, ylabel)
78
+ ax.plot(x, x_pdf, label=label, color=color, linestyle=style)
79
+ if title is not None:
80
+ ax.set_title(title, fontsize=titlesize)
81
+ ax.legend()
82
+ return
83
+
84
+
85
+ def axis_2d_pdf(ax, x, y, pdf, cond_val=None, title=None, titlesize=10, label=None, xlabel="x", ylabel="y"):
86
+ set_axis(ax, (x[0], x[-1]), (y[0], y[-1]), xlabel, ylabel)
87
+ ax.contourf(x, y, pdf, label=label)
88
+ if title is not None:
89
+ ax.set_title(title, fontsize=titlesize)
90
+ if cond_val is not None:
91
+ ax.plot([cond_val, cond_val], [y[-1], y[0]], color="orange")
92
+ ax.legend()
93
+ return
94
+
95
+
96
+ def add_random_noise(x_pdf, noise_ratio, seed, st, et, num, res):
97
+ _, noise_pdf = init_x_pdf(st, et, num, seed=seed)
98
+ z_pdf = (1-noise_ratio)*x_pdf + noise_ratio*noise_pdf
99
+ z_pdf = z_pdf/(res*z_pdf.sum())
100
+ return z_pdf
101
+
102
+
103
+ def power_range(st, et, num, coeff=2):
104
+ roi_nodes = st + np.ceil((np.linspace(0, 1, num=num) ** coeff) * (et - st))
105
+ roi_nodes = roi_nodes.astype(int)
106
+
107
+ for ii in range(1, len(roi_nodes)):
108
+ if roi_nodes[ii] <= roi_nodes[ii - 1]:
109
+ roi_nodes[ii] = roi_nodes[ii - 1] + 1
110
+ roi_nodes[ii] = int(roi_nodes[ii])
111
+
112
+ return list(roi_nodes)
113
+
114
+
115
+ def init_x_pdf(st, et, num, modal_count=16, shape_type=0, seed=200):
116
+ rg = np.random.RandomState(int(seed))
117
+
118
+ C = modal_count
119
+ res = (et - st) / num
120
+
121
+ if shape_type == 0:
122
+ mean_st, mean_et = -1.1, 1.1
123
+ std_st, std_et = 0.03, 0.20
124
+ elif shape_type == 1:
125
+ mean_st, mean_et = -1.5, 1.5
126
+ std_st, std_et = 0.01, 0.09
127
+ elif shape_type == 2:
128
+ mean_st, mean_et = -1.5, 1.5
129
+ std_st, std_et = 0.05, 0.35
130
+ else:
131
+ mean_st, mean_et = -0.8, 0.8
132
+ std_st, std_et = 0.05, 0.35
133
+
134
+ mean = mean_st + rg.random(C) * (mean_et - mean_st)
135
+ std = std_st + rg.random(C) * (std_et - std_st)
136
+ weight = 1 + rg.random(C) * 10
137
+ weight = weight / weight.sum()
138
+
139
+ x = np.linspace(st, et, num + 1, dtype=np.float64)
140
+ x_pdf = np.zeros_like(x, dtype=np.float64)
141
+
142
+ for i in range(C):
143
+ # print("%+0.5f___%+0.5f___%+0.5f" % (mean[i], std[i], weight[i]))
144
+ x_pdf += weight[i] * norm.pdf(x, mean[i], std[i])
145
+ x_pdf += 1E-8
146
+ x_pdf = x_pdf / (x_pdf * res).sum() # normalized to 1
147
+
148
+ return x, x_pdf
149
+
150
+
151
+ def forward_next_pdf(x, x_pdf, alpha, res):
152
+ '''
153
+ x : input domain
154
+ x_pdf : input pdf of continual variable
155
+ res : resolution of x's domain
156
+
157
+ Two ways to understand normalizing to 1:
158
+ convert to discrete variable and summarize
159
+ Approximate integral for continual variable
160
+ '''
161
+
162
+ if np.isclose(alpha, 1.0):
163
+ return x, x_pdf, None, None, None
164
+
165
+ y = copy.deepcopy(x)
166
+ xy_pdf = np.zeros([*x.shape, *y.shape], dtype=np.float64)
167
+ for i in range(len(x)):
168
+ p_x = x_pdf[i]
169
+ mu = x[i] * np.sqrt(alpha)
170
+ std = np.sqrt(1 - alpha)
171
+ p_y__x = norm.pdf(y, mu, std)
172
+
173
+ p_y__x = p_y__x/(p_y__x*res).sum()
174
+
175
+ # this will cause posterior distortion in the near zero area
176
+ # p_y__x += 1E-8
177
+ # p_y__x = p_y__x / (p_y__x * res).sum() # normalize to 1
178
+
179
+ xy_pdf[i] = p_x * p_y__x
180
+
181
+ xy_pdf = xy_pdf / (xy_pdf * res * res).sum() # normalize to 1
182
+ y_pdf = (xy_pdf * res).sum(axis=0)
183
+
184
+ xcy_pdf = xy_pdf / (y_pdf[None, :] + 1E-10)
185
+ ycx_pdf = xy_pdf / (x_pdf[:, None] + 1E-10)
186
+
187
+ return y, y_pdf, xy_pdf, xcy_pdf, ycx_pdf
188
+
189
+
190
+ ###################################################################################
191
+ # transform block function
192
+ ###################################################################################
193
+
194
+ def shrink(x, x_pdf, alpha, st, res):
195
+ '''
196
+ x : input domain
197
+ x_pdf : input pdf of continual variable
198
+ function : y = sqrt(\alpha) * x
199
+ inverse function : x = y / sqrt(\alpha)
200
+ derivative : y'= sqrt(\alpha)
201
+ '''
202
+
203
+ # y's domain is the sample as x
204
+ y = copy.deepcopy(x)
205
+ shrink_pdf = np.zeros_like(x_pdf, dtype=np.float64)
206
+ sqrt_alpha = np.sqrt(alpha)
207
+
208
+ for i in range(len(y)):
209
+ # get corresponding x by inverse function
210
+ idx = int((y[i] / sqrt_alpha - st) / res)
211
+ if idx < 0 or idx >= len(x_pdf):
212
+ continue
213
+
214
+ # scale with the reciprocal of derivative of y
215
+ shrink_pdf[i] = (1 / sqrt_alpha) * x_pdf[idx]
216
+
217
+ return shrink_pdf
218
+
219
+
220
+ def conv(x, x_pdf, alpha, res):
221
+ # gauss_pdf is continual random variable pdf
222
+ gauss_pdf = norm.pdf(x, 0, np.sqrt(1 - alpha))
223
+
224
+ # convert to discrete probability by multiplying with res, and convert back to continual by dividing res
225
+ out_pdf = scipy.signal.convolve(x_pdf * res, gauss_pdf * res, "same") / res
226
+
227
+ return out_pdf
228
+
229
+
230
+ def shrink_conv(x, x_pdf, shrink_alpha, conv_alpha, st, res):
231
+ # linear transform
232
+ shrink_pdf = shrink(x, x_pdf, shrink_alpha, st, res)
233
+
234
+ # add independent noises, that is equivalent to convolution
235
+ conv_pdf = conv(x, shrink_pdf, conv_alpha, res)
236
+
237
+ return conv_pdf
238
+
239
+
240
+ def plot_init_pdf(seed, st, et, num):
241
+ x, x_pdf = init_x_pdf(st, et, num, shape_type=0, seed=seed)
242
+ fig = plot_pdf(x, x_pdf, label="x", title="input variable's pdf")
243
+ fig.axes[0].title.set_size(9)
244
+
245
+ return fig, x, x_pdf
246
+
247
+
248
+ def plot_shrink_pdf(x, x_pdf, alpha, st, res):
249
+ if x is None or x_pdf is None:
250
+ return None
251
+
252
+ shrink_pdf = shrink(x, x_pdf, alpha, st, res)
253
+ fig = plot_pdf(x, shrink_pdf, label=r"$y=\sqrt{\alpha}x$", title="pdf after linear transform", titlesize=9)
254
+
255
+ return fig
256
+
257
+
258
+ def plot_conv_pdf(x, x_pdf, alpha, res):
259
+ if x is None or x_pdf is None:
260
+ return None
261
+
262
+ conv_pdf = conv(x, x_pdf, alpha, res)
263
+ fig = plot_pdf(x, conv_pdf, label=r"$y=x+\sqrt{1-\alpha}\epsilon$", title="pdf after add noises", titlesize=9)
264
+
265
+ return fig
266
+
267
+
268
+ def plot_shrink_conv_pdf(x, x_pdf, shrink_alpha, conv_alpha, st, res):
269
+ if x is None or x_pdf is None:
270
+ return None
271
+
272
+ shrink_conv_pdf = shrink_conv(x, x_pdf, shrink_alpha, conv_alpha, st, res)
273
+ title = r"pdf after two sub transforms"
274
+ label = r"$y=\sqrt{\alpha_s}x + \sqrt{1-\alpha_e}\epsilon$"
275
+ fig = plot_pdf(x, shrink_conv_pdf, label=label, title=title, titlesize=9)
276
+
277
+ return fig
278
+
279
+
280
+ def init_change(seed, shrink_alpha, conv_alpha):
281
+ global g_st, g_et, g_num, g_res
282
+
283
+ init_fig, x, x_pdf = plot_init_pdf(seed, g_st, g_et, g_num)
284
+ shrink_fig = plot_shrink_pdf(x, x_pdf, shrink_alpha, g_st, g_res)
285
+ conv_fig = plot_conv_pdf(x, x_pdf, conv_alpha, g_res)
286
+ shrink_conv_fig = plot_shrink_conv_pdf(x, x_pdf, shrink_alpha, conv_alpha, g_st, g_res)
287
+ return init_fig, x, x_pdf, shrink_fig, conv_fig, shrink_conv_fig
288
+
289
+
290
+ def shrink_change(x, x_pdf, shrink_alpha, conv_alpha):
291
+ global g_st, g_et, g_num, g_res
292
+
293
+ shrink_fig = plot_shrink_pdf(x, x_pdf, shrink_alpha, g_st, g_res)
294
+ shrink_conv_fig = plot_shrink_conv_pdf(x, x_pdf, shrink_alpha, conv_alpha, g_st, g_res)
295
+ return shrink_fig, shrink_conv_fig
296
+
297
+
298
+ def conv_change(x, x_pdf, shrink_alpha, conv_alpha):
299
+ global g_st, g_et, g_num, g_res
300
+
301
+ conv_fig = plot_conv_pdf(x, x_pdf, conv_alpha, g_res)
302
+ shrink_conv_fig = plot_shrink_conv_pdf(x, x_pdf, shrink_alpha, conv_alpha, g_st, g_res)
303
+ return conv_fig, shrink_conv_fig
304
+
305
+
306
+ ###################################################################################
307
+ # cond prob block function
308
+ ###################################################################################
309
+
310
+ def cond_prob_init_change(seed, alpha, cond_val):
311
+ global g_st, g_et, g_num, g_res
312
+
313
+ x, x_pdf = init_x_pdf(g_st, g_et, g_num, shape_type=0, seed=seed)
314
+ x_pdf = hijack(seed, x, x_pdf)
315
+
316
+ fig_x = plot_pdf(x, x_pdf, xlabel="x domain", ylabel="pdf", title="input variable's pdf", titlesize=9)
317
+
318
+ outputs = cond_prob_alpha_change(x, x_pdf, alpha, cond_val)
319
+ z, zcx_pdf, fig_z, fig_zcx, fig_xcz, fig_fix_xcz = outputs
320
+
321
+ return x, x_pdf, z, zcx_pdf, fig_x, fig_z, fig_zcx, fig_xcz, fig_fix_xcz
322
+
323
+
324
+ def cond_prob_alpha_change(x, x_pdf, alpha, cond_val):
325
+ forward_info = forward_next_pdf(x, x_pdf, alpha, g_res)
326
+ z, z_pdf, xz_pdf, xcz_pdf, zcx_pdf = forward_info
327
+
328
+ label = r"$z=\sqrt{\alpha}x + \sqrt{1-\alpha}\epsilon$"
329
+ input_title = r"output variable's pdf"
330
+ fore_cond_title = r"forward conditional pdf"
331
+ fig_z = plot_pdf(z, z_pdf, label=label, title=input_title, titlesize=9, xlabel="z domain", ylabel="pdf")
332
+ fig_zcx = plot_2d_pdf(x, z, zcx_pdf.transpose(), label="$q(z|x)$",
333
+ title=fore_cond_title, titlesize=9, xlabel="x domain(cond)", ylabel="z domain")
334
+
335
+ ret_fig = cond_prob_cond_change(x, x_pdf, z, xcz_pdf, alpha, cond_val)
336
+ fig_xcz, fig_fix_xcz = ret_fig
337
+
338
+ return z, xcz_pdf, fig_z, fig_zcx, fig_xcz, fig_fix_xcz
339
+
340
+
341
+ def cond_prob_cond_change(x, x_pdf, z, xcz_pdf, alpha, cond_val):
342
+ global g_st, g_et, g_num, g_res
343
+
344
+ cond_idx = int((cond_val - g_st) / g_res)
345
+ cond_pdf = xcz_pdf[:, cond_idx]
346
+
347
+ back_cond_title = "backward conditional pdf"
348
+ fig_xcz = plot_2d_pdf(x, z, xcz_pdf, cond_val, label="$q(x|z)$",
349
+ title=back_cond_title, xlabel="z domain(cond)", ylabel="x domain")
350
+ fig_xcz.axes[0].title.set_size(9)
351
+
352
+ gauss = norm.pdf(x, cond_val / np.sqrt(alpha), np.sqrt((1 - alpha) / alpha))
353
+
354
+ fixed_back_cond_title = "posterior with fixed condition"
355
+ fig_fix_xcz = plt.figure(figsize=(g_fw, g_fh))
356
+ ax = fig_fix_xcz.add_subplot(111)
357
+ axis_pdf(ax, x, gauss, max_y=5, label="$gauss$", style="dashed", color="green")
358
+ axis_pdf(ax, x, x_pdf, max_y=5, label="$q(x)$", style="dashed", color="blue")
359
+ axis_pdf(ax, x, cond_pdf, max_y=5, label="$q(x|z=%s)$" % cond_val,
360
+ title=fixed_back_cond_title, titlesize=9, xlabel="x domain", color="orange")
361
+ handles, labels = ax.get_legend_handles_labels()
362
+ ax.add_artist(ax.legend(handles[:2], labels[:2], handlelength=0.8, loc="upper left"))
363
+ ax.add_artist(ax.legend(handles[2:], labels[2:], handlelength=0.8, loc="upper right"))
364
+
365
+ return fig_xcz, fig_fix_xcz
366
+
367
+
368
+ ###################################################################################
369
+ # forward block function
370
+ ###################################################################################
371
+
372
+
373
+ def plot_first_pdf(x, x_pdf, ax):
374
+ title, label = r"origin var pdf", r"forward q(x)",
375
+ xlabel = rs(r"x domain")
376
+ axis_pdf(ax, x, x_pdf, title=title, label=label, xlabel=xlabel, ylabel="pdf", color="blue")
377
+ ax.legend(handlelength=1.2, labels=[label])
378
+ return
379
+
380
+
381
+ def forward_init_change(seed):
382
+ global g_st, g_et, g_num, g_res
383
+
384
+ x, x_pdf = init_x_pdf(g_st, g_et, g_num, seed=seed)
385
+ x_pdf = hijack(seed, x, x_pdf)
386
+
387
+ fig, axes = plt.subplots(nrows=1, ncols=8, figsize=(8 * g_fw, 1 * g_fh))
388
+ axes = axes.flatten()
389
+
390
+ plot_first_pdf(x, x_pdf, axes[0])
391
+
392
+ return x, x_pdf, fig, None
393
+
394
+
395
+ def plot_forward_pdf(axes, seq_info, color, pidx=-1):
396
+ count = len(seq_info)
397
+ step = int(count/3+1)
398
+
399
+ if pidx >= 0:
400
+ st, et = pidx*step, (pidx+1)*step
401
+ seq_info = seq_info[st:et]
402
+
403
+ for info in seq_info:
404
+ _, _, nz, nz_pdf, _, cidx, nidx, alpha = info
405
+ if nidx == 0:
406
+ title, label = "origin var pdf", r"forward $q(x)$",
407
+ else:
408
+ title, label = rs(r"$q(z_{%d})\ \alpha=%0.3f$"%(nidx, alpha)), r"forward $q(z_{%d})$"%nidx
409
+
410
+ xlabel = rs(r"$z_{%d}\ domain$"%nidx)
411
+ axis_pdf(axes[nidx], nz, nz_pdf, title=title, label=label, xlabel=xlabel, ylabel="pdf", color=color)
412
+ axes[nidx].legend(handlelength=1.2)
413
+
414
+ if nidx == (count-1):
415
+ axes[count-1].plot(nz, norm.pdf(nz, 0, 1), label=r"$\mathcal{N}\/(0, 1)$", color="green")
416
+ axes[count-1].legend()
417
+
418
+ return
419
+
420
+
421
+ def plot_backward_pdf(axes, fore_seq_info, back_seq_info, label_prefix, res, color, pidx=-1):
422
+ count = len(fore_seq_info)
423
+ step = int(count/3 + 1)
424
+
425
+ if pidx >= 0:
426
+ st, et = (2-pidx)*step, (2-pidx+1)*step # reverse
427
+ fore_seq_info, back_seq_info = fore_seq_info[st:et], back_seq_info[st:et]
428
+
429
+ for fore_info, back_info in zip(fore_seq_info, back_seq_info):
430
+ fore_nz_pdf, back_nz_pdf = fore_info[3], back_info[3]
431
+ nz, nidx = fore_info[2], fore_info[6]
432
+
433
+ div = jensenshannon(back_nz_pdf*res, fore_nz_pdf*res)
434
+
435
+ name = r"$\mathcal{N}\/(0,1)$" if nidx == count-1 else "revert" # specific name at end point
436
+ label = rs(label_prefix + name + " div=%0.2f"%div)
437
+ xlabel = rs(r"$z_{%d}\ domain$" % nidx)
438
+ axis_pdf(axes[nidx], nz, back_nz_pdf, label=label, xlabel=xlabel, ylabel="pdf", color=color)
439
+ axes[nidx].legend(handlelength=1.2)
440
+
441
+ return
442
+
443
+
444
+ def plot_backward_cond_pdf(axes, seq_info, reverse=True, pidx=-1):
445
+ count = len(seq_info)
446
+ step = int(count/3+1)
447
+
448
+ if pidx >= 0:
449
+ st, et = ((2-pidx)*step, (2-pidx+1)*step) if reverse else (pidx*step, (pidx+1)*step)
450
+ seq_info = seq_info[st:et]
451
+
452
+ for info in seq_info:
453
+ cz, cz_pdf, nz, nz_pdf, bc_pdf, cidx, nidx, alpha = info
454
+ if bc_pdf is None:
455
+ continue
456
+ title = rs(r"$q(z_{%d}|z_{%d})\ \alpha=%0.3f$" % (cidx, nidx, alpha))
457
+ xlabel, ylabel = rs(r"$z_{%d}$" % nidx), rs(r"$z_{%d}$" % cidx)
458
+ axis_2d_pdf(axes[nidx], cz, nz, bc_pdf, title=title, xlabel=xlabel, ylabel=ylabel)
459
+
460
+ return
461
+
462
+
463
+ def get_back_seq_info(ez, ez_pdf, fore_seq_info, res):
464
+ back_seq_info = copy.deepcopy(fore_seq_info)
465
+ count = len(back_seq_info)
466
+
467
+ nz, nz_pdf = ez, ez_pdf
468
+ for ii in reversed(range(count)):
469
+ bc_pdf = back_seq_info[ii][4]
470
+ if bc_pdf is None:
471
+ back_seq_info[ii][2:4] = nz, nz_pdf
472
+ continue
473
+ cz_pdf = np.matmul(bc_pdf, nz_pdf[:, None]) * res
474
+ cz, cz_pdf = nz, cz_pdf.flatten()
475
+ back_seq_info[ii][:4] = cz, cz_pdf, nz, nz_pdf
476
+
477
+ nz, nz_pdf = cz, cz_pdf
478
+
479
+ return back_seq_info
480
+
481
+
482
+ def forward_seq_apply(x, x_pdf, st_alpha, et_alpha, step):
483
+ global g_st, g_et, g_num, g_res
484
+
485
+ if x_pdf is None:
486
+ return None, None, None, None
487
+
488
+ alphas = np.linspace(st_alpha, et_alpha, step)
489
+ col_count = 8
490
+ row_count = int(np.ceil((step+1)/8))
491
+
492
+ fig, axes = plt.subplots(nrows=row_count, ncols=col_count, figsize=(col_count*g_fw, row_count*g_fh))
493
+ axes = axes.flatten()
494
+ pos_fig, pos_axes = plt.subplots(nrows=row_count, ncols=col_count, figsize=(col_count*g_fw, row_count*g_fh))
495
+ pos_axes = pos_axes.flatten()
496
+
497
+ # plot_first_pdf(x, x_pdf, fig, axes[0])
498
+
499
+ seq_info = [[None, None, x, x_pdf, None, -1, 0, None]]
500
+ cz, cz_pdf = x, x_pdf
501
+ for ii, alpha in enumerate(alphas):
502
+ forward_info = forward_next_pdf(cz, cz_pdf, alpha, g_res)
503
+ nz, nz_pdf, joint_pdf, bc_pdf, fc_pdf = forward_info
504
+
505
+ cidx, nidx = ii, ii+1
506
+ # title, label = r"$q(z_%d)\ \alpha=%0.3f$"%(nidx, alpha), r"$q(z_%d)$"%nidx
507
+ # axis_pdf(axes[nidx], nz, nz_pdf, title=title, label=label, xlabel=r"$z_{%d}\ domain$"%nidx, ylabel="pdf")
508
+
509
+ # bc_label = rs(r"$q(z_%d|z_%d)\ \alpha=%0.3f$"%(cidx, nidx, alpha))
510
+ # bc_xlabel, bc_ylabel = rs(r"$z_%d$"%nidx), rs(r"$z_%d$"%cidx)
511
+ # axis_2d_pdf(back_axes[nidx], cz, nz, bc_pdf, label=bc_label, xlabel=bc_xlabel, ylabel=bc_ylabel)
512
+
513
+ seq_info.append([cz, cz_pdf, nz, nz_pdf, bc_pdf, cidx, nidx, alpha])
514
+ cz, cz_pdf = nz, nz_pdf
515
+
516
+ # plot_forward_pdf(axes, seq_info, "blue")
517
+ # plot_backward_bc_pdf(back_axes, seq_info)
518
+
519
+ forward_plot_state = fig, axes, pos_fig, pos_axes, seq_info, g_res, "blue"
520
+
521
+ return seq_info, forward_plot_state
522
+
523
+
524
+ def forward_plot_part(plot_state, pidx):
525
+ if plot_state is None:
526
+ return None, None
527
+
528
+ fig, axes, back_fig, pos_axes, seq_info, res, color = plot_state
529
+
530
+ plot_forward_pdf(axes, seq_info, color, pidx)
531
+ plot_backward_cond_pdf(pos_axes, seq_info, False, pidx)
532
+
533
+ # fig.tight_layout()
534
+ # back_fig.tight_layout()
535
+
536
+ return fig, back_fig
537
+
538
+
539
+ def backward_seq_apply(fore_seq_info, is_forward_pdf, is_backward_pdf, noise_seed, noise_ratio):
540
+ global g_st, g_et, g_num, g_res
541
+
542
+ if fore_seq_info is None:
543
+ return None, None
544
+
545
+ col_count = 8
546
+ step = len(fore_seq_info)-1
547
+ row_count = int(np.ceil((step+1)/8))
548
+ fig, axes = plt.subplots(nrows=row_count, ncols=col_count, figsize=(col_count*g_fw, row_count*g_fh))
549
+ axes = axes.flatten()
550
+
551
+ x, x_pdf = fore_seq_info[0][2:4]
552
+
553
+ if is_forward_pdf:
554
+ plot_forward_pdf(axes, fore_seq_info, "blue")
555
+
556
+ ez, ez_pdf = fore_seq_info[-1][2], norm.pdf(x, 0, 1)
557
+
558
+ std_back_seq_info, noise_back_seq_info = None, None
559
+ if is_backward_pdf:
560
+ # plot_backward_pdf(axes, ez, ez_pdf, fore_seq_info, g_res, "std ", color="green")
561
+ std_back_seq_info = get_back_seq_info(ez, ez_pdf, fore_seq_info, g_res)
562
+
563
+ if noise_ratio > 0:
564
+ ez_pdf = add_random_noise(ez_pdf, noise_ratio, noise_seed, g_st, g_et, g_num, g_res)
565
+ # plot_backward_pdf(axes, ez, ez_pdf, fore_seq_info, g_res, "noise ", color="red")
566
+ noise_back_seq_info = get_back_seq_info(ez, ez_pdf, fore_seq_info, g_res)
567
+
568
+ # fig.tight_layout()
569
+ plot_state = fig, axes, fore_seq_info, std_back_seq_info, noise_back_seq_info, g_res
570
+
571
+ return fig, plot_state
572
+
573
+
574
+ def backward_plot_part(plot_state, pidx=-1):
575
+ if plot_state is None:
576
+ return None
577
+
578
+ fig, axes, fore_seq_info, std_back_seq_info, noise_back_seq_info, res = plot_state
579
+ if std_back_seq_info is not None:
580
+ plot_backward_pdf(axes, fore_seq_info, std_back_seq_info, "std ", res, "green", pidx)
581
+ if noise_back_seq_info is not None:
582
+ plot_backward_pdf(axes, fore_seq_info, noise_back_seq_info, "noise ", res, "red", pidx)
583
+
584
+ return fig
585
+
586
+
587
+ def fit_pos_with_gauss(idx, x, bc_pdf, queue):
588
+ # bc_pdf = copy.deepcopy(bc_pdf)
589
+ for ii in range(bc_pdf.shape[1]):
590
+ # guess = bc_pdf[:, ii].mean()
591
+ (mu, std), _ = curve_fit(norm.pdf, x, bc_pdf[:, ii], p0=[0, 1])
592
+ bc_pdf[:, ii] = norm.pdf(x, mu, std)
593
+ # queue.put((idx, bc_pdf))
594
+ return bc_pdf
595
+
596
+
597
+ def seq_fit_pos_with_gauss(fore_seq_info):
598
+ fit_seq_info = copy.deepcopy(fore_seq_info)
599
+
600
+ # queue = Manager().Queue()
601
+ # ls_param = []
602
+ threads = []
603
+ for ii in range(len(fit_seq_info)):
604
+ x, _, _, _, bc_pdf = fit_seq_info[ii][:5]
605
+ if bc_pdf is None:
606
+ continue
607
+ # os.system("echo hihi")
608
+ # thrd = Thread(target=fit_pos_with_gauss, args=(ii, x, bc_pdf, None))
609
+ # threads.append(thrd)
610
+ fit_seq_info[ii][4] = fit_pos_with_gauss(ii, x, bc_pdf, None)
611
+ # ls_param.append((ii, x, bc_pdf, None))
612
+
613
+ # for thrd in threads:
614
+ # thrd.start()
615
+ # for thrd in threads:
616
+ # thrd.join()
617
+
618
+ # with Pool(6) as pool:
619
+ # pool.starmap(fit_pos_with_gauss, ls_param)
620
+ #
621
+ # for ii in range(queue.qsize()):
622
+ # idx, bc_pdf = queue.get()
623
+ # seq_info[idx][4] = bc_pdf
624
+ # with WorkerPool(n_jobs=5) as pool:
625
+ # results = pool.map(fit_pos_with_gauss, ls_param)
626
+ return fit_seq_info
627
+
628
+
629
+ def fit_and_backward_apply(fore_seq_info, is_forward_pdf, is_backward_pdf):
630
+ global g_st, g_et, g_num, g_res
631
+
632
+ if fore_seq_info is None:
633
+ return None, None, None
634
+
635
+ col_count = 8
636
+ step = len(fore_seq_info)-1
637
+ row_count = int(np.ceil((step+1) / 8))
638
+ fig, axes = plt.subplots(nrows=row_count, ncols=col_count, figsize=(col_count*g_fw, row_count*g_fh))
639
+ axes = axes.flatten()
640
+ pos_fig, pos_axes = plt.subplots(nrows=row_count, ncols=col_count, figsize=(col_count*g_fw, row_count*g_fh))
641
+ pos_axes = pos_axes.flatten()
642
+
643
+ x, x_pdf = fore_seq_info[0][2:4]
644
+ # axis_pdf(axes[0], x, x_pdf, title="origin var pdf $q(x)$", label="forward", xlabel="x domain", ylabel="pdf")
645
+
646
+ if is_forward_pdf:
647
+ plot_forward_pdf(axes, fore_seq_info, "blue")
648
+
649
+ ez, ez_pdf = fore_seq_info[-1][2], norm.pdf(x, 0, 1)
650
+
651
+ # axes[step].plot(ez, ez_pdf, label="$\mathcal{N}\/(0, 1)$", color="green")
652
+
653
+ if is_backward_pdf:
654
+ std_back_seq_info = get_back_seq_info(ez, ez_pdf, fore_seq_info, g_res)
655
+ plot_backward_pdf(axes, fore_seq_info, std_back_seq_info, "std ", g_res, "green")
656
+
657
+ fit_back_seq_info = seq_fit_pos_with_gauss(fore_seq_info)
658
+ fit_back_seq_info = get_back_seq_info(ez, ez_pdf, fit_back_seq_info, g_res)
659
+ # plot_backward_pdf(axes, ez, ez_pdf, fit_seq_info, g_res, "fit ", color="orange")
660
+ # plot_backward_bc_pdf(back_axes, seq_info)
661
+
662
+ # fig.tight_layout()
663
+ # back_fig.tight_layout()
664
+
665
+ fit_plot_state = fig, axes, pos_fig, pos_axes, fore_seq_info, fit_back_seq_info, g_res
666
+
667
+ return fig, pos_fig, fit_plot_state
668
+
669
+
670
+ def fit_plot_part(plot_state, is_show_pos, pidx=-1):
671
+ if plot_state is None:
672
+ return None, None
673
+
674
+ fig, axes, back_fig, back_axes, fore_seq_info, fit_back_seq_info, res = plot_state
675
+ plot_backward_pdf(axes, fore_seq_info, fit_back_seq_info, "fit ", res, "orange", pidx)
676
+ if is_show_pos:
677
+ plot_backward_cond_pdf(back_axes, fit_back_seq_info, True, pidx)
678
+ # back_fig.tight_layout()
679
+
680
+ return fig, back_fig
681
+
682
+
683
+ ###################################################################################
684
+ # contraction block function
685
+ ###################################################################################
686
+
687
+ def contraction_init_change(seed, alpha, two_inputs_seed):
688
+ global g_st, g_et, g_num, g_res
689
+
690
+ rg = np.random.RandomState(int(seed))
691
+ shape_type = rg.randint(0, 4)
692
+
693
+ x, x_pdf = init_x_pdf(g_st, g_et, g_num, shape_type=shape_type, seed=seed)
694
+ x_pdf = hijack(seed, x, x_pdf)
695
+
696
+ # test
697
+ x_pdf[x_pdf < 0.01] = 0
698
+
699
+ x_pdf = x_pdf / (x_pdf * g_res).sum() # normalized to 1
700
+ fig = plot_pdf(x, x_pdf, title="input variable pdf", titlesize=9)
701
+
702
+ info = contraction_alpha_change(x, x_pdf, alpha, two_inputs_seed)
703
+ fig_xcz, fig_z, z, xcz_pdf, fig_inp_out = info
704
+
705
+ return fig, x, x_pdf, fig_xcz, fig_z, z, xcz_pdf, fig_inp_out
706
+
707
+
708
+ def contraction_alpha_change(x, x_pdf, alpha, two_inputs_seed):
709
+ global g_st, g_et, g_num, g_res
710
+
711
+ forward_info = forward_next_pdf(x, x_pdf, alpha, g_res)
712
+ z, z_pdf, xz_pdf, xcz_pdf, zcx_pdf = forward_info
713
+
714
+ label = r"$z=\sqrt{\alpha}x + \sqrt{1-\alpha}\epsilon$"
715
+ z_title = r"output variable pdf"
716
+ xcz_title = r"posterior pdf"
717
+ fig_z = plot_pdf(z, z_pdf, label=label, title=z_title, titlesize=9, xlabel="z domain", ylabel="pdf")
718
+ fig_xcz = plot_2d_pdf(x, z, xcz_pdf, None, label="$q(x|z)$",
719
+ title=xcz_title, titlesize=9, xlabel="z domain(cond)", ylabel="x domain")
720
+
721
+ fig_inp_out = contraction_apply(x, x_pdf, xcz_pdf, two_inputs_seed)
722
+
723
+ return fig_xcz, fig_z, z, xcz_pdf, fig_inp_out
724
+
725
+
726
+ def change_two_inputs_seed():
727
+ seed = random.randint(0, 1E6)
728
+ return seed
729
+
730
+
731
+ def contraction_apply(x, x_pdf, bc_pdf, seed):
732
+ global g_st, g_et, g_num, g_res
733
+
734
+ rg = np.random.RandomState(int(seed))
735
+
736
+ modals = [1, 2, 8, 12, 16, 16, 16, 16, 16, 20]
737
+ count1, count2 = rg.choice(modals), rg.choice(modals)
738
+
739
+ seed1, seed2 = rg.randint(0, 1E6, 2)
740
+ shape1, shape2 = rg.randint(0, 4, 2)
741
+
742
+ z1, z1_pdf = init_x_pdf(g_st, g_et, g_num, count1, shape_type=shape1, seed=seed1)
743
+ z2, z2_pdf = init_x_pdf(g_st, g_et, g_num, count2, shape_type=shape2, seed=seed2)
744
+
745
+ div_z = jensenshannon(z1_pdf*g_res, z2_pdf*g_res)
746
+
747
+ x1_pdf = np.matmul(bc_pdf, z1_pdf[:, None]) * g_res
748
+ x2_pdf = np.matmul(bc_pdf, z2_pdf[:, None]) * g_res
749
+ x1_pdf, x2_pdf = x1_pdf.flatten(), x2_pdf.flatten()
750
+
751
+ div_x = jensenshannon(x1_pdf*g_res, x2_pdf*g_res)
752
+
753
+ div_in_label, div_out_label = r"$div_{in}=%0.3f$"%div_z, r"$div_{out}=%0.3f$"%div_x
754
+
755
+ fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(2*g_fw, 1*g_fh))
756
+
757
+ axis_pdf(axes[0], z1, z1_pdf, max_y=3.8, label="input1",
758
+ title="two random input", titlesize=9, xlabel="z domain", ylabel="pdf", color="orange")
759
+ axis_pdf(axes[0], z2, z2_pdf, max_y=3.8, label="input2", xlabel="z domain", ylabel="pdf", color="green")
760
+ axes[0].plot([], [], label=div_in_label, color="blue")
761
+ handles, labels = axes[0].get_legend_handles_labels()
762
+ axes[0].add_artist(axes[0].legend(handles[:2], labels[:2], handlelength=1.0, loc="upper left"))
763
+ axes[0].add_artist(axes[0].legend(handles[2:], labels[2:], handlelength=0, loc="upper right"))
764
+
765
+ # axis_pdf(axes[1], x, x_pdf, max_y=3.8, title="two output", titlesize=9, style="dotted", color="blue")
766
+ axis_pdf(axes[1], z1, x1_pdf, max_y=3.8, label="output1",
767
+ title="two output", titlesize=9, xlabel="x domain", ylabel="pdf", color="orange")
768
+ axis_pdf(axes[1], z2, x2_pdf, max_y=3.8, label="output2", xlabel="x domain", ylabel="pdf", color="green")
769
+ axes[1].plot([], [], label=div_out_label, color="blue")
770
+ handles, labels = axes[1].get_legend_handles_labels()
771
+ axes[1].add_artist(axes[1].legend(handles[:2], labels[:2], handlelength=1.0, loc="upper left"))
772
+ axes[1].add_artist(axes[1].legend(handles[2:], labels[2:], handlelength=0, loc="upper right"))
773
+
774
+ return fig
775
+
776
+
777
+ def fixed_point_init_change(seed, x, x_pdf):
778
+ rg = np.random.RandomState(int(seed))
779
+
780
+ shape_type = rg.randint(0, 4)
781
+ count = rg.choice([1, 2, 8, 12, 16, 16, 16, 16, 16, 20])
782
+
783
+ z, z_pdf = init_x_pdf(g_st, g_et, g_num, modal_count=count, shape_type=shape_type, seed=seed)
784
+ div = jensenshannon(z_pdf*g_res, x_pdf*g_res)
785
+
786
+ fig, axes = plt.subplots(nrows=1, ncols=8, figsize=(8*g_fw, 1*g_fh))
787
+ axes = axes.flatten()
788
+ axis_pdf(axes[0], x, x_pdf, label="converging pdf", color="blue")
789
+ axis_pdf(axes[0], z, z_pdf, title="random input of inverse transform", label="random input", color="green")
790
+ axes[0].plot([], [], label="div=%0.2f"%div, color="orange")
791
+ axes[0].legend(handlelength=1.2)
792
+
793
+ return fig, z, z_pdf, None
794
+
795
+
796
+ def matrix_power(in_mat, n):
797
+ if n == 0:
798
+ return np.eye(in_mat.shape[0])
799
+
800
+ temp_mat = matrix_power(in_mat, int(n / 2))
801
+
802
+ if n % 2 == 0:
803
+ out_mat = np.matmul(temp_mat * 100, temp_mat * 100) / 10000
804
+ out_mat = out_mat / (out_mat.sum(axis=0, keepdims=True) + 1E-9)
805
+ return out_mat
806
+ else:
807
+ out_mat = np.matmul(temp_mat * 100, temp_mat * 100) / 10000
808
+ out_mat = out_mat / (out_mat.sum(axis=0, keepdims=True) + 1E-9)
809
+ out_mat = np.matmul(in_mat * 100, out_mat * 100) / 10000
810
+ out_mat = out_mat / (out_mat.sum(axis=0, keepdims=True) + 1E-9)
811
+ return out_mat
812
+
813
+
814
+ def fixed_point_apply_iterate(x, x_pdf, zt, zt_pdf, xcz_pdf, iterate_num, is_show_pow):
815
+ global g_res
816
+
817
+ if x_pdf is None or zt_pdf is None or xcz_pdf is None:
818
+ return None, None, None
819
+
820
+ col_count, max_row_count = 8, 3
821
+ max_ax_count = max_row_count*col_count - 1
822
+
823
+ ax_count = min(iterate_num, max_ax_count)
824
+ row_count = int(np.ceil((ax_count+1)/col_count))
825
+ fig, axes = plt.subplots(nrows=row_count, ncols=col_count, figsize=(col_count*g_fw, row_count*g_fh))
826
+ axes = axes.flatten()
827
+
828
+ axis_pdf(axes[0], x, x_pdf, label="converging point", color="blue")
829
+ axis_pdf(axes[0], zt, zt_pdf, title="random input", label="random input", color="green")
830
+
831
+ div = jensenshannon(zt_pdf*g_res, x_pdf*g_res)
832
+ axes[0].plot([], [], label="div=%0.2f"%div, color="green")
833
+ axes[0].legend(handlelength=1.2)
834
+
835
+ idxs = np.arange(iterate_num).tolist()
836
+ if iterate_num > max_ax_count:
837
+ idxs = np.arange(6).tolist() + power_range(6, iterate_num-1, max_ax_count-6, 2.5)
838
+
839
+ pow_mats, pdfs = [], []
840
+ for ii, idx in enumerate(idxs):
841
+ pow_idx, ax_idx = idx + 1, ii + 1
842
+ pow_mat = matrix_power(xcz_pdf*g_res, pow_idx)
843
+ pz_pdf = np.matmul(pow_mat, zt_pdf[:, None])
844
+ pz, pz_pdf = zt, pz_pdf.flatten()
845
+ pow_mats.append([pow_mat, pow_idx, ax_idx])
846
+ pdfs.append([x, x_pdf, pz_pdf, pow_idx, ax_idx])
847
+
848
+ pow_fig, pow_axes = None, None
849
+ if is_show_pow:
850
+ pow_fig, pow_axes = plt.subplots(nrows=row_count, ncols=col_count, figsize=(col_count*g_fw, row_count*g_fh))
851
+ pow_axes = pow_axes.flatten()
852
+
853
+ plot_state = (fig, pow_fig, axes, pow_axes, pdfs, pow_mats, g_res)
854
+
855
+ return fig, pow_fig, plot_state
856
+
857
+
858
+ def fixed_plot_part(plot_state, pidx):
859
+ if plot_state is None:
860
+ return None, None
861
+
862
+ fig, pow_fig, axes, pow_axes, pdfs, pow_mats, res = plot_state
863
+ step = int(len(pdfs)/3) + 1
864
+
865
+ roi_pdfs = pdfs[pidx*step: (pidx+1)*step]
866
+ for pdf_info in roi_pdfs:
867
+ x, x_pdf, pz_pdf, pow_idx, ax_idx = pdf_info
868
+ axis_pdf(axes[ax_idx], x, x_pdf, label="converging pdf", color="blue")
869
+ title = r"the %dth iterate" % pow_idx
870
+ axis_pdf(axes[ax_idx], x, pz_pdf, title=title, label="transform result", color="green")
871
+
872
+ div = jensenshannon(pz_pdf*res, x_pdf*res)
873
+ axes[ax_idx].plot([], [], label="div=%0.3f"%div, color="green")
874
+ axes[ax_idx].legend(handlelength=1.2)
875
+
876
+ # fig.tight_layout()
877
+
878
+ if pow_axes is None:
879
+ return fig, None
880
+
881
+ roi_pow_mats = pow_mats[pidx*step: (pidx+1)*step]
882
+ for pow_info in roi_pow_mats:
883
+ pow_mat, pow_idx, ax_idx = pow_info
884
+ axis_2d_pdf(pow_axes[ax_idx], x, x, pow_mat, title="power(mat,%d)"%(pow_idx), xlabel="z", ylabel="x")
885
+ # pow_fig.tight_layout()
886
+
887
+ return fig, pow_fig
888
+
889
+
890
+ def hijack(seed, x, x_pdf):
891
+ if seed in [16002, 16003]:
892
+ x, x_pdf = init_x_pdf(g_st, g_et, g_num, shape_type=2, seed=100)
893
+ left, right = (-0.5, 0.5) if seed == 16002 else (-0.7, 0.7)
894
+ mask = np.logical_and(x > left, x < right)
895
+ x_pdf[mask] = 0
896
+
897
+ base = 17500
898
+ left, right = int(base+g_st*100), int(base+g_et*100)
899
+ if seed in range(left, right):
900
+ mu, std = g_st + (seed//10*10 - left)*0.01, (seed%10+1)*0.02
901
+ x_pdf = norm.pdf(x, mu, std)
902
+
903
+ return x_pdf
904
+
905
+
906
+
ExtraBlock.js ADDED
@@ -0,0 +1,145 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+
4
+ function write_markdown() {
5
+ let names = ["introduction", "transform", "likelihood", "posterior", "forward_process", "backward_process",
6
+ "fit_posterior", "posterior_transform", "deconvolution", "reference", "about"];
7
+ names = names.slice(-1)
8
+
9
+ names.forEach((item, index) => {
10
+ const elem = document.getElementById("md_" + item);
11
+ let a = document.createElement('a');
12
+ a.href = "data:application/octet-stream," + encodeURIComponent(elem.outerHTML);
13
+ a.download = item + '.html';
14
+ a.click();
15
+ });
16
+ }
17
+
18
+
19
+ function insert_markdown() {
20
+ const names = ["introduction", "transform", "likelihood", "posterior", "forward_process", "backward_process",
21
+ "fit_posterior", "posterior_transform", "deconvolution", "reference", "about"];
22
+
23
+ for (let i = 0; i < names.length; i++) {
24
+ name = names[i];
25
+ const markdown_zh = document.createElement('div');
26
+ markdown_zh.id = "md_" + name + "_zh";
27
+ markdown_zh.style.display = "none";
28
+
29
+ fetch('file/Markdown/zh/' + name + ".html").then(response => response.text()).then(text => markdown_zh.innerHTML = text)
30
+
31
+ const markdown_en = document.createElement('div');
32
+ markdown_en.id = "md_" + name + "_en";
33
+ markdown_en.style.display = "block";
34
+
35
+ fetch('file/Markdown/en/' + name + ".html").then(response => response.text()).then(text => markdown_en.innerHTML = text)
36
+
37
+ const accord = document.getElementById(name).children[2];
38
+ accord.appendChild(markdown_zh);
39
+ accord.appendChild(markdown_en);
40
+ }
41
+ }
42
+
43
+
44
+ function control_language() {
45
+ const names = ["introduction", "transform", "likelihood", "posterior", "forward_process",
46
+ "backward_process", "fit_posterior", "posterior_transform", "deconvolution", "reference", "about"];
47
+
48
+ var is_zh = document.getElementById("switch_language").checked;
49
+ for (let i = 0; i < names.length; i++) {
50
+ name = names[i];
51
+
52
+ zh_display = is_zh ? "block" : "none";
53
+ en_display = is_zh ? "none" : "block";
54
+
55
+ md_zh = document.getElementById("md_" + name + "_zh");
56
+ md_en = document.getElementById("md_" + name + "_en");
57
+ md_zh.style.display = zh_display;
58
+ md_en.style.display = en_display;
59
+ }
60
+ }
61
+
62
+ function control_accordion() {
63
+ open = document.getElementById("switch_accordion").checked;
64
+ all_accords = document.getElementsByClassName("label-wrap");
65
+
66
+ for (let i = 0; i < all_accords.length; i++) {
67
+ const accord = all_accords[i];
68
+ const is_open = accord.classList.contains("open");
69
+ if (is_open != open) {
70
+ accord.click();
71
+ }
72
+ }
73
+ }
74
+
75
+
76
+ function create_switch(id, left_text, right_text, callback) {
77
+ var input = document.createElement("input");
78
+ input.type = "checkbox";
79
+ input.id = id;
80
+ input.checked = false;
81
+ input.addEventListener("change", callback);
82
+
83
+ var slider = document.createElement("span");
84
+ slider.className = "switchslider";
85
+
86
+ var switchbar = document.createElement("label");
87
+ switchbar.className = "switchbar";
88
+
89
+ switchbar.appendChild(input);
90
+ switchbar.appendChild(slider);
91
+
92
+ var div = document.createElement("div");
93
+ div.style.lineHeight = "30px";
94
+ div.style.fontSize = "18px";
95
+
96
+ var left_label = document.createElement("span");
97
+ left_label.innerText = left_text;
98
+ var right_label = document.createElement("span");
99
+ right_label.innerText = right_text;
100
+
101
+ div.appendChild(left_label);
102
+ div.appendChild(switchbar);
103
+ div.appendChild(right_label);
104
+
105
+ return div;
106
+ }
107
+
108
+
109
+ function add_switch() {
110
+ switch_accordion = create_switch("switch_accordion", "Collapse", "Expand", control_accordion);
111
+ switch_language = create_switch("switch_language", "English", "Chinese", control_language);
112
+
113
+ switch_accordion.style.float = "right";
114
+ switch_language.style.float = "left";
115
+
116
+ var state = document.createElement("span");
117
+ state.appendChild(switch_language);
118
+ state.appendChild(switch_accordion);
119
+ state.style.marginBottom = "20px"
120
+
121
+ const elem = document.getElementById("introduction");
122
+ elem.insertAdjacentElement("beforebegin", state);
123
+
124
+ switch_accordion.children[1].click();
125
+ switch_accordion.children[1].click();
126
+ }
127
+
128
+
129
+ function katex_render(name) {
130
+ const elem = document.getElementById(name);
131
+ if (elem == null) { return; }
132
+ var text = elem.innerText.replaceAll("{underline}", "_");
133
+ text = "\\begin{align}\n" + text + "\n\\end{align}";
134
+ katex.render(text, elem, {displayMode: true});
135
+ }
136
+
137
+
138
+ function insert_special_formula(name) {
139
+ katex_render("zh_fit_0");
140
+ katex_render("zh_fit_1");
141
+ katex_render("zh_fit_2");
142
+ katex_render("en_fit_0");
143
+ katex_render("en_fit_1");
144
+ katex_render("en_fit_2");
145
+ }
Markdown/en/about.html ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ <div id="md_about" class="block normal mds svelte-90oupt padded hide-container" style="border-style: solid; overflow: visible; min-width: min(0px, 100%); border-width: var(--block-border-width);"><div class="wrap center full svelte-1occ011 hide" style="position: absolute; padding: 0px;"></div> <div class="svelte-1ed2p3z"><div class="prose normal mds svelte-1yrv54" data-testid="markdown" dir="ltr"><span class="md svelte-1syupzx"><p><b>APP</b>: This APP is developed using Gradio and deployed on HuggingFace. Due to limited resources (2 cores, 16G memory), the response may be slow. For a better experience, it is recommended to clone the source code from <a href="https://github.com/blairstar/The_Art_of_DPM" target="_blank" rel="noopener noreferrer">github</a> and run it locally. This program only relies on Gradio, SciPy, and Matplotlib.</p>
2
+ <p><b>Author</b>: Zhenxin Zheng, Senior computer vision engineer with ten years of algorithm development experience, Formerly employed by Tencent and JD.com, currently focusing on image and video generation.</p>
3
+ <p><b>Email</b>: <a href="mailto:[email protected]" target="_blank" rel="noopener noreferrer">[email protected]</a>.</p>
4
+ </span></div></div></div>
Markdown/en/backward_process.html ADDED
@@ -0,0 +1,46 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div id="md_backward_process" class="block normal mds svelte-90oupt padded hide-container" style="border-style: solid; overflow: visible; min-width: min(0px, 100%); border-width: var(--block-border-width);"><div class="wrap center full svelte-1occ011 hide" style="position: absolute; padding: 0px;"></div> <div class="svelte-1ed2p3z"><div class="prose normal mds svelte-1yrv54" data-testid="markdown" dir="ltr"><span class="md svelte-1syupzx"><p>If the final probability distribution <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mi>T</mi></msub><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(z_T)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span></span></span> and the posterior probabilities of each transform <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo><mo separator="true">,</mo><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mrow><mi>t</mi><mo>−</mo><mn>1</mn></mrow></msub><mi mathvariant="normal">∣</mi><msub><mi>z</mi><mi>t</mi></msub><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z),q(z_{t-1}|z_t)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span><span class="mpunct">,</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">t</span><span class="mbin mtight">−</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.2083em;"><span class=""></span></span></span></span></span></span><span class="mord">∣</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.2806em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">t</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span></span></span> are known, the data distribution <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span> can be recovered through the Bayes Theorem and the Law of Total Probability, as shown in equations 5.1~5.4. When the final probability distribution <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mi>T</mi></msub><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(z_T)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span></span></span> is very similar to the standard normal distribution, the standard normal distribution can be used as a substitute.</p>
2
+ <p>Specifics can be seen in Demo 3.2. In the example, <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mi>T</mi></msub><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(z_T)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span></span></span> substitutes <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="script">N</mi><mo stretchy="false">(</mo><mn>0</mn><mo separator="true">,</mo><mn>1</mn><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\mathcal{N}(0,1)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathcal" style="margin-right: 0.1474em;">N</span><span class="mopen">(</span><span class="mord">0</span><span class="mpunct">,</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord">1</span><span class="mclose">)</span></span></span></span></span>, and the error magnitude is given through JS Divergence. The restored probability distribution <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mi>t</mi></msub><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(z_t)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.2806em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">t</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span></span></span> and <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span> are identified by the <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="green"><mtext>green&nbsp;curve</mtext></mstyle></mrow><annotation encoding="application/x-tex">\textcolor{green}{\text{green curve}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.625em; vertical-align: -0.1944em;"></span><span class="mord text" style="color: green;"><span class="mord" style="color: green;">green&nbsp;curve</span></span></span></span></span></span>, and the original probability distribution is identified by the <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="blue"><mtext>blue&nbsp;curve</mtext></mstyle></mrow><annotation encoding="application/x-tex">\textcolor{blue}{\text{blue curve}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.6944em;"></span><span class="mord text" style="color: blue;"><span class="mord" style="color: blue;">blue&nbsp;curve</span></span></span></span></span></span>. It can be observed that the data distribution <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span> can be well restored, and the error (JS Divergence) will be smaller than the error caused by the standard normal distribution replacing <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mi>T</mi></msub><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(z_T)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span></span></span>.
3
+ <span><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right left" columnspacing="0em"><mtr><mtd class="mtr-glue"></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mrow><mi>T</mi><mo>−</mo><mn>1</mn></mrow></msub><mo stretchy="false">)</mo></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mo>∫</mo><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mrow><mi>T</mi><mo>−</mo><mn>1</mn></mrow></msub><mo separator="true">,</mo><msub><mi>z</mi><mi>T</mi></msub><mo stretchy="false">)</mo><mi>d</mi><msub><mi>z</mi><mi>T</mi></msub><mo>=</mo><mo>∫</mo><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mrow><mi>T</mi><mo>−</mo><mn>1</mn></mrow></msub><mi mathvariant="normal">∣</mi><msub><mi>z</mi><mi>T</mi></msub><mo stretchy="false">)</mo><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mi>T</mi></msub><mo stretchy="false">)</mo><mi>d</mi><msub><mi>z</mi><mi>T</mi></msub></mrow></mstyle></mtd><mtd class="mtr-glue"></mtd><mtd class="mml-eqn-num"></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>…</mo></mrow></mstyle></mtd></mtr><mtr><mtd class="mtr-glue"></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mrow><mi>t</mi><mo>−</mo><mn>1</mn></mrow></msub><mo stretchy="false">)</mo></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mo>∫</mo><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mrow><mi>t</mi><mo>−</mo><mn>1</mn></mrow></msub><mo separator="true">,</mo><msub><mi>z</mi><mi>t</mi></msub><mo stretchy="false">)</mo><mi>d</mi><msub><mi>z</mi><mi>t</mi></msub><mo>=</mo><mo>∫</mo><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mrow><mi>t</mi><mo>−</mo><mn>1</mn></mrow></msub><mi mathvariant="normal">∣</mi><msub><mi>z</mi><mi>t</mi></msub><mo stretchy="false">)</mo><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mi>t</mi></msub><mo stretchy="false">)</mo><mi>d</mi><msub><mi>z</mi><mi>t</mi></msub></mrow></mstyle></mtd><mtd class="mtr-glue"></mtd><mtd class="mml-eqn-num"></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>…</mo></mrow></mstyle></mtd></mtr><mtr><mtd class="mtr-glue"></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mn>1</mn></msub><mo stretchy="false">)</mo></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mo>∫</mo><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mn>1</mn></msub><mo separator="true">,</mo><msub><mi>z</mi><mn>2</mn></msub><mo stretchy="false">)</mo><mi>d</mi><msub><mi>z</mi><mn>1</mn></msub><mo>=</mo><mo>∫</mo><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mn>1</mn></msub><mi mathvariant="normal">∣</mi><msub><mi>z</mi><mn>2</mn></msub><mo stretchy="false">)</mo><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mn>2</mn></msub><mo stretchy="false">)</mo><mi>d</mi><msub><mi>z</mi><mn>2</mn></msub></mrow></mstyle></mtd><mtd class="mtr-glue"></mtd><mtd class="mml-eqn-num"></mtd></mtr><mtr><mtd class="mtr-glue"></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mo>∫</mo><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo separator="true">,</mo><msub><mi>z</mi><mn>1</mn></msub><mo stretchy="false">)</mo><mi>d</mi><msub><mi>z</mi><mn>1</mn></msub><mo>=</mo><mo>∫</mo><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><msub><mi>z</mi><mn>1</mn></msub><mo stretchy="false">)</mo><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mn>1</mn></msub><mo stretchy="false">)</mo><mi>d</mi><msub><mi>z</mi><mn>1</mn></msub></mrow></mstyle></mtd><mtd class="mtr-glue"></mtd><mtd class="mml-eqn-num"></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{align}
4
+ q(z_{T-1}) &amp;= \int q(z_{T-1},z_T)dz_T = \int q(z_{T-1}|z_T)q(z_T)dz_T \tag{5.1} \newline
5
+ &amp; \dots \notag \newline
6
+ q(z_{t-1}) &amp;= \int q(z_{t-1},z_t)dz_t = \int q(z_{t-1}|z_t)q(z_t)dz_t \tag{5.2} \newline
7
+ &amp; \dots \notag \newline
8
+ q(z_1) &amp;= \int q(z_1,z_2) dz_1 = \int q(z_1|z_2)q(z_2)dz_2 \tag{5.3} \newline
9
+ q(x) &amp;= \int q(x,z_1) dz_1 = \int q(x|z_1)q(z_1)dz_1 \tag{5.4} \newline
10
+ \end{align}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 13.089em; vertical-align: -6.2945em;"></span><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 6.7945em;"><span class="" style="top: -8.7945em;"><span class="pstrut" style="height: 3.36em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span><span class="mbin mtight">−</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.2083em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span><span class="" style="top: -6.7923em;"><span class="pstrut" style="height: 3.36em;"></span><span class="mord"></span></span><span class="" style="top: -4.7722em;"><span class="pstrut" style="height: 3.36em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">t</span><span class="mbin mtight">−</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.2083em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span><span class="" style="top: -2.77em;"><span class="pstrut" style="height: 3.36em;"></span><span class="mord"></span></span><span class="" style="top: -0.75em;"><span class="pstrut" style="height: 3.36em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span><span class="" style="top: 1.7722em;"><span class="pstrut" style="height: 3.36em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 6.2945em;"><span class=""></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 6.7945em;"><span class="" style="top: -8.7945em;"><span class="pstrut" style="height: 3.36em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mop op-symbol large-op" style="margin-right: 0.4445em; position: relative; top: -0.0011em;">∫</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span><span class="mbin mtight">−</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.2083em;"><span class=""></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span><span class="mord mathnormal">d</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mop op-symbol large-op" style="margin-right: 0.4445em; position: relative; top: -0.0011em;">∫</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span><span class="mbin mtight">−</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.2083em;"><span class=""></span></span></span></span></span></span><span class="mord">∣</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span><span class="mord mathnormal">d</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span></span></span><span class="" style="top: -6.7923em;"><span class="pstrut" style="height: 3.36em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="minner">…</span></span></span><span class="" style="top: -4.7722em;"><span class="pstrut" style="height: 3.36em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mop op-symbol large-op" style="margin-right: 0.4445em; position: relative; top: -0.0011em;">∫</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">t</span><span class="mbin mtight">−</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.2083em;"><span class=""></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.2806em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">t</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span><span class="mord mathnormal">d</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.2806em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">t</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mop op-symbol large-op" style="margin-right: 0.4445em; position: relative; top: -0.0011em;">∫</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">t</span><span class="mbin mtight">−</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.2083em;"><span class=""></span></span></span></span></span></span><span class="mord">∣</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.2806em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">t</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.2806em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">t</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span><span class="mord mathnormal">d</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.2806em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">t</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span></span></span><span class="" style="top: -2.77em;"><span class="pstrut" style="height: 3.36em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="minner">…</span></span></span><span class="" style="top: -0.75em;"><span class="pstrut" style="height: 3.36em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mop op-symbol large-op" style="margin-right: 0.4445em; position: relative; top: -0.0011em;">∫</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span><span class="mord mathnormal">d</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mop op-symbol large-op" style="margin-right: 0.4445em; position: relative; top: -0.0011em;">∫</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mord">∣</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span><span class="mord mathnormal">d</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span></span></span><span class="" style="top: 1.7722em;"><span class="pstrut" style="height: 3.36em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mop op-symbol large-op" style="margin-right: 0.4445em; position: relative; top: -0.0011em;">∫</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mpunct">,</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span><span class="mord mathnormal">d</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mop op-symbol large-op" style="margin-right: 0.4445em; position: relative; top: -0.0011em;">∫</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span><span class="mord mathnormal">d</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 6.2945em;"><span class=""></span></span></span></span></span></span></span><span class="tag"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 6.7945em;"><span class="" style="top: -8.7945em;"><span class="pstrut" style="height: 3.36em;"></span><span class=""><span class="mord text"><span class="mord">(</span><span class="mord"><span class="mord">5.1</span></span><span class="mord">)</span></span></span></span><span class="" style="top: -6.7923em;"><span class="pstrut" style="height: 3.36em;"></span><span class=""></span></span><span class="" style="top: -4.7722em;"><span class="pstrut" style="height: 3.36em;"></span><span class=""><span class="mord text"><span class="mord">(</span><span class="mord"><span class="mord">5.2</span></span><span class="mord">)</span></span></span></span><span class="" style="top: -2.77em;"><span class="pstrut" style="height: 3.36em;"></span><span class=""></span></span><span class="" style="top: -0.75em;"><span class="pstrut" style="height: 3.36em;"></span><span class=""><span class="mord text"><span class="mord">(</span><span class="mord"><span class="mord">5.3</span></span><span class="mord">)</span></span></span></span><span class="" style="top: 1.7722em;"><span class="pstrut" style="height: 3.36em;"></span><span class=""><span class="mord text"><span class="mord">(</span><span class="mord"><span class="mord">5.4</span></span><span class="mord">)</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 6.2945em;"><span class=""></span></span></span></span></span></span></span></span></span>
11
+ In this article, the aforementioned transform is referred to as the <b>Posterior Transform</b>. For example, in equation 5.4, the input of the transform is the probability distribution function <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mn>1</mn></msub><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(z_1)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span></span></span>, and the output is the probability distribution function <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>.The entire transform is determined by the posterior <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><msub><mi>z</mi><mn>1</mn></msub><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z_1)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span></span></span>. This transform can also be considered as the linear weighted sum of a set of basis functions, where the basis functions are <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><msub><mi>z</mi><mn>1</mn></msub><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z_1)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span></span></span> under different <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>z</mi><mn>1</mn></msub></mrow><annotation encoding="application/x-tex">z_1</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.5806em; vertical-align: -0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span></span></span></span></span>, and the weights of each basis function are <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mn>1</mn></msub><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(z_1)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span></span></span>. Some interesting properties of this transform will be introduced in Section 7.</p>
12
+ <p>In Section 3, we have considered two special posterior probability distributions. Next, we analyze their corresponding <em>posterior transforms</em>.</p>
13
+ <ul>
14
+ <li> When <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi><mo>→</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">\alpha \to 0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">→</span><span class="mspace" style="margin-right: 0.2778em;"></span></span><span class="base"><span class="strut" style="height: 0.6444em;"></span><span class="mord">0</span></span></span></span></span>, the <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span></span></span></span></span> for different <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>z</mi></mrow><annotation encoding="application/x-tex">z</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span></span></span></span></span> are almost the same as <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>. In other words, the basis functions of linear weighted sum are almost the same. In this state, no matter how the input changes, the output of the transformation is always <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>."</li>
15
+ <li> When <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi><mo>→</mo><mn>1</mn></mrow><annotation encoding="application/x-tex">\alpha \to 1</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">→</span><span class="mspace" style="margin-right: 0.2778em;"></span></span><span class="base"><span class="strut" style="height: 0.6444em;"></span><span class="mord">1</span></span></span></span></span>, the <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span></span></span></span></span> for different <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>z</mi></mrow><annotation encoding="application/x-tex">z</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span></span></span></span></span> values becomes a series of Dirac delta functions and zero functions. In this state, as long as the <em>support set</em> of the input distribution is included in the <em>support set</em> of <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>, the output of the transformation will remain the same with the input.</li>
16
+ </ul>
17
+
18
+ <p>In Section 5, it is mentioned that the 1000 transformations used in the DDPM<a href="#ddpm">[2]</a> can be represented using a single transformation
19
+ <span><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right" columnspacing=""><mtr><mtd class="mtr-glue"></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><msub><mi>Z</mi><mi>T</mi></msub><mo>=</mo><msqrt><mn>0.0000403</mn></msqrt><mtext>&nbsp;</mtext><mi>X</mi><mo>+</mo><msqrt><mrow><mn>1</mn><mo>−</mo><mn>0.0000403</mn></mrow></msqrt><mtext>&nbsp;</mtext><mi>ϵ</mi><mo>=</mo><mn>0.00635</mn><mtext>&nbsp;</mtext><mi>X</mi><mo>+</mo><mn>0.99998</mn><mtext>&nbsp;</mtext><mi>ϵ</mi></mrow></mstyle></mtd><mtd class="mtr-glue"></mtd><mtd class="mml-eqn-num"></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{align}
20
+ Z_T = \sqrt{0.0000403}\ X + \sqrt{1-0.0000403}\ \epsilon = 0.00635\ X + 0.99998\ \epsilon \tag{5.5}
21
+ \end{align}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1.6161em; vertical-align: -0.558em;"></span><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.058em;"><span class="" style="top: -3.102em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0715em;">Z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.0715em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.9561em;"><span class="svg-align" style="top: -3em;"><span class="pstrut" style="height: 3em;"></span><span class="mord" style="padding-left: 0.833em;"><span class="mord">0.0000403</span></span></span><span class="" style="top: -2.9161em;"><span class="pstrut" style="height: 3em;"></span><span class="hide-tail" style="min-width: 0.853em; height: 1.08em;"><svg width="400em" height="1.08em" viewBox="0 0 400000 1080" preserveAspectRatio="xMinYMin slice"><path d="M95,702
22
+ c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
23
+ c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
24
+ c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
25
+ s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
26
+ c69,-144,104.5,-217.7,106.5,-221
27
+ l0 -0
28
+ c5.3,-9.3,12,-14,20,-14
29
+ H400000v40H845.2724
30
+ s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
31
+ c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
32
+ M834 80h400000v40h-400000z"></path></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.0839em;"><span class=""></span></span></span></span></span><span class="mspace">&nbsp;</span><span class="mord mathnormal" style="margin-right: 0.0785em;">X</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.9144em;"><span class="svg-align" style="top: -3em;"><span class="pstrut" style="height: 3em;"></span><span class="mord" style="padding-left: 0.833em;"><span class="mord">1</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mord">0.0000403</span></span></span><span class="" style="top: -2.8744em;"><span class="pstrut" style="height: 3em;"></span><span class="hide-tail" style="min-width: 0.853em; height: 1.08em;"><svg width="400em" height="1.08em" viewBox="0 0 400000 1080" preserveAspectRatio="xMinYMin slice"><path d="M95,702
33
+ c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
34
+ c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
35
+ c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
36
+ s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
37
+ c69,-144,104.5,-217.7,106.5,-221
38
+ l0 -0
39
+ c5.3,-9.3,12,-14,20,-14
40
+ H400000v40H845.2724
41
+ s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
42
+ c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
43
+ M834 80h400000v40h-400000z"></path></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.1256em;"><span class=""></span></span></span></span></span><span class="mspace">&nbsp;</span><span class="mord mathnormal">ϵ</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mord">0.00635</span><span class="mspace">&nbsp;</span><span class="mord mathnormal" style="margin-right: 0.0785em;">X</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mord">0.99998</span><span class="mspace">&nbsp;</span><span class="mord mathnormal">ϵ</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.558em;"><span class=""></span></span></span></span></span></span></span><span class="tag"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.058em;"><span class="" style="top: -3.102em;"><span class="pstrut" style="height: 3em;"></span><span class=""><span class="mord text"><span class="mord">(</span><span class="mord"><span class="mord">5.5</span></span><span class="mord">)</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.558em;"><span class=""></span></span></span></span></span></span></span></span></span></p>
44
+ <p>Since <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi><mo>=</mo><mn>0.0000403</mn></mrow><annotation encoding="application/x-tex">\alpha=0.0000403</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span></span><span class="base"><span class="strut" style="height: 0.6444em;"></span><span class="mord">0.0000403</span></span></span></span></span> is very small, the corresponding standard deviation of GaussFun (Equation 3.4) reaches 157.52. However, the range of <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>X</mi></mrow><annotation encoding="application/x-tex">X</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.6833em;"></span><span class="mord mathnormal" style="margin-right: 0.0785em;">X</span></span></span></span></span> is limited within <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo><mo>−</mo><mn>1</mn><mo separator="true">,</mo><mn>1</mn><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">[-1, 1]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mopen">[</span><span class="mord">−</span><span class="mord">1</span><span class="mpunct">,</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord">1</span><span class="mclose">]</span></span></span></span></span>, which is far smaller than the standard deviation of GaussFun. Within the range of <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi><mo>∈</mo><mo stretchy="false">[</mo><mo>−</mo><mn>1</mn><mo separator="true">,</mo><mn>1</mn><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">x \in [-1, 1]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.5782em; vertical-align: -0.0391em;"></span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">∈</span><span class="mspace" style="margin-right: 0.2778em;"></span></span><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mopen">[</span><span class="mord">−</span><span class="mord">1</span><span class="mpunct">,</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord">1</span><span class="mclose">]</span></span></span></span></span>, GaussFun should be close to a constant, showing little variation. Therefore, the <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><msub><mi>z</mi><mi>T</mi></msub><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z_T)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span></span></span> corresponding to different <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>z</mi><mi>T</mi></msub></mrow><annotation encoding="application/x-tex">z_T</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.5806em; vertical-align: -0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span></span></span></span></span> are almost the same as <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>. In this state, the posterior transform corresponding to <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><msub><mi>z</mi><mi>T</mi></msub><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z_T)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span></span></span> does not depend on the input distribution, the output distribution will always be <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>.</p>
45
+ <p><b>Therefore, theoretically, in the DDPM model, it is not necessary to use the standard normal distribution to replace <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mi>T</mi></msub><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(z_T)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span></span></span>. Any other arbitrary distributions can also be used as a substitute.</b></p>
46
+ </span></div></div></div>
Markdown/en/deconvolution.html ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ <div id="md_deconvolution" class="block normal mds svelte-90oupt padded hide-container" style="border-style: solid; overflow: visible; min-width: min(0px, 100%); border-width: var(--block-border-width);"><div class="wrap center full svelte-1occ011 hide" style="position: absolute; padding: 0px;"></div> <div class="svelte-1ed2p3z"><div class="prose normal mds svelte-1yrv54" data-testid="markdown" dir="ltr"><span class="md svelte-1syupzx"><p>As mentioned in the section 2, the transformation of Equation 2.1 can be divided into two sub-transformations, the first one being a linear transformation and the second being adding independent Gaussian noise. The linear transformation is equivalent to a scaling transform of the probability distribution, so it has an inverse transformation. Adding independent Gaussian noise is equivalent to the execution of a convolution operation on the probability distribution, which can be restored through <b>deconvolution</b>. Therefore, theoretically, the data distribution <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span> can be recovered from the final probability distribution <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mi>T</mi></msub><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(z_T)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span></span></span> through <b>inverse linear transform</b> and <b>deconvolution</b>.</p>
2
+ <p>However, in actuality, some problems do exist. Due to the extreme sensitivity of deconvolution to errors, having high input sensitivity, even a small amount of input noise can lead to significant changes in output<a href="#deconv_1">[11]</a><a href="#deconv_2">[12]</a>. Meanwhile, in the diffusion model, the standard normal distribution is used as an approximation to replace <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mi>T</mi></msub><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(z_T)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span></span></span>, thus, noise is introduced at the initial stage of recovery. Although the noise is relatively small, because of the sensitivity of deconvolution, the noise will gradually amplify, affecting the recovery.</p>
3
+ <p>In addition, the infeasibility of <b>deconvolution restoring</b> can be understood from another perspective. Since the process of forward transform (equations 4.1 to 4.4) is fixed, the convolution kernel is fixed. Therefore, the corresponding deconvolution transform is also fixed. Since the initial data distribution <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span> is arbitrary, any probability distribution can be transformed into an approximation of <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="script">N</mi><mo stretchy="false">(</mo><mn>0</mn><mo separator="true">,</mo><mi>I</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\mathcal{N}(0,I)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathcal" style="margin-right: 0.1474em;">N</span><span class="mopen">(</span><span class="mord">0</span><span class="mpunct">,</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord mathnormal" style="margin-right: 0.0785em;">I</span><span class="mclose">)</span></span></span></span></span> through a series of fixed linear transforms and convolutions. If <b>deconvolution restoring</b> is feasible, it means that a fixed deconvolution can be used to restore any data distribution <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span> from the <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="script">N</mi><mo stretchy="false">(</mo><mn>0</mn><mo separator="true">,</mo><mi>I</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\mathcal{N}(0,I)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathcal" style="margin-right: 0.1474em;">N</span><span class="mopen">(</span><span class="mord">0</span><span class="mpunct">,</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord mathnormal" style="margin-right: 0.0785em;">I</span><span class="mclose">)</span></span></span></span></span> , this is clearly <b>paradoxical</b>. The same input, the same transform, cannot have multiple different outputs.</p>
4
+ </span></div></div></div>
Markdown/en/fit_posterior.html ADDED
The diff for this file is too large to render. See raw diff
 
Markdown/en/forward_process.html ADDED
The diff for this file is too large to render. See raw diff
 
Markdown/en/introduction.html ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <div id="md_introduction" class="block normal mds svelte-90oupt padded hide-container" style="border-style: solid; overflow: visible; min-width: min(0px, 100%); border-width: var(--block-border-width);"><div class="wrap center full svelte-1occ011 hide" style="position: absolute; padding: 0px;"></div> <div class="svelte-1ed2p3z"><div class="prose normal mds svelte-1yrv54" data-testid="markdown" dir="ltr"><span class="md svelte-1syupzx"><p>The Diffusion Model<a href="#dpm">[1]</a><a href="#ddpm">[2]</a> is currently the main method used in image and video generation, but due to its abstruse theory, many engineers are unable to understand it well. This article will provide a very easy-to-understand method to help readers grasp the principles of the Diffusion Model. Specifically, it will illustrate the Diffusion Model using examples of one-dimensional random variables in an interactive way, explaining several interesting properties of the Diffusion Model in an intuitive manner.</p>
2
+ <p>The diffusion model is a probabilistic model. Probabilistic models mainly offer two functions: calculating the probability of a given sample appearing; and generating new samples. The diffusion model focuses on the latter aspect, facilitating the production of new samples, thus realizing the task of <strong>generation</strong>.</p>
3
+ <p>The diffusion model differs from general probability models (such as GMM), which directly models the probability distribution of random variables. The diffusion model adopts an indirect approach, which utilizes <strong>random variable transformation</strong>(shown in Figure 1a) to gradually convert the data distribution (the probability distribution to be modeled) into the <strong>standard normal distribution</strong>, and meanwhile models the posterior probability distribution corresponding to each transformation (Figure 1b-c). Upon obtaining the final standard normal distribution and the posterior probability distributions, one can generate samples of each random variable <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>Z</mi><mi>T</mi></msub><mo>…</mo><msub><mi>Z</mi><mn>2</mn></msub><mo separator="true">,</mo><msub><mi>Z</mi><mn>1</mn></msub><mo separator="true">,</mo><mi>X</mi></mrow><annotation encoding="application/x-tex">Z_T \ldots Z_2,Z_1,X</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.8778em; vertical-align: -0.1944em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0715em;">Z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.0715em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="minner">…</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0715em;">Z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.0715em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0715em;">Z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.0715em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord mathnormal" style="margin-right: 0.0785em;">X</span></span></span></span></span> in reverse order through Ancestral Sampling method. Simultaneously, initial data distribution <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span> can be determined by employing Bayes theorem and the total probability theorem.</p>
4
+ <p>One might wonder: indirect methods require modeling and learning T posterior probability distributions, while direct methods only need to model one probability distribution, Why would we choose the indirect approach? Here's the reasoning: the initial data distribution might be quite complex and hard to represent directly with a probability model. In contrast, the complexity of each posterior probability distribution in indirect methods is significantly simpler, allowing it to be approximated by simple probability models. As we will see later, given certain conditions, posterior probability distributions can closely resemble Gaussian distributions, thus a simple conditional Gaussian model can be used for modeling.</p>
5
+ <center> <img style="margin-top:12px" width="820" src="file/pipe.jpg"> </center>
6
+ <center> Figure 1: Diffusion model schematic </center></span></div></div></div>
Markdown/en/likelihood.html ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div id="md_likelihood" class="block normal mds svelte-90oupt padded hide-container" style="border-style: solid; overflow: visible; min-width: min(0px, 100%); border-width: var(--block-border-width);"><div class="wrap center full svelte-1occ011 hide" style="position: absolute; padding: 0px;"></div> <div class="svelte-1ed2p3z"><div class="prose normal mds svelte-1yrv54" data-testid="markdown" dir="ltr"><span class="md svelte-1syupzx"><p>From the transformation method (equation 1.1), it can be seen that the probability distribution of the forward conditional probability <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>z</mi><mi mathvariant="normal">∣</mi><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(z|x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mord">∣</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span> is a Gaussian distribution, which is only related to the value of <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi></mrow><annotation encoding="application/x-tex">\alpha</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span></span></span>, regardless of the probability distribution of <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>.
2
+ <span><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right left" columnspacing="0em"><mtr><mtd class="mtr-glue"></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>z</mi><mi mathvariant="normal">∣</mi><mi>x</mi><mo stretchy="false">)</mo></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mi mathvariant="script">N</mi><mo stretchy="false">(</mo><msqrt><mi>α</mi></msqrt><mi>x</mi><mo separator="true">,</mo><mtext>&nbsp;</mtext><mn>1</mn><mo>−</mo><mi>α</mi><mo stretchy="false">)</mo></mrow></mstyle></mtd><mtd class="mtr-glue"></mtd><mtd class="mml-eqn-num"></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{align}
3
+ q(z|x) &amp;= \mathcal{N}(\sqrt{\alpha}x,\ 1-\alpha) \tag{2.1}
4
+ \end{align}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1.5092em; vertical-align: -0.5046em;"></span><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.0046em;"><span class="" style="top: -3.1554em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mord">∣</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.5046em;"><span class=""></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.0046em;"><span class="" style="top: -3.1554em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mord mathcal" style="margin-right: 0.1474em;">N</span><span class="mopen">(</span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.8492em;"><span class="svg-align" style="top: -3em;"><span class="pstrut" style="height: 3em;"></span><span class="mord" style="padding-left: 0.833em;"><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span><span class="" style="top: -2.8092em;"><span class="pstrut" style="height: 3em;"></span><span class="hide-tail" style="min-width: 0.853em; height: 1.08em;"><svg width="400em" height="1.08em" viewBox="0 0 400000 1080" preserveAspectRatio="xMinYMin slice"><path d="M95,702
5
+ c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
6
+ c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
7
+ c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
8
+ s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
9
+ c69,-144,104.5,-217.7,106.5,-221
10
+ l0 -0
11
+ c5.3,-9.3,12,-14,20,-14
12
+ H400000v40H845.2724
13
+ s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
14
+ c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
15
+ M834 80h400000v40h-400000z"></path></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.1908em;"><span class=""></span></span></span></span></span><span class="mord mathnormal">x</span><span class="mpunct">,</span><span class="mspace">&nbsp;</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord">1</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span><span class="mclose">)</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.5046em;"><span class=""></span></span></span></span></span></span></span><span class="tag"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.0046em;"><span class="" style="top: -3.1554em;"><span class="pstrut" style="height: 3em;"></span><span class=""><span class="mord text"><span class="mord">(</span><span class="mord"><span class="mord">2.1</span></span><span class="mord">)</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.5046em;"><span class=""></span></span></span></span></span></span></span></span></span>
16
+ It can be understood by concrete examples in Demo 2. The third figure depict the shape of <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>z</mi><mi mathvariant="normal">∣</mi><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(z|x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mord">∣</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>. From the figure, a uniform slanting line can be observed. This implies that the mean of <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>z</mi><mi mathvariant="normal">∣</mi><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(z|x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mord">∣</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span> is linearly related to x, and the variance is fixed. The magnitude of <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi></mrow><annotation encoding="application/x-tex">\alpha</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span></span></span> will determine the width and incline of the slanting line.</p>
17
+ </span></div></div></div>
Markdown/en/posterior.html ADDED
@@ -0,0 +1,122 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div id="md_posterior" class="block normal mds svelte-90oupt padded hide-container" style="border-style: solid; overflow: visible; min-width: min(0px, 100%); border-width: var(--block-border-width);"><div class="wrap center full svelte-1occ011 hide" style="position: absolute; padding: 0px;"></div> <div class="svelte-1ed2p3z"><div class="prose normal mds svelte-1yrv54" data-testid="markdown" dir="ltr"><span class="md svelte-1syupzx"><p>The posterior probability distribution does not have a closed form, but its shape can be inferred approximately through some technique.</p>
2
+ <p>According to Bayes formula, we have
3
+ <span><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right" columnspacing=""><mtr><mtd class="mtr-glue"></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo><mo>=</mo><mfrac><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>z</mi><mi mathvariant="normal">∣</mi><mi>x</mi><mo stretchy="false">)</mo><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>z</mi><mo stretchy="false">)</mo></mrow></mfrac></mrow></mstyle></mtd><mtd class="mtr-glue"></mtd><mtd class="mml-eqn-num"></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{align}
4
+ q(x|z) = \frac{q(z|x)q(x)}{q(z)} \tag{3.1}
5
+ \end{align}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 2.663em; vertical-align: -1.0815em;"></span><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.5815em;"><span class="" style="top: -3.5815em;"><span class="pstrut" style="height: 3.427em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.427em;"><span class="" style="top: -2.314em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span></span></span><span class="" style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span class="" style="top: -3.677em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mord">∣</span><span class="mord mathnormal">x</span><span class="mclose">)</span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.936em;"><span class=""></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 1.0815em;"><span class=""></span></span></span></span></span></span></span><span class="tag"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.5815em;"><span class="" style="top: -3.5815em;"><span class="pstrut" style="height: 3.427em;"></span><span class=""><span class="mord text"><span class="mord">(</span><span class="mord"><span class="mord">3.1</span></span><span class="mord">)</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 1.0815em;"><span class=""></span></span></span></span></span></span></span></span></span></p>
6
+ <p>When <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>z</mi></mrow><annotation encoding="application/x-tex">z</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span></span></span></span></span> takes a fixed value, <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>z</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span></span></span></span></span> is a constant, so the shape of <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span></span></span></span></span> is only related to <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>z</mi><mi mathvariant="normal">∣</mi><mi>x</mi><mo stretchy="false">)</mo><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">{q(z|x)q(x)}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mord">∣</span><span class="mord mathnormal">x</span><span class="mclose">)</span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span></span>.
7
+ <span><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right" columnspacing=""><mtr><mtd class="mtr-glue"></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo><mo>∝</mo><mi>q</mi><mo stretchy="false">(</mo><mi>z</mi><mi mathvariant="normal">∣</mi><mi>x</mi><mo stretchy="false">)</mo><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mspace width="2em"></mspace><mi>w</mi><mi>h</mi><mi>e</mi><mi>r</mi><mi>e</mi><mtext>&nbsp;</mtext><mi>z</mi><mtext>&nbsp;</mtext><mi>i</mi><mi>s</mi><mtext>&nbsp;</mtext><mi>f</mi><mi>i</mi><mi>x</mi><mi>e</mi><mi>d</mi></mrow></mstyle></mtd><mtd class="mtr-glue"></mtd><mtd class="mml-eqn-num"></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{align}
8
+ q(x|z) \propto q(z|x)q(x) \qquad where\ z\ is\ fixed \tag{3.2}
9
+ \end{align}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1.5em; vertical-align: -0.5em;"></span><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1em;"><span class="" style="top: -3.16em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">∝</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mord">∣</span><span class="mord mathnormal">x</span><span class="mclose">)</span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span><span class="mspace" style="margin-right: 2em;"></span><span class="mord mathnormal" style="margin-right: 0.0269em;">w</span><span class="mord mathnormal">h</span><span class="mord mathnormal">ere</span><span class="mspace">&nbsp;</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mspace">&nbsp;</span><span class="mord mathnormal">i</span><span class="mord mathnormal">s</span><span class="mspace">&nbsp;</span><span class="mord mathnormal" style="margin-right: 0.1076em;">f</span><span class="mord mathnormal">i</span><span class="mord mathnormal">x</span><span class="mord mathnormal">e</span><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.5em;"><span class=""></span></span></span></span></span></span></span><span class="tag"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1em;"><span class="" style="top: -3.16em;"><span class="pstrut" style="height: 3em;"></span><span class=""><span class="mord text"><span class="mord">(</span><span class="mord"><span class="mord">3.2</span></span><span class="mord">)</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.5em;"><span class=""></span></span></span></span></span></span></span></span></span></p>
10
+ <p>From Equation 2.1, we can see that <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>z</mi><mi mathvariant="normal">∣</mi><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(z|x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mord">∣</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span> is a Gaussian distribution, so we have
11
+ <span><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right left right left" columnspacing="0em 1em 0em"><mtr><mtd class="mtr-glue"></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>∝</mo><mfrac><mn>1</mn><msqrt><mrow><mn>2</mn><mi>π</mi><mo stretchy="false">(</mo><mn>1</mn><mo>−</mo><mi>α</mi><mo stretchy="false">)</mo></mrow></msqrt></mfrac><mi>exp</mi><mo>⁡</mo><mfrac><mrow><mo>−</mo><mo stretchy="false">(</mo><mi>z</mi><mo>−</mo><msqrt><mi>α</mi></msqrt><mi>x</mi><msup><mo stretchy="false">)</mo><mn>2</mn></msup></mrow><mrow><mn>2</mn><mo stretchy="false">(</mo><mn>1</mn><mo>−</mo><mi>α</mi><mo stretchy="false">)</mo></mrow></mfrac><mtext>&nbsp;</mtext><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mspace width="2em"></mspace></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>w</mi><mi>h</mi><mi>e</mi><mi>r</mi><mi>e</mi><mtext>&nbsp;</mtext><mi>z</mi><mtext>&nbsp;</mtext><mi>i</mi><mi>s</mi><mtext>&nbsp;</mtext><mi>f</mi><mi>i</mi><mi>x</mi><mi>e</mi><mi>d</mi></mrow></mstyle></mtd><mtd class="mtr-glue"></mtd><mtd class="mml-eqn-num"></mtd></mtr><mtr><mtd class="mtr-glue"></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mfrac><mn>1</mn><msqrt><mi>α</mi></msqrt></mfrac><munder><munder><mrow><mfrac><mn>1</mn><mrow><msqrt><mrow><mn>2</mn><mi>π</mi></mrow></msqrt><mi>σ</mi></mrow></mfrac><mi>exp</mi><mo>⁡</mo><mfrac><mrow><mo>−</mo><mo stretchy="false">(</mo><mi>x</mi><mo>−</mo><mi>μ</mi><msup><mo stretchy="false">)</mo><mn>2</mn></msup></mrow><mrow><mn>2</mn><msup><mi>σ</mi><mn>2</mn></msup></mrow></mfrac></mrow><mo stretchy="true">⏟</mo></munder><mtext>GaussFun</mtext></munder><mtext>&nbsp;</mtext><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mspace width="2em"></mspace></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>w</mi><mi>h</mi><mi>e</mi><mi>r</mi><mi>e</mi><mtext>&nbsp;</mtext><mi>μ</mi><mo>=</mo><mfrac><mi>z</mi><msqrt><mi>α</mi></msqrt></mfrac><mspace width="1em"></mspace><mi>σ</mi><mo>=</mo><msqrt><mfrac><mrow><mn>1</mn><mo>−</mo><mi>α</mi></mrow><mi>α</mi></mfrac></msqrt></mrow></mstyle></mtd><mtd class="mtr-glue"></mtd><mtd class="mml-eqn-num"></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{align}
12
+ q(x|z) &amp;\propto \frac{1}{\sqrt{2\pi(1-\alpha)}}\exp{\frac{-(z-\sqrt{\alpha}x)^2}{2(1-\alpha)}}\ q(x)&amp; \qquad &amp;where\ z\ is\ fixed \tag{3.3} \newline
13
+ &amp;= \frac{1}{\sqrt{\alpha}} \underbrace{\frac{1}{\sqrt{2\pi}\sigma}\exp{\frac{-(x-\mu)^2}{2\sigma^2}}}_{\text{GaussFun}}\ q(x)&amp; \qquad &amp;where\ \mu=\frac{z}{\sqrt{\alpha}}\quad \sigma=\sqrt{\frac{1-\alpha}{\alpha}} \tag{3.4}
14
+ \end{align}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 7.129em; vertical-align: -3.3145em;"></span><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 3.8145em;"><span class="" style="top: -5.975em;"><span class="pstrut" style="height: 3.6516em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span></span></span><span class="" style="top: -2.8934em;"><span class="pstrut" style="height: 3.6516em;"></span><span class="mord"></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 3.3145em;"><span class=""></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 3.8145em;"><span class="" style="top: -5.975em;"><span class="pstrut" style="height: 3.6516em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">∝</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.3214em;"><span class="" style="top: -2.175em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.935em;"><span class="svg-align" style="top: -3.2em;"><span class="pstrut" style="height: 3.2em;"></span><span class="mord" style="padding-left: 1em;"><span class="mord">2</span><span class="mord mathnormal" style="margin-right: 0.0359em;">π</span><span class="mopen">(</span><span class="mord">1</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span><span class="mclose">)</span></span></span><span class="" style="top: -2.895em;"><span class="pstrut" style="height: 3.2em;"></span><span class="hide-tail" style="min-width: 1.02em; height: 1.28em;"><svg width="400em" height="1.28em" viewBox="0 0 400000 1296" preserveAspectRatio="xMinYMin slice"><path d="M263,681c0.7,0,18,39.7,52,119
15
+ c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
16
+ c340,-704.7,510.7,-1060.3,512,-1067
17
+ l0 -0
18
+ c4.7,-7.3,11,-11,19,-11
19
+ H40000v40H1012.3
20
+ s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
21
+ c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
22
+ s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
23
+ c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
24
+ M1001 80h400000v40h-400000z"></path></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.305em;"><span class=""></span></span></span></span></span></span></span><span class="" style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span class="" style="top: -3.677em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 1.13em;"><span class=""></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mop">exp</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord"><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.4911em;"><span class="" style="top: -2.314em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">2</span><span class="mopen">(</span><span class="mord">1</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span><span class="mclose">)</span></span></span><span class="" style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span class="" style="top: -3.677em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">−</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.8003em;"><span class="svg-align" style="top: -3em;"><span class="pstrut" style="height: 3em;"></span><span class="mord" style="padding-left: 0.833em;"><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span><span class="" style="top: -2.7603em;"><span class="pstrut" style="height: 3em;"></span><span class="hide-tail" style="min-width: 0.853em; height: 1.08em;"><svg width="400em" height="1.08em" viewBox="0 0 400000 1080" preserveAspectRatio="xMinYMin slice"><path d="M95,702
25
+ c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
26
+ c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
27
+ c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
28
+ s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
29
+ c69,-144,104.5,-217.7,106.5,-221
30
+ l0 -0
31
+ c5.3,-9.3,12,-14,20,-14
32
+ H400000v40H845.2724
33
+ s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
34
+ c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
35
+ M834 80h400000v40h-400000z"></path></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.2397em;"><span class=""></span></span></span></span></span><span class="mord mathnormal">x</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height: 0.8141em;"><span class="" style="top: -3.063em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.936em;"><span class=""></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span><span class="mspace">&nbsp;</span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span><span class="" style="top: -2.8934em;"><span class="pstrut" style="height: 3.6516em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.3214em;"><span class="" style="top: -2.3097em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.8003em;"><span class="svg-align" style="top: -3em;"><span class="pstrut" style="height: 3em;"></span><span class="mord" style="padding-left: 0.833em;"><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span><span class="" style="top: -2.7603em;"><span class="pstrut" style="height: 3em;"></span><span class="hide-tail" style="min-width: 0.853em; height: 1.08em;"><svg width="400em" height="1.08em" viewBox="0 0 400000 1080" preserveAspectRatio="xMinYMin slice"><path d="M95,702
36
+ c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
37
+ c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
38
+ c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
39
+ s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
40
+ c69,-144,104.5,-217.7,106.5,-221
41
+ l0 -0
42
+ c5.3,-9.3,12,-14,20,-14
43
+ H400000v40H845.2724
44
+ s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
45
+ c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
46
+ M834 80h400000v40h-400000z"></path></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.2397em;"><span class=""></span></span></span></span></span></span></span><span class="" style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span class="" style="top: -3.677em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.93em;"><span class=""></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord munder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.4911em;"><span class="" style="top: -1.2348em;"><span class="pstrut" style="height: 3.4911em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord text mtight"><span class="mord mtight">GaussFun</span></span></span></span></span><span class="" style="top: -3.4911em;"><span class="pstrut" style="height: 3.4911em;"></span><span class="mord munder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.4911em;"><span class="svg-align" style="top: -1.9131em;"><span class="pstrut" style="height: 3.4911em;"></span><span class="stretchy" style="height: 0.548em; min-width: 1.6em;"><span class="brace-left" style="height: 0.548em;"><svg width="400em" height="0.548em" viewBox="0 0 400000 548" preserveAspectRatio="xMinYMin slice"><path d="M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13
47
+ 35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688
48
+ 0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7
49
+ -331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z"></path></svg></span><span class="brace-center" style="height: 0.548em;"><svg width="400em" height="0.548em" viewBox="0 0 400000 548" preserveAspectRatio="xMidYMin slice"><path d="M199572 214
50
+ c100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14
51
+ 53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3
52
+ 11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0
53
+ -5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z"></path></svg></span><span class="brace-right" style="height: 0.548em;"><svg width="400em" height="0.548em" viewBox="0 0 400000 548" preserveAspectRatio="xMaxYMin slice"><path d="M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3
54
+ 28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237
55
+ -174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z"></path></svg></span></span></span><span class="" style="top: -3.4911em;"><span class="pstrut" style="height: 3.4911em;"></span><span class="mord"><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.3214em;"><span class="" style="top: -2.2028em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.9072em;"><span class="svg-align" style="top: -3em;"><span class="pstrut" style="height: 3em;"></span><span class="mord" style="padding-left: 0.833em;"><span class="mord">2</span><span class="mord mathnormal" style="margin-right: 0.0359em;">π</span></span></span><span class="" style="top: -2.8672em;"><span class="pstrut" style="height: 3em;"></span><span class="hide-tail" style="min-width: 0.853em; height: 1.08em;"><svg width="400em" height="1.08em" viewBox="0 0 400000 1080" preserveAspectRatio="xMinYMin slice"><path d="M95,702
56
+ c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
57
+ c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
58
+ c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
59
+ s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
60
+ c69,-144,104.5,-217.7,106.5,-221
61
+ l0 -0
62
+ c5.3,-9.3,12,-14,20,-14
63
+ H400000v40H845.2724
64
+ s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
65
+ c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
66
+ M834 80h400000v40h-400000z"></path></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.1328em;"><span class=""></span></span></span></span></span><span class="mord mathnormal" style="margin-right: 0.0359em;">σ</span></span></span><span class="" style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span class="" style="top: -3.677em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.93em;"><span class=""></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mop">exp</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord"><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.4911em;"><span class="" style="top: -2.314em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">2</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0359em;">σ</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height: 0.7401em;"><span class="" style="top: -2.989em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span class="" style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span class="" style="top: -3.677em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">−</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mord mathnormal">μ</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height: 0.8141em;"><span class="" style="top: -3.063em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.686em;"><span class=""></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 1.578em;"><span class=""></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 2.2563em;"><span class=""></span></span></span></span></span><span class="mspace">&nbsp;</span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 3.3145em;"><span class=""></span></span></span></span></span><span class="arraycolsep" style="width: 1em;"></span><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 3.8145em;"><span class="" style="top: -5.975em;"><span class="pstrut" style="height: 3.6516em;"></span><span class="mord"><span class="mspace" style="margin-right: 2em;"></span></span></span><span class="" style="top: -2.8934em;"><span class="pstrut" style="height: 3.6516em;"></span><span class="mord"><span class="mspace" style="margin-right: 2em;"></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 3.3145em;"><span class=""></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 3.8145em;"><span class="" style="top: -5.975em;"><span class="pstrut" style="height: 3.6516em;"></span><span class="mord"><span class="mord"></span><span class="mord mathnormal" style="margin-right: 0.0269em;">w</span><span class="mord mathnormal">h</span><span class="mord mathnormal">ere</span><span class="mspace">&nbsp;</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mspace">&nbsp;</span><span class="mord mathnormal">i</span><span class="mord mathnormal">s</span><span class="mspace">&nbsp;</span><span class="mord mathnormal" style="margin-right: 0.1076em;">f</span><span class="mord mathnormal">i</span><span class="mord mathnormal">x</span><span class="mord mathnormal">e</span><span class="mord mathnormal">d</span></span></span><span class="" style="top: -2.8934em;"><span class="pstrut" style="height: 3.6516em;"></span><span class="mord"><span class="mord"></span><span class="mord mathnormal" style="margin-right: 0.0269em;">w</span><span class="mord mathnormal">h</span><span class="mord mathnormal">ere</span><span class="mspace">&nbsp;</span><span class="mord mathnormal">μ</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.1076em;"><span class="" style="top: -2.3097em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.8003em;"><span class="svg-align" style="top: -3em;"><span class="pstrut" style="height: 3em;"></span><span class="mord" style="padding-left: 0.833em;"><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span><span class="" style="top: -2.7603em;"><span class="pstrut" style="height: 3em;"></span><span class="hide-tail" style="min-width: 0.853em; height: 1.08em;"><svg width="400em" height="1.08em" viewBox="0 0 400000 1080" preserveAspectRatio="xMinYMin slice"><path d="M95,702
67
+ c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
68
+ c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
69
+ c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
70
+ s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
71
+ c69,-144,104.5,-217.7,106.5,-221
72
+ l0 -0
73
+ c5.3,-9.3,12,-14,20,-14
74
+ H400000v40H845.2724
75
+ s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
76
+ c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
77
+ M834 80h400000v40h-400000z"></path></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.2397em;"><span class=""></span></span></span></span></span></span></span><span class="" style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span class="" style="top: -3.677em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.93em;"><span class=""></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right: 1em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">σ</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.6516em;"><span class="svg-align" style="top: -4.4em;"><span class="pstrut" style="height: 4.4em;"></span><span class="mord" style="padding-left: 1em;"><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.3214em;"><span class="" style="top: -2.314em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span><span class="" style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span class="" style="top: -3.677em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">1</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.686em;"><span class=""></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span><span class="" style="top: -3.6116em;"><span class="pstrut" style="height: 4.4em;"></span><span class="hide-tail" style="min-width: 1.02em; height: 2.48em;"><svg width="400em" height="2.48em" viewBox="0 0 400000 2592" preserveAspectRatio="xMinYMin slice"><path d="M424,2478
78
+ c-1.3,-0.7,-38.5,-172,-111.5,-514c-73,-342,-109.8,-513.3,-110.5,-514
79
+ c0,-2,-10.7,14.3,-32,49c-4.7,7.3,-9.8,15.7,-15.5,25c-5.7,9.3,-9.8,16,-12.5,20
80
+ s-5,7,-5,7c-4,-3.3,-8.3,-7.7,-13,-13s-13,-13,-13,-13s76,-122,76,-122s77,-121,77,-121
81
+ s209,968,209,968c0,-2,84.7,-361.7,254,-1079c169.3,-717.3,254.7,-1077.7,256,-1081
82
+ l0 -0c4,-6.7,10,-10,18,-10 H400000
83
+ v40H1014.6
84
+ s-87.3,378.7,-272.6,1166c-185.3,787.3,-279.3,1182.3,-282,1185
85
+ c-2,6,-10,9,-24,9
86
+ c-8,0,-12,-0.7,-12,-2z M1001 80
87
+ h400000v40h-400000z"></path></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.7884em;"><span class=""></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 3.3145em;"><span class=""></span></span></span></span></span></span></span><span class="tag"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 3.8145em;"><span class="" style="top: -5.975em;"><span class="pstrut" style="height: 3.6516em;"></span><span class=""><span class="mord text"><span class="mord">(</span><span class="mord"><span class="mord">3.3</span></span><span class="mord">)</span></span></span></span><span class="" style="top: -2.8934em;"><span class="pstrut" style="height: 3.6516em;"></span><span class=""><span class="mord text"><span class="mord">(</span><span class="mord"><span class="mord">3.4</span></span><span class="mord">)</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 3.3145em;"><span class=""></span></span></span></span></span></span></span></span></span></p>
88
+ <p>It can be observed that the <b>GaussFun</b> part is a Gaussian function of <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi></mrow><annotation encoding="application/x-tex">x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal">x</span></span></span></span></span>, with a mean of <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mi>z</mi><msqrt><mi>α</mi></msqrt></mfrac></mrow><annotation encoding="application/x-tex">\frac{z}{\sqrt{\alpha}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1.2334em; vertical-align: -0.538em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.6954em;"><span class="" style="top: -2.6259em;"><span class="pstrut" style="height: 3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord sqrt mtight"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.8059em;"><span class="svg-align" style="top: -3em;"><span class="pstrut" style="height: 3em;"></span><span class="mord mtight" style="padding-left: 0.833em;"><span class="mord mathnormal mtight" style="margin-right: 0.0037em;">α</span></span></span><span class="" style="top: -2.7659em;"><span class="pstrut" style="height: 3em;"></span><span class="hide-tail mtight" style="min-width: 0.853em; height: 1.08em;"><svg width="400em" height="1.08em" viewBox="0 0 400000 1080" preserveAspectRatio="xMinYMin slice"><path d="M95,702
89
+ c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
90
+ c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
91
+ c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
92
+ s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
93
+ c69,-144,104.5,-217.7,106.5,-221
94
+ l0 -0
95
+ c5.3,-9.3,12,-14,20,-14
96
+ H400000v40H845.2724
97
+ s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
98
+ c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
99
+ M834 80h400000v40h-400000z"></path></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.2341em;"><span class=""></span></span></span></span></span></span></span></span><span class="" style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span class="" style="top: -3.394em;"><span class="pstrut" style="height: 3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right: 0.044em;">z</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.538em;"><span class=""></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span> and a variance of <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msqrt><mfrac><mrow><mn>1</mn><mo>−</mo><mi>α</mi></mrow><mi>α</mi></mfrac></msqrt></mrow><annotation encoding="application/x-tex">\sqrt{\frac{1-\alpha}{\alpha}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1.84em; vertical-align: -0.6049em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.2351em;"><span class="svg-align" style="top: -3.8em;"><span class="pstrut" style="height: 3.8em;"></span><span class="mord" style="padding-left: 1em;"><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.8451em;"><span class="" style="top: -2.655em;"><span class="pstrut" style="height: 3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right: 0.0037em;">α</span></span></span></span><span class="" style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span class="" style="top: -3.394em;"><span class="pstrut" style="height: 3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span><span class="mbin mtight">−</span><span class="mord mathnormal mtight" style="margin-right: 0.0037em;">α</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.345em;"><span class=""></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span><span class="" style="top: -3.1951em;"><span class="pstrut" style="height: 3.8em;"></span><span class="hide-tail" style="min-width: 1.02em; height: 1.88em;"><svg width="400em" height="1.88em" viewBox="0 0 400000 1944" preserveAspectRatio="xMinYMin slice"><path d="M983 90
100
+ l0 -0
101
+ c4,-6.7,10,-10,18,-10 H400000v40
102
+ H1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7
103
+ s-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744
104
+ c-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30
105
+ c26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722
106
+ c56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5
107
+ c53.7,-170.3,84.5,-266.8,92.5,-289.5z
108
+ M1001 80h400000v40h-400000z"></path></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.6049em;"><span class=""></span></span></span></span></span></span></span></span></span>, so the shape of <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span></span></span></span></span> is determined by <strong>the product of GaussFun and q(x)</strong>.</p>
109
+ <p>According to the characteristics of <em>multiplication</em>, the characteristics of the shape of the <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span></span></span></span></span> function can be summarized. </p>
110
+ <ul>
111
+ <li>When the variance of the Gaussian function is small (small noise), or when <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span> changes slowly, the shape of <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span></span></span></span></span> will approximate to the Gaussian function, and have a simpler function form, which is convenient for modeling and learning.</li>
112
+
113
+ <li>When the variance of the Gaussian function is large (large noise), or when <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span> changes drastically, the shape of <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span></span></span></span></span> will be more complex, and greatly differ from a Gaussian function, which makes it difficult to model and learn.</li>
114
+ </ul>
115
+
116
+ <p>The specifics can be seen in Demo 2. The fourth figure present the shape of the posterior <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span></span></span></span></span>, which shows an irregular shape and resembles a curved and uneven line. As <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi></mrow><annotation encoding="application/x-tex">\alpha</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span></span></span> increases (noise decreases), the curve tends to be uniform and straight. Readers can adjust different <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi></mrow><annotation encoding="application/x-tex">\alpha</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span></span></span> values and observe the relationship between the shape of posterior and the level of noise. In the last figure, the <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="blue"><mtext>blue&nbsp;dash&nbsp;line</mtext></mstyle></mrow><annotation encoding="application/x-tex">\textcolor{blue}{\text{blue dash line}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.6944em;"></span><span class="mord text" style="color: blue;"><span class="mord" style="color: blue;">blue&nbsp;dash&nbsp;line</span></span></span></span></span></span> represents <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>, the <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="green"><mtext>green&nbsp;dash&nbsp;line</mtext></mstyle></mrow><annotation encoding="application/x-tex">\textcolor{green}{\text{green dash line}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.8889em; vertical-align: -0.1944em;"></span><span class="mord text" style="color: green;"><span class="mord" style="color: green;">green&nbsp;dash&nbsp;line</span></span></span></span></span></span> represents <b>GaussFun</b> in the equation 3.4, and the <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="orange"><mtext>orange&nbsp;curve</mtext></mstyle></mrow><annotation encoding="application/x-tex">\textcolor{orange}{\text{orange curve}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.625em; vertical-align: -0.1944em;"></span><span class="mord text" style="color: orange;"><span class="mord" style="color: orange;">orange&nbsp;curve</span></span></span></span></span></span> represents the result of multiplying the two function and normalizing it, which is the posterior probability <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo>=</mo><mi>f</mi><mi>i</mi><mi>x</mi><mi>e</mi><mi>d</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z=fixed)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span></span><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.1076em;">f</span><span class="mord mathnormal">i</span><span class="mord mathnormal">x</span><span class="mord mathnormal">e</span><span class="mord mathnormal">d</span><span class="mclose">)</span></span></span></span></span> under a fixed z condition. Readers can adjust different values of z to observe how the fluctuation of <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span> affect the shape of the posterior probability <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span></span></span></span></span>.</p>
117
+ <p>The posterior <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span></span></span></span></span> under two special states are worth considering.</p>
118
+ <ul>
119
+ <li>As <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi><mo>→</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">\alpha \to 0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">→</span><span class="mspace" style="margin-right: 0.2778em;"></span></span><span class="base"><span class="strut" style="height: 0.6444em;"></span><span class="mord">0</span></span></span></span></span>, the variance of <b>GaussFun</b> tends to <b><span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="normal">∞</mi></mrow><annotation encoding="application/x-tex">\infty</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord">∞</span></span></span></span></span></b>, and <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span></span></span></span></span> for different <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>z</mi></mrow><annotation encoding="application/x-tex">z</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span></span></span></span></span> almost become identical, and almost the same as <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>. Readers can set <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi></mrow><annotation encoding="application/x-tex">\alpha</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span></span></span> to 0.01 in Demo 2 to observe the specific results.</li>
120
+
121
+ <li>As <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi><mo>→</mo><mn>1</mn></mrow><annotation encoding="application/x-tex">\alpha \to 1</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">→</span><span class="mspace" style="margin-right: 0.2778em;"></span></span><span class="base"><span class="strut" style="height: 0.6444em;"></span><span class="mord">1</span></span></span></span></span>, the variance of <b>GaussFun</b> tends to <b><span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>0</mn></mrow><annotation encoding="application/x-tex">0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.6444em;"></span><span class="mord">0</span></span></span></span></span></b>, The <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span></span></span></span></span> for different <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>z</mi></mrow><annotation encoding="application/x-tex">z</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span></span></span></span></span> values contract into a series of <em>Dirac delta functions</em> with different offsets equalling to <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>z</mi></mrow><annotation encoding="application/x-tex">z</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span></span></span></span></span>. However, there are some exceptions. When there are regions where <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span> is zero, the corresponding <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span></span></span></span></span> will no longer be a Dirac <em>delta function</em>, but a zero function. Readers can set <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi></mrow><annotation encoding="application/x-tex">\alpha</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span></span></span> to 0.999 in Demo 2 to observe the specific results.</li>
122
+ </ul></span></div></div></div>
Markdown/en/posterior_transform.html ADDED
The diff for this file is too large to render. See raw diff
 
Markdown/en/reference.html ADDED
@@ -0,0 +1,16 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div id="md_reference" class="block normal mds svelte-90oupt padded hide-container" style="border-style: solid; overflow: visible; min-width: min(0px, 100%); border-width: var(--block-border-width);"><div class="wrap center full svelte-1occ011 hide" style="position: absolute; padding: 0px;"></div> <div class="svelte-1ed2p3z"><div class="prose normal mds svelte-1yrv54" data-testid="markdown" dir="ltr"><span class="md svelte-1syupzx"><p><a href="https://arxiv.org/abs/1503.03585" id="dpm" target="_blank" rel="noopener noreferrer"> [1] Deep Unsupervised Learning Using Nonequilibrium Thermodynami </a></p>
2
+ <p><a href="https://arxiv.org/abs/1503.03585" id="ddpm" target="_blank" rel="noopener noreferrer"> [2] Denoising Diffusion Probabilistic Models </a></p>
3
+ <p><a href="https://stats.libretexts.org/Bookshelves/Probability_Theory/Probability_Mathematical_Statistics_and_Stochastic_Processes_(Siegrist)/03%3A_Distributions/3.07%3A_Transformations_of_Random_Variables" id="linear_transform" target="_blank" rel="noopener noreferrer"> [3] Linear Transformations of Random Variable </a></p>
4
+ <p><a href="https://stats.libretexts.org/Bookshelves/Probability_Theory/Probability_Mathematical_Statistics_and_Stochastic_Processes_(Siegrist)/03%3A_Distributions/3.07%3A_Transformations_of_Random_Variables" id="sum_conv" target="_blank" rel="noopener noreferrer"> [4] Sums and Convolution </a></p>
5
+ <p><a href="https://en.wikipedia.org/wiki/Banach_fixed-point_theorem" id="fixed_point" target="_blank" rel="noopener noreferrer"> [5] Banach fixed-point theorem </a></p>
6
+ <p><a href="https://en.wikipedia.org/wiki/Contraction_mapping" id="ctr" target="_blank" rel="noopener noreferrer"> [6] Contraction mapping </a></p>
7
+ <p><a href="https://stats.libretexts.org/Bookshelves/Probability_Theory/Book%3A_Introductory_Probability_(Grinstead_and_Snell)/11%3A_Markov_Chains/11.04%3A_Fundamental_Limit_Theorem_for_Regular_Chains" id="mc_limit" target="_blank" rel="noopener noreferrer"> [7] Fundamental Limit Theorem for Regular Chains </a></p>
8
+ <p><a href="http://galton.uchicago.edu/~lalley/Courses/312/MarkovChains.pdf" id="mc_basic_p6" target="_blank" rel="noopener noreferrer"> [8] Markov Chain:Basic Theory - Proposition 6 </a></p>
9
+ <p><a href="https://arxiv.org/abs/1702.07339" id="fp_converse" target="_blank" rel="noopener noreferrer"> [9] A Converse to Banach's Fixed Point Theorem and its CLS Completeness </a></p>
10
+ <p><a href="https://en.wikipedia.org/wiki/Cross-entropy#Cross-entropy_minimization" id="ce_kl" target="_blank" rel="noopener noreferrer"> [10] Cross-entropy minimization </a></p>
11
+ <p><a href="https://thewolfsound.com/deconvolution-inverse-convolution/" id="deconv_1" target="_blank" rel="noopener noreferrer"> [11] Deconvolution Using Frequency-Domain Division </a></p>
12
+ <p><a href="https://www.strollswithmydog.com/deconvolution-by-division-in-the-frequency-domain/" id="deconv_2" target="_blank" rel="noopener noreferrer"> [12] deconvolution-by-division-in-the-frequency-domain </a></p>
13
+ <p><a href="http://galton.uchicago.edu/~lalley/Courses/312/MarkovChains.pdf" id="mc_basic_t7" target="_blank" rel="noopener noreferrer"> [13] Markov Chain:Basic Theory - Theorem 7 </a></p>
14
+ <p><a href="http://galton.uchicago.edu/~lalley/Courses/312/MarkovChains.pdf" id="mc_basic_d4" target="_blank" rel="noopener noreferrer"> [14] Markov Chain:Basic Theory - Definition 4 </a>
15
+ </p>
16
+ </span></div></div></div>
Markdown/en/transform.html ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div id="md_transform" class="block normal mds svelte-90oupt padded hide-container" style="border-style: solid; overflow: visible; min-width: min(0px, 100%); border-width: var(--block-border-width);"><div class="wrap center full svelte-1occ011 hide" style="position: absolute; padding: 0px;"></div> <div class="svelte-1ed2p3z"><div class="prose normal mds svelte-1yrv54" data-testid="markdown" dir="ltr"><span class="md svelte-1syupzx"><p>To transform the initial data distribution into a simple standard normal distribution, the diffusion model uses the following transformation method:
2
+ <span><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right" columnspacing=""><mtr><mtd class="mtr-glue"></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>Z</mi><mo>=</mo><msqrt><mi>α</mi></msqrt><mi>X</mi><mo>+</mo><msqrt><mrow><mn>1</mn><mo>−</mo><mi>α</mi></mrow></msqrt><mi>ϵ</mi><mspace width="2em"></mspace><mi>w</mi><mi>h</mi><mi>e</mi><mi>r</mi><mi>e</mi><mspace width="1em"></mspace><mi>α</mi><mo>&lt;</mo><mn>1</mn><mo separator="true">,</mo><mspace width="1em"></mspace><mi>ϵ</mi><mo>∼</mo><mi mathvariant="script">N</mi><mo stretchy="false">(</mo><mn>0</mn><mo separator="true">,</mo><mi>I</mi><mo stretchy="false">)</mo></mrow></mstyle></mtd><mtd class="mtr-glue"></mtd><mtd class="mml-eqn-num"></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{align}
3
+ Z = \sqrt{\alpha} X + \sqrt{1-\alpha}\epsilon \qquad where \quad \alpha &lt; 1, \quad \epsilon \sim \mathcal{N}(0, I) \tag{1.1}
4
+ \end{align}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1.5744em; vertical-align: -0.5372em;"></span><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.0372em;"><span class="" style="top: -3.1228em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0715em;">Z</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.8492em;"><span class="svg-align" style="top: -3em;"><span class="pstrut" style="height: 3em;"></span><span class="mord" style="padding-left: 0.833em;"><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span><span class="" style="top: -2.8092em;"><span class="pstrut" style="height: 3em;"></span><span class="hide-tail" style="min-width: 0.853em; height: 1.08em;"><svg width="400em" height="1.08em" viewBox="0 0 400000 1080" preserveAspectRatio="xMinYMin slice"><path d="M95,702
5
+ c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
6
+ c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
7
+ c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
8
+ s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
9
+ c69,-144,104.5,-217.7,106.5,-221
10
+ l0 -0
11
+ c5.3,-9.3,12,-14,20,-14
12
+ H400000v40H845.2724
13
+ s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
14
+ c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
15
+ M834 80h400000v40h-400000z"></path></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.1908em;"><span class=""></span></span></span></span></span><span class="mord mathnormal" style="margin-right: 0.0785em;">X</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.9144em;"><span class="svg-align" style="top: -3em;"><span class="pstrut" style="height: 3em;"></span><span class="mord" style="padding-left: 0.833em;"><span class="mord">1</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span><span class="" style="top: -2.8744em;"><span class="pstrut" style="height: 3em;"></span><span class="hide-tail" style="min-width: 0.853em; height: 1.08em;"><svg width="400em" height="1.08em" viewBox="0 0 400000 1080" preserveAspectRatio="xMinYMin slice"><path d="M95,702
16
+ c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
17
+ c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
18
+ c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
19
+ s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
20
+ c69,-144,104.5,-217.7,106.5,-221
21
+ l0 -0
22
+ c5.3,-9.3,12,-14,20,-14
23
+ H400000v40H845.2724
24
+ s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
25
+ c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
26
+ M834 80h400000v40h-400000z"></path></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.1256em;"><span class=""></span></span></span></span></span><span class="mord mathnormal">ϵ</span><span class="mspace" style="margin-right: 2em;"></span><span class="mord mathnormal" style="margin-right: 0.0269em;">w</span><span class="mord mathnormal">h</span><span class="mord mathnormal">ere</span><span class="mspace" style="margin-right: 1em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">&lt;</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mord">1</span><span class="mpunct">,</span><span class="mspace" style="margin-right: 1em;"></span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord mathnormal">ϵ</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">∼</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mord mathcal" style="margin-right: 0.1474em;">N</span><span class="mopen">(</span><span class="mord">0</span><span class="mpunct">,</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord mathnormal" style="margin-right: 0.0785em;">I</span><span class="mclose">)</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.5372em;"><span class=""></span></span></span></span></span></span></span><span class="tag"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.0372em;"><span class="" style="top: -3.1228em;"><span class="pstrut" style="height: 3em;"></span><span class=""><span class="mord text"><span class="mord">(</span><span class="mord"><span class="mord">1.1</span></span><span class="mord">)</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.5372em;"><span class=""></span></span></span></span></span></span></span></span></span>
27
+ where <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>X</mi><mo>∼</mo><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">X\sim q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.6833em;"></span><span class="mord mathnormal" style="margin-right: 0.0785em;">X</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">∼</span><span class="mspace" style="margin-right: 0.2778em;"></span></span><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>is any random variable,<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Z</mi><mo>∼</mo><mi>q</mi><mo stretchy="false">(</mo><mi>Z</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">Z\sim q(Z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.6833em;"></span><span class="mord mathnormal" style="margin-right: 0.0715em;">Z</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">∼</span><span class="mspace" style="margin-right: 0.2778em;"></span></span><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right: 0.0715em;">Z</span><span class="mclose">)</span></span></span></span></span> is the transformed random variable。</p>
28
+ <p>This transformation can be divided into two sub-transformations。</p>
29
+ <p>The first sub-transformation performs a linear transformation (<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msqrt><mi>α</mi></msqrt><mi>X</mi></mrow><annotation encoding="application/x-tex">\sqrt{\alpha}X</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1.04em; vertical-align: -0.2397em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.8003em;"><span class="svg-align" style="top: -3em;"><span class="pstrut" style="height: 3em;"></span><span class="mord" style="padding-left: 0.833em;"><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span><span class="" style="top: -2.7603em;"><span class="pstrut" style="height: 3em;"></span><span class="hide-tail" style="min-width: 0.853em; height: 1.08em;"><svg width="400em" height="1.08em" viewBox="0 0 400000 1080" preserveAspectRatio="xMinYMin slice"><path d="M95,702
30
+ c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
31
+ c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
32
+ c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
33
+ s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
34
+ c69,-144,104.5,-217.7,106.5,-221
35
+ l0 -0
36
+ c5.3,-9.3,12,-14,20,-14
37
+ H400000v40H845.2724
38
+ s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
39
+ c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
40
+ M834 80h400000v40h-400000z"></path></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.2397em;"><span class=""></span></span></span></span></span><span class="mord mathnormal" style="margin-right: 0.0785em;">X</span></span></span></span></span>) on the random variable <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>X</mi></mrow><annotation encoding="application/x-tex">X</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.6833em;"></span><span class="mord mathnormal" style="margin-right: 0.0785em;">X</span></span></span></span></span>. According to the conclusion of the literature<a href="#linear_transform">[3]</a>, the linear transformation makes the probability distribution of <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>X</mi></mrow><annotation encoding="application/x-tex">X</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.6833em;"></span><span class="mord mathnormal" style="margin-right: 0.0785em;">X</span></span></span></span></span> <strong>narrower and taller</strong>, and the extent of <strong>narrowing and heightening</strong> is directly proportional to the value of <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi></mrow><annotation encoding="application/x-tex">\alpha</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span></span></span>. </p>
41
+ <p>This can be specifically seen in Demo 1, where the first figure depicts a randomly generated one-dimensional probability distribution, and the second figure represents the probability distribution after the linear transformation. It can be observed that the curve of the third figure has become <strong>narrower and taller</strong> compared to the first image. Readers can experiment with different <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi></mrow><annotation encoding="application/x-tex">\alpha</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span></span></span> to gain a more intuitive understanding.</p>
42
+ <p>The second sub-transformation is <strong>adding independent random noise</strong>(<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msqrt><mrow><mn>1</mn><mo>−</mo><mi>α</mi></mrow></msqrt><mi>ϵ</mi></mrow><annotation encoding="application/x-tex">\sqrt{1-\alpha}\epsilon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1.04em; vertical-align: -0.1744em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.8656em;"><span class="svg-align" style="top: -3em;"><span class="pstrut" style="height: 3em;"></span><span class="mord" style="padding-left: 0.833em;"><span class="mord">1</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span><span class="" style="top: -2.8256em;"><span class="pstrut" style="height: 3em;"></span><span class="hide-tail" style="min-width: 0.853em; height: 1.08em;"><svg width="400em" height="1.08em" viewBox="0 0 400000 1080" preserveAspectRatio="xMinYMin slice"><path d="M95,702
43
+ c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
44
+ c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
45
+ c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
46
+ s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
47
+ c69,-144,104.5,-217.7,106.5,-221
48
+ l0 -0
49
+ c5.3,-9.3,12,-14,20,-14
50
+ H400000v40H845.2724
51
+ s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
52
+ c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
53
+ M834 80h400000v40h-400000z"></path></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.1744em;"><span class=""></span></span></span></span></span><span class="mord mathnormal">ϵ</span></span></span></span></span>). According to the conclusion of the literature<a href="#sum_conv">[4]</a>, <strong>adding independent random variables</strong> is equivalent to performing convolution on the two probability distributions. Since the probability distribution of random noise is Gaussian, it is equivalent to performing a <strong>Gaussian Blur</strong> operation. After blurring, the original probability distribution will become smoother and more similar to the standard normal distribution. The degree of blurring is directly proportional to the noise level (<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msqrt><mrow><mn>1</mn><mo>−</mo><mi>α</mi></mrow></msqrt></mrow><annotation encoding="application/x-tex">\sqrt{1-\alpha}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1.04em; vertical-align: -0.1744em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.8656em;"><span class="svg-align" style="top: -3em;"><span class="pstrut" style="height: 3em;"></span><span class="mord" style="padding-left: 0.833em;"><span class="mord">1</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span><span class="" style="top: -2.8256em;"><span class="pstrut" style="height: 3em;"></span><span class="hide-tail" style="min-width: 0.853em; height: 1.08em;"><svg width="400em" height="1.08em" viewBox="0 0 400000 1080" preserveAspectRatio="xMinYMin slice"><path d="M95,702
54
+ c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
55
+ c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
56
+ c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
57
+ s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
58
+ c69,-144,104.5,-217.7,106.5,-221
59
+ l0 -0
60
+ c5.3,-9.3,12,-14,20,-14
61
+ H400000v40H845.2724
62
+ s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
63
+ c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
64
+ M834 80h400000v40h-400000z"></path></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.1744em;"><span class=""></span></span></span></span></span></span></span></span></span>).</p>
65
+ <p>For specifics, one can see Demo 1, where the first figure is a randomly generated one-dimensional probability distribution, and the third figure is the result after the transformation. It can be seen that the transformed probability distribution curve is smoother and there are fewer corners. The readers can test different <span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi></mrow><annotation encoding="application/x-tex">\alpha</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span></span></span> values to feel how the noise level affect the shape of the probability distribution. The last figure is the result after applying all two sub-transformations.</p>
66
+ </span></div></div></div>
Markdown/zh/about.html ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ <div id="md_about" class="block normal mds svelte-90oupt padded hide-container" style="border-style: solid; overflow: visible; min-width: min(0px, 100%); border-width: var(--block-border-width);"><div class="wrap center full svelte-1occ011 hide" style="position: absolute; padding: 0px;"></div> <div class="svelte-1ed2p3z"><div class="prose normal mds svelte-1yrv54" data-testid="markdown" dir="ltr"><span class="md svelte-1syupzx"><p><b>APP</b>: 本APP是使用Gradio开发,并部署在HuggingFace。由于资源有限(2核,16G内存),所以可能会响应较慢。为了更好地体验,建议从<a href="https://github.com/blairstar/The_Art_of_DPM" target="_blank" rel="noopener noreferrer">github</a>复制源代码,在本地机器运行。本APP只依赖Gradio, SciPy, Matplotlib。</p>
2
+ <p><b>Author</b>: 郑镇鑫,资深视觉算法工程师,十年算法开发经历,曾就职于腾讯京东等互联网公司,目前专注于视频生成(类似Sora)。</p>
3
+ <p><b>Email</b>: <a href="mailto:[email protected]" target="_blank" rel="noopener noreferrer">[email protected]</a> 。</p>
4
+ </span></div></div></div>
Markdown/zh/backward_process.html ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div id="md_backward_process" class="block normal mds svelte-90oupt padded hide-container" style="border-style: solid; overflow: visible; min-width: min(0px, 100%); border-width: var(--block-border-width);"><div class="wrap center full svelte-1occ011 hide" style="position: absolute; padding: 0px;"></div> <div class="svelte-1ed2p3z"><div class="prose normal mds svelte-1yrv54" data-testid="markdown" dir="ltr"><span class="md svelte-1syupzx"><p>如果知道了最终的概率分布<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mi>T</mi></msub><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(z_T)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span></span></span>及各个转换过程的后验概率<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo><mo separator="true">,</mo><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mrow><mi>t</mi><mo>−</mo><mn>1</mn></mrow></msub><mi mathvariant="normal">∣</mi><msub><mi>z</mi><mi>t</mi></msub><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z),q(z_{t-1}|z_t)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span><span class="mpunct">,</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">t</span><span class="mbin mtight">−</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.2083em;"><span class=""></span></span></span></span></span></span><span class="mord">∣</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.2806em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">t</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span></span></span>,则可通过“贝叶斯公式”和“全概率公式”恢复数据分布<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>,见式5.1~5.4。当最终的概率分布<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mi>T</mi></msub><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(z_T)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span></span></span>与标准正态分布很相似时,可用标准正态分布代替。</p>
2
+ <p>具体可看Demo 3.2。示例中<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mi>T</mi></msub><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(z_T)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span></span></span>使用<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="script">N</mi><mo stretchy="false">(</mo><mn>0</mn><mo separator="true">,</mo><mn>1</mn><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\mathcal{N}(0,1)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathcal" style="margin-right: 0.1474em;">N</span><span class="mopen">(</span><span class="mord">0</span><span class="mpunct">,</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord">1</span><span class="mclose">)</span></span></span></span></span>代替,同时通过JS Div给出了误差大小。恢复的概率分布<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mi>t</mi></msub><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(z_t)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.2806em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">t</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span></span></span>及<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>使用<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="green"><mtext>绿色曲线</mtext></mstyle></mrow><annotation encoding="application/x-tex">\textcolor{green}{绿色曲线}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.6833em;"></span><span class="mord cjk_fallback" style="color: green;">绿色曲线</span></span></span></span></span>标识,原始的概率分布使用<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="blue"><mtext>蓝色曲线</mtext></mstyle></mrow><annotation encoding="application/x-tex">\textcolor{blue}{蓝色曲线}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.6833em;"></span><span class="mord cjk_fallback" style="color: blue;">蓝色曲线</span></span></span></span></span>标识。可以看出,数据分布<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>能够被很好地恢复回来,并且误差(JS Divergence)会小于标准正态分布替换<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mi>T</mi></msub><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(z_T)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span></span></span>引起的误差。
3
+ <span><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right left" columnspacing="0em"><mtr><mtd class="mtr-glue"></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mrow><mi>T</mi><mo>−</mo><mn>1</mn></mrow></msub><mo stretchy="false">)</mo></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mo>∫</mo><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mrow><mi>T</mi><mo>−</mo><mn>1</mn></mrow></msub><mo separator="true">,</mo><msub><mi>z</mi><mi>T</mi></msub><mo stretchy="false">)</mo><mi>d</mi><msub><mi>z</mi><mi>T</mi></msub><mo>=</mo><mo>∫</mo><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mrow><mi>T</mi><mo>−</mo><mn>1</mn></mrow></msub><mi mathvariant="normal">∣</mi><msub><mi>z</mi><mi>T</mi></msub><mo stretchy="false">)</mo><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mi>T</mi></msub><mo stretchy="false">)</mo><mi>d</mi><msub><mi>z</mi><mi>T</mi></msub></mrow></mstyle></mtd><mtd class="mtr-glue"></mtd><mtd class="mml-eqn-num"></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>…</mo></mrow></mstyle></mtd></mtr><mtr><mtd class="mtr-glue"></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mrow><mi>t</mi><mo>−</mo><mn>1</mn></mrow></msub><mo stretchy="false">)</mo></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mo>∫</mo><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mrow><mi>t</mi><mo>−</mo><mn>1</mn></mrow></msub><mo separator="true">,</mo><msub><mi>z</mi><mi>t</mi></msub><mo stretchy="false">)</mo><mi>d</mi><msub><mi>z</mi><mi>t</mi></msub><mo>=</mo><mo>∫</mo><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mrow><mi>t</mi><mo>−</mo><mn>1</mn></mrow></msub><mi mathvariant="normal">∣</mi><msub><mi>z</mi><mi>t</mi></msub><mo stretchy="false">)</mo><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mi>t</mi></msub><mo stretchy="false">)</mo><mi>d</mi><msub><mi>z</mi><mi>t</mi></msub></mrow></mstyle></mtd><mtd class="mtr-glue"></mtd><mtd class="mml-eqn-num"></mtd></mtr><mtr><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>…</mo></mrow></mstyle></mtd></mtr><mtr><mtd class="mtr-glue"></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mn>1</mn></msub><mo stretchy="false">)</mo></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mo>∫</mo><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mn>1</mn></msub><mo separator="true">,</mo><msub><mi>z</mi><mn>2</mn></msub><mo stretchy="false">)</mo><mi>d</mi><msub><mi>z</mi><mn>1</mn></msub><mo>=</mo><mo>∫</mo><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mn>1</mn></msub><mi mathvariant="normal">∣</mi><msub><mi>z</mi><mn>2</mn></msub><mo stretchy="false">)</mo><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mn>2</mn></msub><mo stretchy="false">)</mo><mi>d</mi><msub><mi>z</mi><mn>2</mn></msub></mrow></mstyle></mtd><mtd class="mtr-glue"></mtd><mtd class="mml-eqn-num"></mtd></mtr><mtr><mtd class="mtr-glue"></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mo>∫</mo><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo separator="true">,</mo><msub><mi>z</mi><mn>1</mn></msub><mo stretchy="false">)</mo><mi>d</mi><msub><mi>z</mi><mn>1</mn></msub><mo>=</mo><mo>∫</mo><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><msub><mi>z</mi><mn>1</mn></msub><mo stretchy="false">)</mo><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mn>1</mn></msub><mo stretchy="false">)</mo><mi>d</mi><msub><mi>z</mi><mn>1</mn></msub></mrow></mstyle></mtd><mtd class="mtr-glue"></mtd><mtd class="mml-eqn-num"></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{align}
4
+ q(z_{T-1}) &amp;= \int q(z_{T-1},z_T)dz_T = \int q(z_{T-1}|z_T)q(z_T)dz_T \tag{5.1} \newline
5
+ &amp; \dots \notag \newline
6
+ q(z_{t-1}) &amp;= \int q(z_{t-1},z_t)dz_t = \int q(z_{t-1}|z_t)q(z_t)dz_t \tag{5.2} \newline
7
+ &amp; \dots \notag \newline
8
+ q(z_1) &amp;= \int q(z_1,z_2) dz_1 = \int q(z_1|z_2)q(z_2)dz_2 \tag{5.3} \newline
9
+ q(x) &amp;= \int q(x,z_1) dz_1 = \int q(x|z_1)q(z_1)dz_1 \tag{5.4} \newline
10
+ \end{align}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 13.089em; vertical-align: -6.2945em;"></span><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 6.7945em;"><span class="" style="top: -8.7945em;"><span class="pstrut" style="height: 3.36em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span><span class="mbin mtight">−</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.2083em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span><span class="" style="top: -6.7923em;"><span class="pstrut" style="height: 3.36em;"></span><span class="mord"></span></span><span class="" style="top: -4.7722em;"><span class="pstrut" style="height: 3.36em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">t</span><span class="mbin mtight">−</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.2083em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span><span class="" style="top: -2.77em;"><span class="pstrut" style="height: 3.36em;"></span><span class="mord"></span></span><span class="" style="top: -0.75em;"><span class="pstrut" style="height: 3.36em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span><span class="" style="top: 1.7722em;"><span class="pstrut" style="height: 3.36em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 6.2945em;"><span class=""></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 6.7945em;"><span class="" style="top: -8.7945em;"><span class="pstrut" style="height: 3.36em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mop op-symbol large-op" style="margin-right: 0.4445em; position: relative; top: -0.0011em;">∫</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span><span class="mbin mtight">−</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.2083em;"><span class=""></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span><span class="mord mathnormal">d</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mop op-symbol large-op" style="margin-right: 0.4445em; position: relative; top: -0.0011em;">∫</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span><span class="mbin mtight">−</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.2083em;"><span class=""></span></span></span></span></span></span><span class="mord">∣</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span><span class="mord mathnormal">d</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span></span></span><span class="" style="top: -6.7923em;"><span class="pstrut" style="height: 3.36em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="minner">…</span></span></span><span class="" style="top: -4.7722em;"><span class="pstrut" style="height: 3.36em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mop op-symbol large-op" style="margin-right: 0.4445em; position: relative; top: -0.0011em;">∫</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">t</span><span class="mbin mtight">−</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.2083em;"><span class=""></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.2806em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">t</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span><span class="mord mathnormal">d</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.2806em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">t</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mop op-symbol large-op" style="margin-right: 0.4445em; position: relative; top: -0.0011em;">∫</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight">t</span><span class="mbin mtight">−</span><span class="mord mtight">1</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.2083em;"><span class=""></span></span></span></span></span></span><span class="mord">∣</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.2806em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">t</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.2806em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">t</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span><span class="mord mathnormal">d</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.2806em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight">t</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span></span></span><span class="" style="top: -2.77em;"><span class="pstrut" style="height: 3.36em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="minner">…</span></span></span><span class="" style="top: -0.75em;"><span class="pstrut" style="height: 3.36em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mop op-symbol large-op" style="margin-right: 0.4445em; position: relative; top: -0.0011em;">∫</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span><span class="mord mathnormal">d</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mop op-symbol large-op" style="margin-right: 0.4445em; position: relative; top: -0.0011em;">∫</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mord">∣</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span><span class="mord mathnormal">d</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span></span></span><span class="" style="top: 1.7722em;"><span class="pstrut" style="height: 3.36em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mop op-symbol large-op" style="margin-right: 0.4445em; position: relative; top: -0.0011em;">∫</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mpunct">,</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span><span class="mord mathnormal">d</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mop op-symbol large-op" style="margin-right: 0.4445em; position: relative; top: -0.0011em;">∫</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span><span class="mord mathnormal">d</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 6.2945em;"><span class=""></span></span></span></span></span></span></span><span class="tag"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 6.7945em;"><span class="" style="top: -8.7945em;"><span class="pstrut" style="height: 3.36em;"></span><span class=""><span class="mord text"><span class="mord">(</span><span class="mord"><span class="mord">5.1</span></span><span class="mord">)</span></span></span></span><span class="" style="top: -6.7923em;"><span class="pstrut" style="height: 3.36em;"></span><span class=""></span></span><span class="" style="top: -4.7722em;"><span class="pstrut" style="height: 3.36em;"></span><span class=""><span class="mord text"><span class="mord">(</span><span class="mord"><span class="mord">5.2</span></span><span class="mord">)</span></span></span></span><span class="" style="top: -2.77em;"><span class="pstrut" style="height: 3.36em;"></span><span class=""></span></span><span class="" style="top: -0.75em;"><span class="pstrut" style="height: 3.36em;"></span><span class=""><span class="mord text"><span class="mord">(</span><span class="mord"><span class="mord">5.3</span></span><span class="mord">)</span></span></span></span><span class="" style="top: 1.7722em;"><span class="pstrut" style="height: 3.36em;"></span><span class=""><span class="mord text"><span class="mord">(</span><span class="mord"><span class="mord">5.4</span></span><span class="mord">)</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 6.2945em;"><span class=""></span></span></span></span></span></span></span></span></span>
11
+ 在本文中,将上述恢复过程(式5.1~5.4)所使用的变换称之为“后验概率变换”。例如,在式5.4中,变换的输入为概率分布函数<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mn>1</mn></msub><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(z_1)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span></span></span>,输出为概率分布函数<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>,整个变换由后验概率分布<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><msub><mi>z</mi><mn>1</mn></msub><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z_1)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span></span></span>决定。此变换也可看作为一组基函数的线性加权和,基函数为不同条件下的<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><msub><mi>z</mi><mn>1</mn></msub><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z_1)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span></span></span>,各个基函数的权重为<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mn>1</mn></msub><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(z_1)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span></span></span>。在第7节,将会进一步介绍此变换的一些有趣性质。</p>
12
+ <p>在第3节中,我们考虑了两个特殊的后验概率分布。接下来,分析其对应的”后验概率变换“。</p>
13
+ <ul>
14
+ <li> 当<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi><mo>→</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">\alpha \to 0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">→</span><span class="mspace" style="margin-right: 0.2778em;"></span></span><span class="base"><span class="strut" style="height: 0.6444em;"></span><span class="mord">0</span></span></span></span></span>时,不同<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>z</mi></mrow><annotation encoding="application/x-tex">z</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span></span></span></span></span>值的<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span></span></span></span></span>均与<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>几乎相同,也就是说,线性加权和的基函数几乎相同。此状态下,不管输入如何变化,变换的输出总为<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>。</li>
15
+ <li> 当<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi><mo>→</mo><mn>1</mn></mrow><annotation encoding="application/x-tex">\alpha \to 1</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">→</span><span class="mspace" style="margin-right: 0.2778em;"></span></span><span class="base"><span class="strut" style="height: 0.6444em;"></span><span class="mord">1</span></span></span></span></span>时,不同<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>z</mi></mrow><annotation encoding="application/x-tex">z</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span></span></span></span></span>值的<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span></span></span></span></span>收缩成一系列不同偏移量的Dirac delta函数及零函数。此状态下,只要输入分布的支撑集(support set)包含于<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>的支撑集,变换的输出与输入将保持一致。</li>
16
+ </ul>
17
+
18
+ <p>在第5节中提到,DDPM<a href="#ddpm">[2]</a>论文所使用的1000次变换可使用一次变换表示:
19
+ <span><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right" columnspacing=""><mtr><mtd class="mtr-glue"></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><msub><mi>Z</mi><mi>T</mi></msub><mo>=</mo><msqrt><mn>0.0000403</mn></msqrt><mtext>&nbsp;</mtext><mi>X</mi><mo>+</mo><msqrt><mrow><mn>1</mn><mo>−</mo><mn>0.0000403</mn></mrow></msqrt><mtext>&nbsp;</mtext><mi>ϵ</mi><mo>=</mo><mn>0.00635</mn><mtext>&nbsp;</mtext><mi>X</mi><mo>+</mo><mn>0.99998</mn><mtext>&nbsp;</mtext><mi>ϵ</mi></mrow></mstyle></mtd><mtd class="mtr-glue"></mtd><mtd class="mml-eqn-num"></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{align}
20
+ Z_T = \sqrt{0.0000403}\ X + \sqrt{1-0.0000403}\ \epsilon = 0.00635\ X + 0.99998\ \epsilon \tag{5.5}
21
+ \end{align}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1.6161em; vertical-align: -0.558em;"></span><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.058em;"><span class="" style="top: -3.102em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0715em;">Z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.0715em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.9561em;"><span class="svg-align" style="top: -3em;"><span class="pstrut" style="height: 3em;"></span><span class="mord" style="padding-left: 0.833em;"><span class="mord">0.0000403</span></span></span><span class="" style="top: -2.9161em;"><span class="pstrut" style="height: 3em;"></span><span class="hide-tail" style="min-width: 0.853em; height: 1.08em;"><svg width="400em" height="1.08em" viewBox="0 0 400000 1080" preserveAspectRatio="xMinYMin slice"><path d="M95,702
22
+ c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
23
+ c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
24
+ c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
25
+ s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
26
+ c69,-144,104.5,-217.7,106.5,-221
27
+ l0 -0
28
+ c5.3,-9.3,12,-14,20,-14
29
+ H400000v40H845.2724
30
+ s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
31
+ c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
32
+ M834 80h400000v40h-400000z"></path></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.0839em;"><span class=""></span></span></span></span></span><span class="mspace">&nbsp;</span><span class="mord mathnormal" style="margin-right: 0.0785em;">X</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.9144em;"><span class="svg-align" style="top: -3em;"><span class="pstrut" style="height: 3em;"></span><span class="mord" style="padding-left: 0.833em;"><span class="mord">1</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mord">0.0000403</span></span></span><span class="" style="top: -2.8744em;"><span class="pstrut" style="height: 3em;"></span><span class="hide-tail" style="min-width: 0.853em; height: 1.08em;"><svg width="400em" height="1.08em" viewBox="0 0 400000 1080" preserveAspectRatio="xMinYMin slice"><path d="M95,702
33
+ c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
34
+ c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
35
+ c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
36
+ s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
37
+ c69,-144,104.5,-217.7,106.5,-221
38
+ l0 -0
39
+ c5.3,-9.3,12,-14,20,-14
40
+ H400000v40H845.2724
41
+ s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
42
+ c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
43
+ M834 80h400000v40h-400000z"></path></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.1256em;"><span class=""></span></span></span></span></span><span class="mspace">&nbsp;</span><span class="mord mathnormal">ϵ</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mord">0.00635</span><span class="mspace">&nbsp;</span><span class="mord mathnormal" style="margin-right: 0.0785em;">X</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mord">0.99998</span><span class="mspace">&nbsp;</span><span class="mord mathnormal">ϵ</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.558em;"><span class=""></span></span></span></span></span></span></span><span class="tag"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.058em;"><span class="" style="top: -3.102em;"><span class="pstrut" style="height: 3em;"></span><span class=""><span class="mord text"><span class="mord">(</span><span class="mord"><span class="mord">5.5</span></span><span class="mord">)</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.558em;"><span class=""></span></span></span></span></span></span></span></span></span>
44
+ 由于<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi><mo>=</mo><mn>0.0000403</mn></mrow><annotation encoding="application/x-tex">\alpha=0.0000403</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span></span><span class="base"><span class="strut" style="height: 0.6444em;"></span><span class="mord">0.0000403</span></span></span></span></span>非常小,其对应的GaussFun(式3.4)的标准差达到157.52,而<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>X</mi></mrow><annotation encoding="application/x-tex">X</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.6833em;"></span><span class="mord mathnormal" style="margin-right: 0.0785em;">X</span></span></span></span></span>的范围限制在<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mo stretchy="false">[</mo><mo>−</mo><mn>1</mn><mo separator="true">,</mo><mn>1</mn><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">[-1, 1]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mopen">[</span><span class="mord">−</span><span class="mord">1</span><span class="mpunct">,</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord">1</span><span class="mclose">]</span></span></span></span></span>,远小于GaussFun的标准差。在<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi><mo>∈</mo><mo stretchy="false">[</mo><mo>−</mo><mn>1</mn><mo separator="true">,</mo><mn>1</mn><mo stretchy="false">]</mo></mrow><annotation encoding="application/x-tex">x \in [-1, 1]</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.5782em; vertical-align: -0.0391em;"></span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">∈</span><span class="mspace" style="margin-right: 0.2778em;"></span></span><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mopen">[</span><span class="mord">−</span><span class="mord">1</span><span class="mpunct">,</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord">1</span><span class="mclose">]</span></span></span></span></span>范围内,GaussFun应该接近于常量,没有什么变化,所以不同的<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>z</mi><mi>T</mi></msub></mrow><annotation encoding="application/x-tex">z_T</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.5806em; vertical-align: -0.15em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span></span></span></span></span>对应的<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><msub><mi>z</mi><mi>T</mi></msub><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z_T)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span></span></span>均与<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>几乎相同。在这种状态下,对于<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><msub><mi>z</mi><mi>T</mi></msub><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z_T)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span></span></span>相应的后验概率变换,不管输入分布是什么,输出分布都将是<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>。</p>
45
+ <p><b>所以,理论上,在DDPM模型中,无需非得使用标准正态分布代替<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mi>T</mi></msub><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(z_T)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span></span></span>,也可使用其它任意的分布代替。</b>
46
+ </p>
47
+ </span></div></div></div>
Markdown/zh/deconvolution.html ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ <div id="md_deconvolution" class="block normal mds svelte-90oupt padded hide-container" style="border-style: solid; overflow: visible; min-width: min(0px, 100%); border-width: var(--block-border-width);"><div class="wrap center full svelte-1occ011 hide" style="position: absolute; padding: 0px;"></div> <div class="svelte-1ed2p3z"><div class="prose normal mds svelte-1yrv54" data-testid="markdown" dir="ltr"><span class="md svelte-1syupzx"><p>在第二节中提到,式2.1的变换可分为两个子变换,第一个子变换为”线性变换“,第二个为“加上独立高斯噪声”。线性变换相当于对概率分布进行拉伸变换,所以存在逆变换。"加上独立高斯噪声”相当于对概率分布执行卷积操作,卷积操作可通过逆卷积恢复。所以,理论上,可通过“逆线性变换”和“逆卷积”从最终的概率分布<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mi>T</mi></msub><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(z_T)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span></span></span>恢复数据分布<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>。</p>
2
+ <p>但实际上,会存在一些问题。由于逆卷积对误差极为敏感,具有很高的输入灵敏度,很小的输入噪声就会引起输出极大的变化<a href="#deconv_1">[11]</a><a href="#deconv_2">[12]</a>。而在扩散模型中,会使用标准正态分布近似代替<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><msub><mi>z</mi><mi>T</mi></msub><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(z_T)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.044em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mclose">)</span></span></span></span></span>,因此,在恢复的起始阶段就会引入噪声。虽然噪声较小,但由于逆卷积的敏感性,噪声会逐步放大,影响恢复。</p>
3
+ <p>另外,也可以从另一个角度理解“逆卷积恢复”的不可行性。由于前向变换的过程(式4.1~4.4)是确定的,所以卷积核是固定的,因此,相应的“逆卷积变换“也是固定的。由于起始的数据分布<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>可以是任意的分布,所以,通过一系列固定的“卷积正变换”,可以将任意的概率分布转换成近似<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="script">N</mi><mo stretchy="false">(</mo><mn>0</mn><mo separator="true">,</mo><mi>I</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\mathcal{N}(0,I)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathcal" style="margin-right: 0.1474em;">N</span><span class="mopen">(</span><span class="mord">0</span><span class="mpunct">,</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord mathnormal" style="margin-right: 0.0785em;">I</span><span class="mclose">)</span></span></span></span></span>的分布。如“逆卷积变换“可行,则意味着,可用一个固定的“逆卷积变换",将<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi mathvariant="script">N</mi><mo stretchy="false">(</mo><mn>0</mn><mo separator="true">,</mo><mi>I</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">\mathcal{N}(0,I)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathcal" style="margin-right: 0.1474em;">N</span><span class="mopen">(</span><span class="mord">0</span><span class="mpunct">,</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord mathnormal" style="margin-right: 0.0785em;">I</span><span class="mclose">)</span></span></span></span></span>分布恢复成任意的数据分布<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>,这明显是一个悖论。同一个输入,同一个变换,不可能会有多个输出。</p>
4
+ </span></div></div></div>
Markdown/zh/fit_posterior.html ADDED
The diff for this file is too large to render. See raw diff
 
Markdown/zh/forward_process.html ADDED
The diff for this file is too large to render. See raw diff
 
Markdown/zh/introduction.html ADDED
@@ -0,0 +1,6 @@
 
 
 
 
 
 
 
1
+ <div id="md_introduction" class="block normal mds svelte-90oupt padded hide-container" style="border-style: solid; overflow: visible; min-width: min(0px, 100%); border-width: var(--block-border-width);"><div class="wrap center full svelte-1occ011 hide" style="position: absolute; padding: 0px;"></div> <div class="svelte-1ed2p3z"><div class="prose normal mds svelte-1yrv54" data-testid="markdown" dir="ltr"><span class="md svelte-1syupzx"><p>扩散模型<a href="#dpm">[1]</a><a href="#ddpm">[2]</a>是当前图像生成和视频生成使用的主要方式,但由于其晦涩的理论,很多工程师并不能很好地理解。本文将提供一种非常直观易懂的方式,方便读者理解把握扩散模型的原理。特别地,将以互动的形式,以一维随机随机变量的扩散模型进行举例,直观解释扩散模型的多个有趣的性质。</p>
2
+ <p>扩散模型是一个概率模型。概率模型主要提供两方面的功能:计算给定样本出现的概率;采样生成新样本。扩散模型侧重于第二方面,方便采样新样本,从而实现"生成"的任务。</p>
3
+ <p>扩散模型与一般的概率模型(如GMM)不同,直接建模随机变量的概率分布。扩散模型采用一种间接方式,利用“随机变量变换”的方式(如图1a),逐步将待建模的概率分布(数据分布)转变成"标准正态分布",同时,建模学习各个变换对应的后验概率分布(图1b-c)。有了最终的标准正态分布和各个后验概率分布,则可通过祖先采样的方式,从反向逐步采样得到各个随机变量<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msub><mi>Z</mi><mi>T</mi></msub><mo>…</mo><msub><mi>Z</mi><mn>2</mn></msub><mo separator="true">,</mo><msub><mi>Z</mi><mn>1</mn></msub><mo separator="true">,</mo><mi>X</mi></mrow><annotation encoding="application/x-tex">Z_T \ldots Z_2,Z_1,X</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.8778em; vertical-align: -0.1944em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0715em;">Z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3283em;"><span class="" style="top: -2.55em; margin-left: -0.0715em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mathnormal mtight" style="margin-right: 0.1389em;">T</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="minner">…</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0715em;">Z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.0715em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0715em;">Z</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.3011em;"><span class="" style="top: -2.55em; margin-left: -0.0715em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.15em;"><span class=""></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord mathnormal" style="margin-right: 0.0785em;">X</span></span></span></span></span>的样本。同时也可通过贝叶斯公式和全概率公式确定初始的数据分布<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>。</p>
4
+ <p>可能会有这样的疑问:间接的方式需要建模学习T个后验概率分布,直接方式只需要建模学习一个概率分布,为什么要选择间接的方式呢?是这样子的:初始的数据分布可能很复杂,很难用一个概率模型直接表示;而对于间接的方式,各个后验概率分布的复杂度会简单许多,可以用简单的概率模型进行拟合。下面将会看到,当满足一些条件时,后验概率分布将非常接近高斯分布,所以可以使用简单的条件高斯模型进行建模。</p>
5
+ <center> <img style="margin-top:12px" width="820" src="file/pipe.jpg"> </center>
6
+ <center> Figure 1: Diffusion model schematic </center></span></div></div></div>
Markdown/zh/likelihood.html ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div id="md_likelihood" class="block normal mds svelte-90oupt padded hide-container" style="border-style: solid; overflow: visible; min-width: min(0px, 100%); border-width: var(--block-border-width);"><div class="wrap center full svelte-1occ011 hide" style="position: absolute; padding: 0px;"></div> <div class="svelte-1ed2p3z"><div class="prose normal mds svelte-1yrv54" data-testid="markdown" dir="ltr"><span class="md svelte-1syupzx"><p>由变换的方式(式1.1)可以看出,前向条件概率<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>z</mi><mi mathvariant="normal">∣</mi><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(z|x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mord">∣</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>的概率分布为高斯分布,且只与<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi></mrow><annotation encoding="application/x-tex">\alpha</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span></span></span>的值有关,与<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>的概率分布无关。
2
+ <span><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right left" columnspacing="0em"><mtr><mtd class="mtr-glue"></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>z</mi><mi mathvariant="normal">∣</mi><mi>x</mi><mo stretchy="false">)</mo></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mi mathvariant="script">N</mi><mo stretchy="false">(</mo><msqrt><mi>α</mi></msqrt><mi>x</mi><mo separator="true">,</mo><mtext>&nbsp;</mtext><mn>1</mn><mo>−</mo><mi>α</mi><mo stretchy="false">)</mo></mrow></mstyle></mtd><mtd class="mtr-glue"></mtd><mtd class="mml-eqn-num"></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{align}
3
+ q(z|x) &amp;= \mathcal{N}(\sqrt{\alpha}x,\ 1-\alpha) \tag{2.1}
4
+ \end{align}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1.5092em; vertical-align: -0.5046em;"></span><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.0046em;"><span class="" style="top: -3.1554em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mord">∣</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.5046em;"><span class=""></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.0046em;"><span class="" style="top: -3.1554em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mord mathcal" style="margin-right: 0.1474em;">N</span><span class="mopen">(</span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.8492em;"><span class="svg-align" style="top: -3em;"><span class="pstrut" style="height: 3em;"></span><span class="mord" style="padding-left: 0.833em;"><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span><span class="" style="top: -2.8092em;"><span class="pstrut" style="height: 3em;"></span><span class="hide-tail" style="min-width: 0.853em; height: 1.08em;"><svg width="400em" height="1.08em" viewBox="0 0 400000 1080" preserveAspectRatio="xMinYMin slice"><path d="M95,702
5
+ c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
6
+ c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
7
+ c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
8
+ s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
9
+ c69,-144,104.5,-217.7,106.5,-221
10
+ l0 -0
11
+ c5.3,-9.3,12,-14,20,-14
12
+ H400000v40H845.2724
13
+ s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
14
+ c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
15
+ M834 80h400000v40h-400000z"></path></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.1908em;"><span class=""></span></span></span></span></span><span class="mord mathnormal">x</span><span class="mpunct">,</span><span class="mspace">&nbsp;</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord">1</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span><span class="mclose">)</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.5046em;"><span class=""></span></span></span></span></span></span></span><span class="tag"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.0046em;"><span class="" style="top: -3.1554em;"><span class="pstrut" style="height: 3em;"></span><span class=""><span class="mord text"><span class="mord">(</span><span class="mord"><span class="mord">2.1</span></span><span class="mord">)</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.5046em;"><span class=""></span></span></span></span></span></span></span></span></span>
16
+ 具体可看Demo 2,左3图展示了<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>z</mi><mi mathvariant="normal">∣</mi><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(z|x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mord">∣</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>的形状,从图中可以看到一条均匀的斜线,这意味着<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>z</mi><mi mathvariant="normal">∣</mi><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(z|x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mord">∣</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>的均值与x线性相关,方差固定不变。<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi></mrow><annotation encoding="application/x-tex">\alpha</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span></span></span>值的大小将决定斜线宽度和倾斜程度。</p>
17
+ </span></div></div></div>
Markdown/zh/posterior.html ADDED
@@ -0,0 +1,120 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div id="md_posterior" class="block normal mds svelte-90oupt padded hide-container" style="border-style: solid; overflow: visible; min-width: min(0px, 100%); border-width: var(--block-border-width);"><div class="wrap center full svelte-1occ011 hide" style="position: absolute; padding: 0px;"></div> <div class="svelte-1ed2p3z"><div class="prose normal mds svelte-1yrv54" data-testid="markdown" dir="ltr"><span class="md svelte-1syupzx"><p>后验概率分布没有闭合的形式,但可以通过一些方法,推断其大概的形状,并分析影响其形状的因素。</p>
2
+ <p>根据Bayes公式,有
3
+ <span><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right" columnspacing=""><mtr><mtd class="mtr-glue"></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo><mo>=</mo><mfrac><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>z</mi><mi mathvariant="normal">∣</mi><mi>x</mi><mo stretchy="false">)</mo><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>z</mi><mo stretchy="false">)</mo></mrow></mfrac></mrow></mstyle></mtd><mtd class="mtr-glue"></mtd><mtd class="mml-eqn-num"></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{align}
4
+ q(x|z) = \frac{q(z|x)q(x)}{q(z)} \tag{3.1}
5
+ \end{align}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 2.663em; vertical-align: -1.0815em;"></span><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.5815em;"><span class="" style="top: -3.5815em;"><span class="pstrut" style="height: 3.427em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.427em;"><span class="" style="top: -2.314em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span></span></span><span class="" style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span class="" style="top: -3.677em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mord">∣</span><span class="mord mathnormal">x</span><span class="mclose">)</span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.936em;"><span class=""></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 1.0815em;"><span class=""></span></span></span></span></span></span></span><span class="tag"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.5815em;"><span class="" style="top: -3.5815em;"><span class="pstrut" style="height: 3.427em;"></span><span class=""><span class="mord text"><span class="mord">(</span><span class="mord"><span class="mord">3.1</span></span><span class="mord">)</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 1.0815em;"><span class=""></span></span></span></span></span></span></span></span></span></p>
6
+ <p>当<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>z</mi></mrow><annotation encoding="application/x-tex">z</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span></span></span></span></span>是取固定值时,<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>z</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span></span></span></span></span>是常数,所以<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span></span></span></span></span>的形状只与<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>z</mi><mi mathvariant="normal">∣</mi><mi>x</mi><mo stretchy="false">)</mo><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">{q(z|x)q(x)}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mord">∣</span><span class="mord mathnormal">x</span><span class="mclose">)</span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span></span>有关。
7
+ <span><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right" columnspacing=""><mtr><mtd class="mtr-glue"></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo><mo>∝</mo><mi>q</mi><mo stretchy="false">(</mo><mi>z</mi><mi mathvariant="normal">∣</mi><mi>x</mi><mo stretchy="false">)</mo><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo><mspace width="2em"></mspace><mi>w</mi><mi>h</mi><mi>e</mi><mi>r</mi><mi>e</mi><mtext>&nbsp;</mtext><mi>z</mi><mtext>&nbsp;</mtext><mi>i</mi><mi>s</mi><mtext>&nbsp;</mtext><mi>f</mi><mi>i</mi><mi>x</mi><mi>e</mi><mi>d</mi></mrow></mstyle></mtd><mtd class="mtr-glue"></mtd><mtd class="mml-eqn-num"></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{align}
8
+ q(x|z) \propto q(z|x)q(x) \qquad where\ z\ is\ fixed \tag{3.2}
9
+ \end{align}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1.5em; vertical-align: -0.5em;"></span><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1em;"><span class="" style="top: -3.16em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">∝</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mord">∣</span><span class="mord mathnormal">x</span><span class="mclose">)</span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span><span class="mspace" style="margin-right: 2em;"></span><span class="mord mathnormal" style="margin-right: 0.0269em;">w</span><span class="mord mathnormal">h</span><span class="mord mathnormal">ere</span><span class="mspace">&nbsp;</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mspace">&nbsp;</span><span class="mord mathnormal">i</span><span class="mord mathnormal">s</span><span class="mspace">&nbsp;</span><span class="mord mathnormal" style="margin-right: 0.1076em;">f</span><span class="mord mathnormal">i</span><span class="mord mathnormal">x</span><span class="mord mathnormal">e</span><span class="mord mathnormal">d</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.5em;"><span class=""></span></span></span></span></span></span></span><span class="tag"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1em;"><span class="" style="top: -3.16em;"><span class="pstrut" style="height: 3em;"></span><span class=""><span class="mord text"><span class="mord">(</span><span class="mord"><span class="mord">3.2</span></span><span class="mord">)</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.5em;"><span class=""></span></span></span></span></span></span></span></span></span>
10
+ 由式2.1可知,<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>z</mi><mi mathvariant="normal">∣</mi><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(z|x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mord">∣</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>为高斯分布,于是有
11
+ <span><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right left right left" columnspacing="0em 1em 0em"><mtr><mtd class="mtr-glue"></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>∝</mo><mfrac><mn>1</mn><msqrt><mrow><mn>2</mn><mi>π</mi><mo stretchy="false">(</mo><mn>1</mn><mo>−</mo><mi>α</mi><mo stretchy="false">)</mo></mrow></msqrt></mfrac><mi>exp</mi><mo>⁡</mo><mfrac><mrow><mo>−</mo><mo stretchy="false">(</mo><mi>z</mi><mo>−</mo><msqrt><mi>α</mi></msqrt><mi>x</mi><msup><mo stretchy="false">)</mo><mn>2</mn></msup></mrow><mrow><mn>2</mn><mo stretchy="false">(</mo><mn>1</mn><mo>−</mo><mi>α</mi><mo stretchy="false">)</mo></mrow></mfrac><mtext>&nbsp;</mtext><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mspace width="2em"></mspace></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>w</mi><mi>h</mi><mi>e</mi><mi>r</mi><mi>e</mi><mtext>&nbsp;</mtext><mi>z</mi><mtext>&nbsp;</mtext><mi>i</mi><mi>s</mi><mtext>&nbsp;</mtext><mi>f</mi><mi>i</mi><mi>x</mi><mi>e</mi><mi>d</mi></mrow></mstyle></mtd><mtd class="mtr-glue"></mtd><mtd class="mml-eqn-num"></mtd></mtr><mtr><mtd class="mtr-glue"></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mo>=</mo><mfrac><mn>1</mn><msqrt><mi>α</mi></msqrt></mfrac><munder><munder><mrow><mfrac><mn>1</mn><mrow><msqrt><mrow><mn>2</mn><mi>π</mi></mrow></msqrt><mi>σ</mi></mrow></mfrac><mi>exp</mi><mo>⁡</mo><mfrac><mrow><mo>−</mo><mo stretchy="false">(</mo><mi>x</mi><mo>−</mo><mi>μ</mi><msup><mo stretchy="false">)</mo><mn>2</mn></msup></mrow><mrow><mn>2</mn><msup><mi>σ</mi><mn>2</mn></msup></mrow></mfrac></mrow><mo stretchy="true">⏟</mo></munder><mtext>GaussFun</mtext></munder><mtext>&nbsp;</mtext><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mspace width="2em"></mspace></mstyle></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mrow></mrow><mi>w</mi><mi>h</mi><mi>e</mi><mi>r</mi><mi>e</mi><mtext>&nbsp;</mtext><mi>μ</mi><mo>=</mo><mfrac><mi>z</mi><msqrt><mi>α</mi></msqrt></mfrac><mspace width="1em"></mspace><mi>σ</mi><mo>=</mo><msqrt><mfrac><mrow><mn>1</mn><mo>−</mo><mi>α</mi></mrow><mi>α</mi></mfrac></msqrt></mrow></mstyle></mtd><mtd class="mtr-glue"></mtd><mtd class="mml-eqn-num"></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{align}
12
+ q(x|z) &amp;\propto \frac{1}{\sqrt{2\pi(1-\alpha)}}\exp{\frac{-(z-\sqrt{\alpha}x)^2}{2(1-\alpha)}}\ q(x)&amp; \qquad &amp;where\ z\ is\ fixed \tag{3.3} \newline
13
+ &amp;= \frac{1}{\sqrt{\alpha}} \underbrace{\frac{1}{\sqrt{2\pi}\sigma}\exp{\frac{-(x-\mu)^2}{2\sigma^2}}}_{\text{GaussFun}}\ q(x)&amp; \qquad &amp;where\ \mu=\frac{z}{\sqrt{\alpha}}\quad \sigma=\sqrt{\frac{1-\alpha}{\alpha}} \tag{3.4}
14
+ \end{align}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 7.129em; vertical-align: -3.3145em;"></span><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 3.8145em;"><span class="" style="top: -5.975em;"><span class="pstrut" style="height: 3.6516em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span></span></span><span class="" style="top: -2.8934em;"><span class="pstrut" style="height: 3.6516em;"></span><span class="mord"></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 3.3145em;"><span class=""></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 3.8145em;"><span class="" style="top: -5.975em;"><span class="pstrut" style="height: 3.6516em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">∝</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.3214em;"><span class="" style="top: -2.175em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.935em;"><span class="svg-align" style="top: -3.2em;"><span class="pstrut" style="height: 3.2em;"></span><span class="mord" style="padding-left: 1em;"><span class="mord">2</span><span class="mord mathnormal" style="margin-right: 0.0359em;">π</span><span class="mopen">(</span><span class="mord">1</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span><span class="mclose">)</span></span></span><span class="" style="top: -2.895em;"><span class="pstrut" style="height: 3.2em;"></span><span class="hide-tail" style="min-width: 1.02em; height: 1.28em;"><svg width="400em" height="1.28em" viewBox="0 0 400000 1296" preserveAspectRatio="xMinYMin slice"><path d="M263,681c0.7,0,18,39.7,52,119
15
+ c34,79.3,68.167,158.7,102.5,238c34.3,79.3,51.8,119.3,52.5,120
16
+ c340,-704.7,510.7,-1060.3,512,-1067
17
+ l0 -0
18
+ c4.7,-7.3,11,-11,19,-11
19
+ H40000v40H1012.3
20
+ s-271.3,567,-271.3,567c-38.7,80.7,-84,175,-136,283c-52,108,-89.167,185.3,-111.5,232
21
+ c-22.3,46.7,-33.8,70.3,-34.5,71c-4.7,4.7,-12.3,7,-23,7s-12,-1,-12,-1
22
+ s-109,-253,-109,-253c-72.7,-168,-109.3,-252,-110,-252c-10.7,8,-22,16.7,-34,26
23
+ c-22,17.3,-33.3,26,-34,26s-26,-26,-26,-26s76,-59,76,-59s76,-60,76,-60z
24
+ M1001 80h400000v40h-400000z"></path></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.305em;"><span class=""></span></span></span></span></span></span></span><span class="" style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span class="" style="top: -3.677em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 1.13em;"><span class=""></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mop">exp</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord"><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.4911em;"><span class="" style="top: -2.314em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">2</span><span class="mopen">(</span><span class="mord">1</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span><span class="mclose">)</span></span></span><span class="" style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span class="" style="top: -3.677em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">−</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.8003em;"><span class="svg-align" style="top: -3em;"><span class="pstrut" style="height: 3em;"></span><span class="mord" style="padding-left: 0.833em;"><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span><span class="" style="top: -2.7603em;"><span class="pstrut" style="height: 3em;"></span><span class="hide-tail" style="min-width: 0.853em; height: 1.08em;"><svg width="400em" height="1.08em" viewBox="0 0 400000 1080" preserveAspectRatio="xMinYMin slice"><path d="M95,702
25
+ c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
26
+ c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
27
+ c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
28
+ s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
29
+ c69,-144,104.5,-217.7,106.5,-221
30
+ l0 -0
31
+ c5.3,-9.3,12,-14,20,-14
32
+ H400000v40H845.2724
33
+ s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
34
+ c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
35
+ M834 80h400000v40h-400000z"></path></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.2397em;"><span class=""></span></span></span></span></span><span class="mord mathnormal">x</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height: 0.8141em;"><span class="" style="top: -3.063em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.936em;"><span class=""></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span><span class="mspace">&nbsp;</span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span><span class="" style="top: -2.8934em;"><span class="pstrut" style="height: 3.6516em;"></span><span class="mord"><span class="mord"></span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.3214em;"><span class="" style="top: -2.3097em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.8003em;"><span class="svg-align" style="top: -3em;"><span class="pstrut" style="height: 3em;"></span><span class="mord" style="padding-left: 0.833em;"><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span><span class="" style="top: -2.7603em;"><span class="pstrut" style="height: 3em;"></span><span class="hide-tail" style="min-width: 0.853em; height: 1.08em;"><svg width="400em" height="1.08em" viewBox="0 0 400000 1080" preserveAspectRatio="xMinYMin slice"><path d="M95,702
36
+ c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
37
+ c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
38
+ c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
39
+ s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
40
+ c69,-144,104.5,-217.7,106.5,-221
41
+ l0 -0
42
+ c5.3,-9.3,12,-14,20,-14
43
+ H400000v40H845.2724
44
+ s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
45
+ c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
46
+ M834 80h400000v40h-400000z"></path></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.2397em;"><span class=""></span></span></span></span></span></span></span><span class="" style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span class="" style="top: -3.677em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.93em;"><span class=""></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mord munder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.4911em;"><span class="" style="top: -1.2348em;"><span class="pstrut" style="height: 3.4911em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord text mtight"><span class="mord mtight">GaussFun</span></span></span></span></span><span class="" style="top: -3.4911em;"><span class="pstrut" style="height: 3.4911em;"></span><span class="mord munder"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.4911em;"><span class="svg-align" style="top: -1.9131em;"><span class="pstrut" style="height: 3.4911em;"></span><span class="stretchy" style="height: 0.548em; min-width: 1.6em;"><span class="brace-left" style="height: 0.548em;"><svg width="400em" height="0.548em" viewBox="0 0 400000 548" preserveAspectRatio="xMinYMin slice"><path d="M0 6l6-6h17c12.688 0 19.313.3 20 1 4 4 7.313 8.3 10 13
47
+ 35.313 51.3 80.813 93.8 136.5 127.5 55.688 33.7 117.188 55.8 184.5 66.5.688
48
+ 0 2 .3 4 1 18.688 2.7 76 4.3 172 5h399450v120H429l-6-1c-124.688-8-235-61.7
49
+ -331-161C60.687 138.7 32.312 99.3 7 54L0 41V6z"></path></svg></span><span class="brace-center" style="height: 0.548em;"><svg width="400em" height="0.548em" viewBox="0 0 400000 548" preserveAspectRatio="xMidYMin slice"><path d="M199572 214
50
+ c100.7 8.3 195.3 44 280 108 55.3 42 101.7 93 139 153l9 14c2.7-4 5.7-8.7 9-14
51
+ 53.3-86.7 123.7-153 211-199 66.7-36 137.3-56.3 212-62h199568v120H200432c-178.3
52
+ 11.7-311.7 78.3-403 201-6 8-9.7 12-11 12-.7.7-6.7 1-18 1s-17.3-.3-18-1c-1.3 0
53
+ -5-4-11-12-44.7-59.3-101.3-106.3-170-141s-145.3-54.3-229-60H0V214z"></path></svg></span><span class="brace-right" style="height: 0.548em;"><svg width="400em" height="0.548em" viewBox="0 0 400000 548" preserveAspectRatio="xMaxYMin slice"><path d="M399994 0l6 6v35l-6 11c-56 104-135.3 181.3-238 232-57.3
54
+ 28.7-117 45-179 50H-300V214h399897c43.3-7 81-15 113-26 100.7-33 179.7-91 237
55
+ -174 2.7-5 6-9 10-13 .7-1 7.3-1 20-1h17z"></path></svg></span></span></span><span class="" style="top: -3.4911em;"><span class="pstrut" style="height: 3.4911em;"></span><span class="mord"><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.3214em;"><span class="" style="top: -2.2028em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.9072em;"><span class="svg-align" style="top: -3em;"><span class="pstrut" style="height: 3em;"></span><span class="mord" style="padding-left: 0.833em;"><span class="mord">2</span><span class="mord mathnormal" style="margin-right: 0.0359em;">π</span></span></span><span class="" style="top: -2.8672em;"><span class="pstrut" style="height: 3em;"></span><span class="hide-tail" style="min-width: 0.853em; height: 1.08em;"><svg width="400em" height="1.08em" viewBox="0 0 400000 1080" preserveAspectRatio="xMinYMin slice"><path d="M95,702
56
+ c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
57
+ c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
58
+ c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
59
+ s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
60
+ c69,-144,104.5,-217.7,106.5,-221
61
+ l0 -0
62
+ c5.3,-9.3,12,-14,20,-14
63
+ H400000v40H845.2724
64
+ s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
65
+ c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
66
+ M834 80h400000v40h-400000z"></path></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.1328em;"><span class=""></span></span></span></span></span><span class="mord mathnormal" style="margin-right: 0.0359em;">σ</span></span></span><span class="" style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span class="" style="top: -3.677em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">1</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.93em;"><span class=""></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mop">exp</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord"><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.4911em;"><span class="" style="top: -2.314em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">2</span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0359em;">σ</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height: 0.7401em;"><span class="" style="top: -2.989em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span><span class="" style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span class="" style="top: -3.677em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">−</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mord mathnormal">μ</span><span class="mclose"><span class="mclose">)</span><span class="msupsub"><span class="vlist-t"><span class="vlist-r"><span class="vlist" style="height: 0.8141em;"><span class="" style="top: -3.063em; margin-right: 0.05em;"><span class="pstrut" style="height: 2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">2</span></span></span></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.686em;"><span class=""></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 1.578em;"><span class=""></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 2.2563em;"><span class=""></span></span></span></span></span><span class="mspace">&nbsp;</span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 3.3145em;"><span class=""></span></span></span></span></span><span class="arraycolsep" style="width: 1em;"></span><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 3.8145em;"><span class="" style="top: -5.975em;"><span class="pstrut" style="height: 3.6516em;"></span><span class="mord"><span class="mspace" style="margin-right: 2em;"></span></span></span><span class="" style="top: -2.8934em;"><span class="pstrut" style="height: 3.6516em;"></span><span class="mord"><span class="mspace" style="margin-right: 2em;"></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 3.3145em;"><span class=""></span></span></span></span></span><span class="col-align-l"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 3.8145em;"><span class="" style="top: -5.975em;"><span class="pstrut" style="height: 3.6516em;"></span><span class="mord"><span class="mord"></span><span class="mord mathnormal" style="margin-right: 0.0269em;">w</span><span class="mord mathnormal">h</span><span class="mord mathnormal">ere</span><span class="mspace">&nbsp;</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mspace">&nbsp;</span><span class="mord mathnormal">i</span><span class="mord mathnormal">s</span><span class="mspace">&nbsp;</span><span class="mord mathnormal" style="margin-right: 0.1076em;">f</span><span class="mord mathnormal">i</span><span class="mord mathnormal">x</span><span class="mord mathnormal">e</span><span class="mord mathnormal">d</span></span></span><span class="" style="top: -2.8934em;"><span class="pstrut" style="height: 3.6516em;"></span><span class="mord"><span class="mord"></span><span class="mord mathnormal" style="margin-right: 0.0269em;">w</span><span class="mord mathnormal">h</span><span class="mord mathnormal">ere</span><span class="mspace">&nbsp;</span><span class="mord mathnormal">μ</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.1076em;"><span class="" style="top: -2.3097em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.8003em;"><span class="svg-align" style="top: -3em;"><span class="pstrut" style="height: 3em;"></span><span class="mord" style="padding-left: 0.833em;"><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span><span class="" style="top: -2.7603em;"><span class="pstrut" style="height: 3em;"></span><span class="hide-tail" style="min-width: 0.853em; height: 1.08em;"><svg width="400em" height="1.08em" viewBox="0 0 400000 1080" preserveAspectRatio="xMinYMin slice"><path d="M95,702
67
+ c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
68
+ c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
69
+ c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
70
+ s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
71
+ c69,-144,104.5,-217.7,106.5,-221
72
+ l0 -0
73
+ c5.3,-9.3,12,-14,20,-14
74
+ H400000v40H845.2724
75
+ s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
76
+ c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
77
+ M834 80h400000v40h-400000z"></path></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.2397em;"><span class=""></span></span></span></span></span></span></span><span class="" style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span class="" style="top: -3.677em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.044em;">z</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.93em;"><span class=""></span></span></span></span></span><span class="mclose nulldelimiter"></span></span><span class="mspace" style="margin-right: 1em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">σ</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.6516em;"><span class="svg-align" style="top: -4.4em;"><span class="pstrut" style="height: 4.4em;"></span><span class="mord" style="padding-left: 1em;"><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.3214em;"><span class="" style="top: -2.314em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span><span class="" style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span class="" style="top: -3.677em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord">1</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.686em;"><span class=""></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span><span class="" style="top: -3.6116em;"><span class="pstrut" style="height: 4.4em;"></span><span class="hide-tail" style="min-width: 1.02em; height: 2.48em;"><svg width="400em" height="2.48em" viewBox="0 0 400000 2592" preserveAspectRatio="xMinYMin slice"><path d="M424,2478
78
+ c-1.3,-0.7,-38.5,-172,-111.5,-514c-73,-342,-109.8,-513.3,-110.5,-514
79
+ c0,-2,-10.7,14.3,-32,49c-4.7,7.3,-9.8,15.7,-15.5,25c-5.7,9.3,-9.8,16,-12.5,20
80
+ s-5,7,-5,7c-4,-3.3,-8.3,-7.7,-13,-13s-13,-13,-13,-13s76,-122,76,-122s77,-121,77,-121
81
+ s209,968,209,968c0,-2,84.7,-361.7,254,-1079c169.3,-717.3,254.7,-1077.7,256,-1081
82
+ l0 -0c4,-6.7,10,-10,18,-10 H400000
83
+ v40H1014.6
84
+ s-87.3,378.7,-272.6,1166c-185.3,787.3,-279.3,1182.3,-282,1185
85
+ c-2,6,-10,9,-24,9
86
+ c-8,0,-12,-0.7,-12,-2z M1001 80
87
+ h400000v40h-400000z"></path></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.7884em;"><span class=""></span></span></span></span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 3.3145em;"><span class=""></span></span></span></span></span></span></span><span class="tag"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 3.8145em;"><span class="" style="top: -5.975em;"><span class="pstrut" style="height: 3.6516em;"></span><span class=""><span class="mord text"><span class="mord">(</span><span class="mord"><span class="mord">3.3</span></span><span class="mord">)</span></span></span></span><span class="" style="top: -2.8934em;"><span class="pstrut" style="height: 3.6516em;"></span><span class=""><span class="mord text"><span class="mord">(</span><span class="mord"><span class="mord">3.4</span></span><span class="mord">)</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 3.3145em;"><span class=""></span></span></span></span></span></span></span></span></span></p>
88
+ <p>可以看出,<b>GaussFun</b>部分是关于<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>x</mi></mrow><annotation encoding="application/x-tex">x</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal">x</span></span></span></span></span>的高斯函数,均值为<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mfrac><mi>z</mi><msqrt><mi>α</mi></msqrt></mfrac></mrow><annotation encoding="application/x-tex">\frac{z}{\sqrt{\alpha}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1.2334em; vertical-align: -0.538em;"></span><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.6954em;"><span class="" style="top: -2.6259em;"><span class="pstrut" style="height: 3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord sqrt mtight"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.8059em;"><span class="svg-align" style="top: -3em;"><span class="pstrut" style="height: 3em;"></span><span class="mord mtight" style="padding-left: 0.833em;"><span class="mord mathnormal mtight" style="margin-right: 0.0037em;">α</span></span></span><span class="" style="top: -2.7659em;"><span class="pstrut" style="height: 3em;"></span><span class="hide-tail mtight" style="min-width: 0.853em; height: 1.08em;"><svg width="400em" height="1.08em" viewBox="0 0 400000 1080" preserveAspectRatio="xMinYMin slice"><path d="M95,702
89
+ c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
90
+ c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
91
+ c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
92
+ s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
93
+ c69,-144,104.5,-217.7,106.5,-221
94
+ l0 -0
95
+ c5.3,-9.3,12,-14,20,-14
96
+ H400000v40H845.2724
97
+ s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
98
+ c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
99
+ M834 80h400000v40h-400000z"></path></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.2341em;"><span class=""></span></span></span></span></span></span></span></span><span class="" style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span class="" style="top: -3.394em;"><span class="pstrut" style="height: 3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right: 0.044em;">z</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.538em;"><span class=""></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span></span></span>,方差为<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msqrt><mfrac><mrow><mn>1</mn><mo>−</mo><mi>α</mi></mrow><mi>α</mi></mfrac></msqrt></mrow><annotation encoding="application/x-tex">\sqrt{\frac{1-\alpha}{\alpha}}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1.84em; vertical-align: -0.6049em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.2351em;"><span class="svg-align" style="top: -3.8em;"><span class="pstrut" style="height: 3.8em;"></span><span class="mord" style="padding-left: 1em;"><span class="mord"><span class="mopen nulldelimiter"></span><span class="mfrac"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.8451em;"><span class="" style="top: -2.655em;"><span class="pstrut" style="height: 3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mathnormal mtight" style="margin-right: 0.0037em;">α</span></span></span></span><span class="" style="top: -3.23em;"><span class="pstrut" style="height: 3em;"></span><span class="frac-line" style="border-bottom-width: 0.04em;"></span></span><span class="" style="top: -3.394em;"><span class="pstrut" style="height: 3em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight"><span class="mord mtight">1</span><span class="mbin mtight">−</span><span class="mord mathnormal mtight" style="margin-right: 0.0037em;">α</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.345em;"><span class=""></span></span></span></span></span><span class="mclose nulldelimiter"></span></span></span></span><span class="" style="top: -3.1951em;"><span class="pstrut" style="height: 3.8em;"></span><span class="hide-tail" style="min-width: 1.02em; height: 1.88em;"><svg width="400em" height="1.88em" viewBox="0 0 400000 1944" preserveAspectRatio="xMinYMin slice"><path d="M983 90
100
+ l0 -0
101
+ c4,-6.7,10,-10,18,-10 H400000v40
102
+ H1013.1s-83.4,268,-264.1,840c-180.7,572,-277,876.3,-289,913c-4.7,4.7,-12.7,7,-24,7
103
+ s-12,0,-12,0c-1.3,-3.3,-3.7,-11.7,-7,-25c-35.3,-125.3,-106.7,-373.3,-214,-744
104
+ c-10,12,-21,25,-33,39s-32,39,-32,39c-6,-5.3,-15,-14,-27,-26s25,-30,25,-30
105
+ c26.7,-32.7,52,-63,76,-91s52,-60,52,-60s208,722,208,722
106
+ c56,-175.3,126.3,-397.3,211,-666c84.7,-268.7,153.8,-488.2,207.5,-658.5
107
+ c53.7,-170.3,84.5,-266.8,92.5,-289.5z
108
+ M1001 80h400000v40h-400000z"></path></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.6049em;"><span class=""></span></span></span></span></span></span></span></span></span>,所以<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span></span></span></span></span>的形状由“<b>GaussFun与<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>相乘</b>”决定。</p>
109
+ <p>根据”乘法“的特点,可以总结<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span></span></span></span></span>函数形状具有的特点。</p>
110
+ <ul>
111
+ <li> 当高斯函数的方差较小(较小噪声),或者<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>变化缓慢时,<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span></span></span></span></span>的形状将近似于高斯函数,函数形式较简单,方便建模学习。</li>
112
+ <li> 当高斯函数的方差较大(较大噪声),或者<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>剧烈变化时,<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span></span></span></span></span>的形状将较复杂,与高斯函数有较大的差别,难以建模学习。</li>
113
+ </ul>
114
+
115
+ <p>具体可看Demo 2,左4图给出后验概率分布<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span></span></span></span></span>的形态,可以看出,其形状较不规则,像一条弯曲且不均匀的曲线。当<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi></mrow><annotation encoding="application/x-tex">\alpha</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span></span></span>较大时(噪声较小),曲线将趋向于均匀且笔直。读者可调整不同的<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi></mrow><annotation encoding="application/x-tex">\alpha</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span></span></span>值,观察后验概率分布与噪声大小的关系;左5图,<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="blue"><mtext>蓝色虚线</mtext></mstyle></mrow><annotation encoding="application/x-tex">\textcolor{blue}{蓝色虚线}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.6833em;"></span><span class="mord cjk_fallback" style="color: blue;">蓝色虚线</span></span></span></span></span>给出<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>,<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="green"><mtext>绿色虚线</mtext></mstyle></mrow><annotation encoding="application/x-tex">\textcolor{green}{绿色虚线}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.6833em;"></span><span class="mord cjk_fallback" style="color: green;">绿色虚线</span></span></span></span></span>给出式3.4中的GaussFun,<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mstyle mathcolor="orange"><mtext>黄色实线</mtext></mstyle></mrow><annotation encoding="application/x-tex">\textcolor{orange}{黄色实线}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.6833em;"></span><span class="mord cjk_fallback" style="color: orange;">黄色实线</span></span></span></span></span>给出两者相乘并归一化的结果,即固定z条件下后验概率<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo>=</mo><mi>f</mi><mi>i</mi><mi>x</mi><mi>e</mi><mi>d</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z=fixed)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span></span><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.1076em;">f</span><span class="mord mathnormal">i</span><span class="mord mathnormal">x</span><span class="mord mathnormal">e</span><span class="mord mathnormal">d</span><span class="mclose">)</span></span></span></span></span>。读者可调整不同z值,观察<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>的波动变化对后验概率<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span></span></span></span></span>形态的影响。</p>
116
+ <p>两个特殊状态下的后验概率分布<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span></span></span></span></span>值得考虑一下。</p>
117
+ <ul>
118
+ <li> 当<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi><mo>→</mo><mn>0</mn></mrow><annotation encoding="application/x-tex">\alpha \to 0</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">→</span><span class="mspace" style="margin-right: 0.2778em;"></span></span><span class="base"><span class="strut" style="height: 0.6444em;"></span><span class="mord">0</span></span></span></span></span>时,GaussFun的方差趋向于<b>无穷大</b>,不同<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>z</mi></mrow><annotation encoding="application/x-tex">z</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span></span></span></span></span>值的<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span></span></span></span></span>几乎变成一致,并与<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>几乎相同。读者可在Demo 2中,将<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi></mrow><annotation encoding="application/x-tex">\alpha</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span></span></span>设置为0.01,观察具体的结果。</li>
119
+ <li> 当<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi><mo>→</mo><mn>1</mn></mrow><annotation encoding="application/x-tex">\alpha \to 1</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">→</span><span class="mspace" style="margin-right: 0.2778em;"></span></span><span class="base"><span class="strut" style="height: 0.6444em;"></span><span class="mord">1</span></span></span></span></span>时,GaussFun的方差趋向于<b>无穷小</b>,不同<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>z</mi></mrow><annotation encoding="application/x-tex">z</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span></span></span></span></span>值的<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mi mathvariant="normal">∣</mi><mi>z</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">q(x|z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mord">∣</span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span><span class="mclose">)</span></span></span></span></span>收缩成一系列不同偏移量的Dirac delta函数, 偏移量等于<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>z</mi></mrow><annotation encoding="application/x-tex">z</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.044em;">z</span></span></span></span></span>。但有一些例外,当q(x)存在为零的区域时,其对应的q(x|z)将不再为Dirac delta函数,而是零函数。可在Demo 2中,将<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi></mrow><annotation encoding="application/x-tex">\alpha</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span></span></span>设置为0.999,观察具体的结果。</li>
120
+ </ul></span></div></div></div>
Markdown/zh/posterior_transform.html ADDED
The diff for this file is too large to render. See raw diff
 
Markdown/zh/reference.html ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div id="md_reference" class="block normal mds svelte-90oupt padded hide-container" style="border-style: solid; overflow: visible; min-width: min(0px, 100%); border-width: var(--block-border-width);"><div class="wrap center full svelte-1occ011 hide" style="position: absolute; padding: 0px;"></div> <div class="svelte-1ed2p3z"><div class="prose normal mds svelte-1yrv54" data-testid="markdown" dir="ltr"><span class="md svelte-1syupzx"><p><a href="https://arxiv.org/abs/1503.03585" id="dpm" target="_blank" rel="noopener noreferrer"> [1] Deep Unsupervised Learning Using Nonequilibrium Thermodynami </a></p>
2
+ <p><a href="https://arxiv.org/abs/1503.03585" id="ddpm" target="_blank" rel="noopener noreferrer"> [2] Denoising Diffusion Probabilistic Models </a></p>
3
+ <p><a href="https://stats.libretexts.org/Bookshelves/Probability_Theory/Probability_Mathematical_Statistics_and_Stochastic_Processes_(Siegrist)/03%3A_Distributions/3.07%3A_Transformations_of_Random_Variables" id="linear_transform" target="_blank" rel="noopener noreferrer"> [3] Linear Transformations of Random Variable </a></p>
4
+ <p><a href="https://stats.libretexts.org/Bookshelves/Probability_Theory/Probability_Mathematical_Statistics_and_Stochastic_Processes_(Siegrist)/03%3A_Distributions/3.07%3A_Transformations_of_Random_Variables" id="sum_conv" target="_blank" rel="noopener noreferrer"> [4] Sums and Convolution </a></p>
5
+ <p><a href="https://en.wikipedia.org/wiki/Banach_fixed-point_theorem" id="fixed_point" target="_blank" rel="noopener noreferrer"> [5] Banach fixed-point theorem </a></p>
6
+ <p><a href="https://en.wikipedia.org/wiki/Contraction_mapping" id="ctr" target="_blank" rel="noopener noreferrer"> [6] Contraction mapping </a></p>
7
+ <p><a href="https://stats.libretexts.org/Bookshelves/Probability_Theory/Book%3A_Introductory_Probability_(Grinstead_and_Snell)/11%3A_Markov_Chains/11.04%3A_Fundamental_Limit_Theorem_for_Regular_Chains" id="mc_limit" target="_blank" rel="noopener noreferrer"> [7] Fundamental Limit Theorem for Regular Chains </a></p>
8
+ <p><a href="http://galton.uchicago.edu/~lalley/Courses/312/MarkovChains.pdf" id="mc_basic_p6" target="_blank" rel="noopener noreferrer"> [8] Markov Chain:Basic Theory - Proposition 6 </a></p>
9
+ <p><a href="https://arxiv.org/abs/1702.07339" id="fp_converse" target="_blank" rel="noopener noreferrer"> [9] A Converse to Banach's Fixed Point Theorem and its CLS Completeness </a></p>
10
+ <p><a href="https://en.wikipedia.org/wiki/Cross-entropy#Cross-entropy_minimization" id="ce_kl" target="_blank" rel="noopener noreferrer"> [10] Cross-entropy minimization </a></p>
11
+ <p><a href="https://thewolfsound.com/deconvolution-inverse-convolution/" id="deconv_1" target="_blank" rel="noopener noreferrer"> [11] Deconvolution Using Frequency-Domain Division </a></p>
12
+ <p><a href="https://www.strollswithmydog.com/deconvolution-by-division-in-the-frequency-domain/" id="deconv_2" target="_blank" rel="noopener noreferrer"> [12] deconvolution-by-division-in-the-frequency-domain </a></p>
13
+ <p><a href="http://galton.uchicago.edu/~lalley/Courses/312/MarkovChains.pdf" id="mc_basic_t7" target="_blank" rel="noopener noreferrer"> [13] Markov Chain:Basic Theory - Theorem 7 </a></p>
14
+ <p><a href="http://galton.uchicago.edu/~lalley/Courses/312/MarkovChains.pdf" id="mc_basic_d4" target="_blank" rel="noopener noreferrer"> [14] Markov Chain:Basic Theory - Definition 4 </a></p>
15
+ </span></div></div></div>
Markdown/zh/transform.html ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <div id="md_transform" class="block normal mds svelte-90oupt padded hide-container" style="border-style: solid; overflow: visible; min-width: min(0px, 100%); border-width: var(--block-border-width);"><div class="wrap center full svelte-1occ011 hide" style="position: absolute; padding: 0px;"></div> <div class="svelte-1ed2p3z"><div class="prose normal mds svelte-1yrv54" data-testid="markdown" dir="ltr"><span class="md svelte-1syupzx"><p>为了将初始的数据分布转换为简单的标准正态分布,扩散模型采用如下的变换方式
2
+ <span><span class="katex-display"><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML" display="block"><semantics><mtable rowspacing="0.25em" columnalign="right" columnspacing=""><mtr><mtd class="mtr-glue"></mtd><mtd><mstyle scriptlevel="0" displaystyle="true"><mrow><mi>Z</mi><mo>=</mo><msqrt><mi>α</mi></msqrt><mi>X</mi><mo>+</mo><msqrt><mrow><mn>1</mn><mo>−</mo><mi>α</mi></mrow></msqrt><mi>ϵ</mi><mspace width="2em"></mspace><mi>w</mi><mi>h</mi><mi>e</mi><mi>r</mi><mi>e</mi><mspace width="1em"></mspace><mi>α</mi><mo>&lt;</mo><mn>1</mn><mo separator="true">,</mo><mspace width="1em"></mspace><mi>ϵ</mi><mo>∼</mo><mi mathvariant="script">N</mi><mo stretchy="false">(</mo><mn>0</mn><mo separator="true">,</mo><mi>I</mi><mo stretchy="false">)</mo></mrow></mstyle></mtd><mtd class="mtr-glue"></mtd><mtd class="mml-eqn-num"></mtd></mtr></mtable><annotation encoding="application/x-tex">\begin{align}
3
+ Z = \sqrt{\alpha} X + \sqrt{1-\alpha}\epsilon \qquad where \quad \alpha &lt; 1, \quad \epsilon \sim \mathcal{N}(0, I) \tag{1.1}
4
+ \end{align}</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1.5744em; vertical-align: -0.5372em;"></span><span class="mtable"><span class="col-align-r"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.0372em;"><span class="" style="top: -3.1228em;"><span class="pstrut" style="height: 3em;"></span><span class="mord"><span class="mord mathnormal" style="margin-right: 0.0715em;">Z</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">=</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.8492em;"><span class="svg-align" style="top: -3em;"><span class="pstrut" style="height: 3em;"></span><span class="mord" style="padding-left: 0.833em;"><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span><span class="" style="top: -2.8092em;"><span class="pstrut" style="height: 3em;"></span><span class="hide-tail" style="min-width: 0.853em; height: 1.08em;"><svg width="400em" height="1.08em" viewBox="0 0 400000 1080" preserveAspectRatio="xMinYMin slice"><path d="M95,702
5
+ c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
6
+ c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
7
+ c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
8
+ s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
9
+ c69,-144,104.5,-217.7,106.5,-221
10
+ l0 -0
11
+ c5.3,-9.3,12,-14,20,-14
12
+ H400000v40H845.2724
13
+ s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
14
+ c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
15
+ M834 80h400000v40h-400000z"></path></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.1908em;"><span class=""></span></span></span></span></span><span class="mord mathnormal" style="margin-right: 0.0785em;">X</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mbin">+</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.9144em;"><span class="svg-align" style="top: -3em;"><span class="pstrut" style="height: 3em;"></span><span class="mord" style="padding-left: 0.833em;"><span class="mord">1</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span><span class="" style="top: -2.8744em;"><span class="pstrut" style="height: 3em;"></span><span class="hide-tail" style="min-width: 0.853em; height: 1.08em;"><svg width="400em" height="1.08em" viewBox="0 0 400000 1080" preserveAspectRatio="xMinYMin slice"><path d="M95,702
16
+ c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
17
+ c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
18
+ c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
19
+ s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
20
+ c69,-144,104.5,-217.7,106.5,-221
21
+ l0 -0
22
+ c5.3,-9.3,12,-14,20,-14
23
+ H400000v40H845.2724
24
+ s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
25
+ c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
26
+ M834 80h400000v40h-400000z"></path></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.1256em;"><span class=""></span></span></span></span></span><span class="mord mathnormal">ϵ</span><span class="mspace" style="margin-right: 2em;"></span><span class="mord mathnormal" style="margin-right: 0.0269em;">w</span><span class="mord mathnormal">h</span><span class="mord mathnormal">ere</span><span class="mspace" style="margin-right: 1em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">&lt;</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mord">1</span><span class="mpunct">,</span><span class="mspace" style="margin-right: 1em;"></span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord mathnormal">ϵ</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">∼</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mord mathcal" style="margin-right: 0.1474em;">N</span><span class="mopen">(</span><span class="mord">0</span><span class="mpunct">,</span><span class="mspace" style="margin-right: 0.1667em;"></span><span class="mord mathnormal" style="margin-right: 0.0785em;">I</span><span class="mclose">)</span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.5372em;"><span class=""></span></span></span></span></span></span></span><span class="tag"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 1.0372em;"><span class="" style="top: -3.1228em;"><span class="pstrut" style="height: 3em;"></span><span class=""><span class="mord text"><span class="mord">(</span><span class="mord"><span class="mord">1.1</span></span><span class="mord">)</span></span></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.5372em;"><span class=""></span></span></span></span></span></span></span></span></span>
27
+ 其中<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>X</mi><mo>∼</mo><mi>q</mi><mo stretchy="false">(</mo><mi>x</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">X\sim q(x)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.6833em;"></span><span class="mord mathnormal" style="margin-right: 0.0785em;">X</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">∼</span><span class="mspace" style="margin-right: 0.2778em;"></span></span><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal">x</span><span class="mclose">)</span></span></span></span></span>是任意的随机变量,<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>Z</mi><mo>∼</mo><mi>q</mi><mo stretchy="false">(</mo><mi>Z</mi><mo stretchy="false">)</mo></mrow><annotation encoding="application/x-tex">Z\sim q(Z)</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.6833em;"></span><span class="mord mathnormal" style="margin-right: 0.0715em;">Z</span><span class="mspace" style="margin-right: 0.2778em;"></span><span class="mrel">∼</span><span class="mspace" style="margin-right: 0.2778em;"></span></span><span class="base"><span class="strut" style="height: 1em; vertical-align: -0.25em;"></span><span class="mord mathnormal" style="margin-right: 0.0359em;">q</span><span class="mopen">(</span><span class="mord mathnormal" style="margin-right: 0.0715em;">Z</span><span class="mclose">)</span></span></span></span></span>是变换后的随机变量。</p>
28
+ <p>此变换可分为两个子变换。</p>
29
+ <p>第一个子变换是对随机变量<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>X</mi></mrow><annotation encoding="application/x-tex">X</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.6833em;"></span><span class="mord mathnormal" style="margin-right: 0.0785em;">X</span></span></span></span></span>执行一个线性变换(<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msqrt><mi>α</mi></msqrt><mi>X</mi></mrow><annotation encoding="application/x-tex">\sqrt{\alpha}X</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1.04em; vertical-align: -0.2397em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.8003em;"><span class="svg-align" style="top: -3em;"><span class="pstrut" style="height: 3em;"></span><span class="mord" style="padding-left: 0.833em;"><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span><span class="" style="top: -2.7603em;"><span class="pstrut" style="height: 3em;"></span><span class="hide-tail" style="min-width: 0.853em; height: 1.08em;"><svg width="400em" height="1.08em" viewBox="0 0 400000 1080" preserveAspectRatio="xMinYMin slice"><path d="M95,702
30
+ c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
31
+ c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
32
+ c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
33
+ s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
34
+ c69,-144,104.5,-217.7,106.5,-221
35
+ l0 -0
36
+ c5.3,-9.3,12,-14,20,-14
37
+ H400000v40H845.2724
38
+ s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
39
+ c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
40
+ M834 80h400000v40h-400000z"></path></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.2397em;"><span class=""></span></span></span></span></span><span class="mord mathnormal" style="margin-right: 0.0785em;">X</span></span></span></span></span>),根据文献<a href="#linear_transform">[3]</a>的结论,线性变换使<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>X</mi></mrow><annotation encoding="application/x-tex">X</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.6833em;"></span><span class="mord mathnormal" style="margin-right: 0.0785em;">X</span></span></span></span></span>的概率分布“变窄变高”,并且"变窄变高"的程度与<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi></mrow><annotation encoding="application/x-tex">\alpha</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span></span></span>的值成正比;具体可看Demo 1,左1图为随机生成的一维的概率分布,左2图是经过线性变换后的概率分布,可以看出,与左1图相比,左2图的曲线“变窄变高”了。读者可亲自测试不同的<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi></mrow><annotation encoding="application/x-tex">\alpha</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span></span></span>值,获得更直观的理解。</p>
41
+ <p>第二个子变换是“加上独立的随机噪声”(<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><msqrt><mrow><mn>1</mn><mo>−</mo><mi>α</mi></mrow></msqrt><mi>ϵ</mi></mrow><annotation encoding="application/x-tex">\sqrt{1-\alpha}\epsilon</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 1.04em; vertical-align: -0.1744em;"></span><span class="mord sqrt"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height: 0.8656em;"><span class="svg-align" style="top: -3em;"><span class="pstrut" style="height: 3em;"></span><span class="mord" style="padding-left: 0.833em;"><span class="mord">1</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span><span class="" style="top: -2.8256em;"><span class="pstrut" style="height: 3em;"></span><span class="hide-tail" style="min-width: 0.853em; height: 1.08em;"><svg width="400em" height="1.08em" viewBox="0 0 400000 1080" preserveAspectRatio="xMinYMin slice"><path d="M95,702
42
+ c-2.7,0,-7.17,-2.7,-13.5,-8c-5.8,-5.3,-9.5,-10,-9.5,-14
43
+ c0,-2,0.3,-3.3,1,-4c1.3,-2.7,23.83,-20.7,67.5,-54
44
+ c44.2,-33.3,65.8,-50.3,66.5,-51c1.3,-1.3,3,-2,5,-2c4.7,0,8.7,3.3,12,10
45
+ s173,378,173,378c0.7,0,35.3,-71,104,-213c68.7,-142,137.5,-285,206.5,-429
46
+ c69,-144,104.5,-217.7,106.5,-221
47
+ l0 -0
48
+ c5.3,-9.3,12,-14,20,-14
49
+ H400000v40H845.2724
50
+ s-225.272,467,-225.272,467s-235,486,-235,486c-2.7,4.7,-9,7,-19,7
51
+ c-6,0,-10,-1,-12,-3s-194,-422,-194,-422s-65,47,-65,47z
52
+ M834 80h400000v40h-400000z"></path></svg></span></span></span><span class="vlist-s">​</span></span><span class="vlist-r"><span class="vlist" style="height: 0.1744em;"><span class=""></span></span></span></span></span><span class="mord mathnormal">ϵ</span></span></span></span></span>),根据文献<a href="#sum_conv">[4]</a>的结论,“加上独立的随机变量”等效于对两个概率分布执行卷积,由于随机噪声的概率分布为高斯形状,所以相当于执行”高斯模糊“的操作。经过模糊后,原来的概率分布将变得更加平滑,与标准正态分布将更加相似。模糊的程度与噪声大小(<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mn>1</mn><mo>−</mo><mi>α</mi></mrow><annotation encoding="application/x-tex">1-\alpha</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.7278em; vertical-align: -0.0833em;"></span><span class="mord">1</span><span class="mspace" style="margin-right: 0.2222em;"></span><span class="mbin">−</span><span class="mspace" style="margin-right: 0.2222em;"></span></span><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span></span></span>)正相关。具体可看Demo 1,左1图是随机生成的一维概率分布,左3图是经过变换后的结果,可以看出,变换后的曲线变光滑了,棱角变少了。读者可测试不同的<span><span class="katex"><span class="katex-mathml"><math xmlns="http://www.w3.org/1998/Math/MathML"><semantics><mrow><mi>α</mi></mrow><annotation encoding="application/x-tex">\alpha</annotation></semantics></math></span><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height: 0.4306em;"></span><span class="mord mathnormal" style="margin-right: 0.0037em;">α</span></span></span></span></span>值,感受噪声大小对概率分布曲线形状的影响。左4图是综合两个子变换后的结果。</p>
53
+ </span></div></div></div>
Misc.py ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+
3
+ js_head = "<script>" + open("ExtraBlock.js").read() + "</script>" +\
4
+ """ <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/[email protected]/dist/katex.min.js" integrity="sha384-0fdwu/T/EQMsQlrHCCHoH10pkPLlKA1jL5dFyUOvB3lfeT2540/2g6YgSi2BL14p" crossorigin="anonymous"></script> """
5
+
6
+
7
+ js_load = """
8
+ function load_callback() {
9
+ insert_markdown();
10
+ add_switch();
11
+ insert_special_formula();
12
+ }
13
+ """
14
+
15
+
16
+ g_css = """
17
+ .bgc {background-color: #ffffff; border-width: 0 !important}
18
+ .first_demo span{font-size: 140%; font-weight: bold; color: blue}
19
+ .first_md span{font-size: 140%; font-weight: bold; color: orange}
20
+ .normal span{font-size: 100%; font-weight: normal; color: black}
21
+ .second span{font-size: 100%; font-weight: bold; color: blue}
22
+ .mds div{margin-top: 10px; margin-bottom: 20px; margin-left:10px; margin-right:10px; font-size:16px}
23
+ .gps div{margin-top: 10px; margin-bottom: 20px;}
24
+
25
+ .switchbar {position: relative; display: inline-block; width: 60px; height: 30px; margin-left: 10px; margin-right: 10px}
26
+ .switchbar input {opacity: 0; width: 0; height: 0;}
27
+
28
+ .switchslider {position: absolute; cursor: pointer; top: 0; left: 0; right: 0; bottom: 0;
29
+ border-radius: 30px; background-color: orange; -webkit-transition: .4s; transition: .4s;}
30
+
31
+ .switchslider:before {position: absolute; content: ""; height: 22px; width: 22px; border-radius: 50%;
32
+ left: 4px; bottom: 4px; background-color: white; -webkit-transition: .4s;
33
+ transition: .4s;}
34
+
35
+ input:checked + .switchslider {background-color: orange;}
36
+
37
+ input:checked + .switchslider:before {-webkit-transform: translateX(26px); -ms-transform: translateX(26px);
38
+ transform: translateX(26px);}
39
+
40
+ ul,ol { display: block; list-style-type: disc;
41
+ padding-inline-start: 40px;}
42
+ ul,ol:last-of-type { list-style-position: outside;}
43
+ ol { list-style-type: decimal ;}
44
+ li { display: list-item;}
45
+ """
46
+
47
+ g_latex_del = [
48
+ {"left": "$$", "right": "$$", "display": True},
49
+ {"left": "$", "right": "$", "display": False},
50
+ {"left": "\\(", "right": "\\)", "display": False},
51
+ {"left": "\\begin{equation}", "right": "\\end{equation}", "display": True},
52
+ {"left": "\\begin{align}", "right": "\\end{align}", "display": True},
53
+ {"left": "\\begin{aligned}", "right": "\\end{aligned}", "display": True}
54
+ ]
README.md CHANGED
@@ -4,10 +4,32 @@ emoji: 🌖
4
  colorFrom: red
5
  colorTo: gray
6
  sdk: gradio
7
- sdk_version: 4.28.3
8
- app_file: app.py
9
  pinned: false
 
10
  license: apache-2.0
11
  ---
12
 
13
- Check out the configuration reference at https://huggingface.co/docs/hub/spaces-config-reference
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
4
  colorFrom: red
5
  colorTo: gray
6
  sdk: gradio
7
+ sdk_version: 4.12.0
8
+ app_file: App.py
9
  pinned: false
10
+ python_version: 3.10
11
  license: apache-2.0
12
  ---
13
 
14
+ <center>
15
+ <h1 style="display:block">
16
+ Understanding Diffusion Probability Model<span style='color: orange'>&nbsp;Interactively </span>
17
+ </h1>
18
+ </center>
19
+ </br> </br> </br>
20
+
21
+ This is a Web App which provides a special introduction about the Diffusion Probability Model with interactive demos.
22
+
23
+ How to run
24
+ <ol>
25
+ <li> Open <a href="https://huggingface.co/spaces/blairzheng/DPMInteractive">HuggingFace space</a> in browser directly. </li>
26
+ <li> Running locally, recommended.
27
+ <ul>
28
+ <li> git clone https://github.com/blairstar/The_Art_of_DPM.git </li>
29
+ <li> cd DPMInteractive & pip install -r requirements.txt </li>
30
+ <li> python App.py </li>
31
+ </ul>
32
+ </li>
33
+ </ol>
34
+
35
+
RenderMarkdown.py ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+
4
+ from RenderMarkdownZh import md_introduction_zh, md_transform_zh, md_likelihood_zh, md_posterior_zh
5
+ from RenderMarkdownZh import md_forward_process_zh, md_backward_process_zh, md_fit_posterior_zh
6
+ from RenderMarkdownZh import md_posterior_transform_zh, md_deconvolution_zh, md_reference_zh, md_about_zh
7
+
8
+ from RenderMarkdownEn import md_introduction_en, md_transform_en, md_likelihood_en, md_posterior_en
9
+ from RenderMarkdownEn import md_forward_process_en, md_backward_process_en, md_fit_posterior_en
10
+ from RenderMarkdownEn import md_posterior_transform_en, md_deconvolution_en, md_reference_en, md_about_en
11
+
12
+
13
+ def md_introduction_block(md_type="offline"):
14
+ if md_type == "offline":
15
+ gr.Accordion(label="0. Introduction", elem_classes="first_md", elem_id="introduction")
16
+ elif md_type == "zh":
17
+ md_introduction_zh()
18
+ elif md_type == "en":
19
+ md_introduction_en()
20
+ else:
21
+ raise NotImplementedError
22
+ return
23
+
24
+
25
+ def md_transform_block(md_type="offline"):
26
+ if md_type == "offline":
27
+ gr.Accordion(label="1. How To Transform", elem_classes="first_md", elem_id="transform")
28
+ elif md_type == "zh":
29
+ md_transform_zh()
30
+ elif md_type == "en":
31
+ md_transform_en()
32
+ else:
33
+ raise NotImplementedError
34
+ return
35
+
36
+
37
+ def md_likelihood_block(md_type="offline"):
38
+ if md_type == "offline":
39
+ gr.Accordion(label="2. Likelihood of The Transform", elem_classes="first_md", elem_id="likelihood")
40
+ elif md_type == "zh":
41
+ md_likelihood_zh()
42
+ elif md_type == "en":
43
+ md_likelihood_en()
44
+ else:
45
+ raise NotImplementedError
46
+ return
47
+
48
+
49
+ def md_posterior_block(md_type="offline"):
50
+ if md_type == "offline":
51
+ gr.Accordion(label="3. Posterior of The Transform", elem_classes="first_md", elem_id="posterior")
52
+ elif md_type == "zh":
53
+ md_posterior_zh()
54
+ elif md_type == "en":
55
+ md_posterior_en()
56
+ else:
57
+ raise NotImplementedError
58
+ return
59
+
60
+
61
+ def md_forward_process_block(md_type="offline"):
62
+ if md_type == "offline":
63
+ title = "4. Transform Data Distribution To Normal Distribution"
64
+ gr.Accordion(label=title, elem_classes="first_md", elem_id="forward_process")
65
+ elif md_type == "zh":
66
+ md_forward_process_zh()
67
+ elif md_type == "en":
68
+ md_forward_process_en()
69
+ else:
70
+ raise NotImplementedError
71
+ return
72
+
73
+
74
+ def md_backward_process_block(md_type="offline"):
75
+ if md_type == "offline":
76
+ title = "5. Restore Data Distribution From Normal Distribution"
77
+ gr.Accordion(label=title, elem_classes="first_md", elem_id="backward_process")
78
+ elif md_type == "zh":
79
+ md_backward_process_zh()
80
+ elif md_type == "en":
81
+ md_backward_process_en()
82
+ else:
83
+ raise NotImplementedError
84
+ return
85
+
86
+
87
+ def md_fit_posterior_block(md_type="offline"):
88
+ if md_type == "offline":
89
+ title = "6. Fitting Posterior With Conditional Gaussian Model"
90
+ gr.Accordion(label=title, elem_classes="first_md", elem_id="fit_posterior")
91
+ elif md_type == "zh":
92
+ md_fit_posterior_zh()
93
+ elif md_type == "en":
94
+ md_fit_posterior_en()
95
+ else:
96
+ raise NotImplementedError
97
+ return
98
+
99
+
100
+ def md_posterior_transform_block(md_type="offline"):
101
+ if md_type == "offline":
102
+ gr.Accordion(label="7. Posterior Transform", elem_classes="first_md", elem_id="posterior_transform")
103
+ elif md_type == "zh":
104
+ md_posterior_transform_zh()
105
+ elif md_type == "en":
106
+ md_posterior_transform_en()
107
+ else:
108
+ raise NotImplementedError
109
+ return
110
+
111
+
112
+ def md_deconvolution_block(md_type="offline"):
113
+ if md_type == "offline":
114
+ title = "8. Can the data distribution be restored by deconvolution?"
115
+ gr.Accordion(label=title, elem_classes="first_md", elem_id="deconvolution")
116
+ elif md_type == "zh":
117
+ md_deconvolution_zh()
118
+ elif md_type == "en":
119
+ md_deconvolution_en()
120
+ else:
121
+ raise NotImplementedError
122
+ return
123
+
124
+
125
+ def md_reference_block(md_type="offline"):
126
+ if md_type == "offline":
127
+ gr.Accordion(label="Reference", elem_classes="first_md", elem_id="reference")
128
+ elif md_type == "zh":
129
+ md_reference_zh()
130
+ elif md_type == "en":
131
+ md_reference_en()
132
+ else:
133
+ raise NotImplementedError
134
+ return
135
+
136
+
137
+ def md_about_block(md_type="offline"):
138
+ if md_type == "offline":
139
+ gr.Accordion(label="About", elem_classes="first_md", elem_id="about")
140
+ elif md_type == "zh":
141
+ md_about_zh()
142
+ elif md_type == "en":
143
+ md_about_en()
144
+ else:
145
+ raise NotImplementedError
146
+ return
RenderMarkdownEn.py ADDED
@@ -0,0 +1,504 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+ from Misc import g_css, g_latex_del, js_head
4
+
5
+
6
+ def md_introduction_en():
7
+ global g_latex_del
8
+
9
+ with gr.Accordion(label="0. Introduction", elem_classes="first_md", elem_id="introduction"):
10
+
11
+ gr.Markdown(
12
+ r"""
13
+ The Diffusion Model[\\[1\\]](#dpm)[\\[2\\]](#ddpm) is currently the main method used in image and video generation, but due to its abstruse theory, many engineers are unable to understand it well. This article will provide a very easy-to-understand method to help readers grasp the principles of the Diffusion Model. Specifically, it will illustrate the Diffusion Model using examples of one-dimensional random variables in an interactive way, explaining several interesting properties of the Diffusion Model in an intuitive manner.
14
+
15
+ The diffusion model is a probabilistic model. Probabilistic models mainly offer two functions: calculating the probability of a given sample appearing; and generating new samples. The diffusion model focuses on the latter aspect, facilitating the production of new samples, thus realizing the task of **generation**.
16
+
17
+ The diffusion model differs from general probability models (such as GMM), which directly models the probability distribution of random variables. The diffusion model adopts an indirect approach, which utilizes **random variable transformation**(shown in Figure 1a) to gradually convert the data distribution (the probability distribution to be modeled) into the **standard normal distribution**, and meanwhile models the posterior probability distribution corresponding to each transformation (Figure 1b-c). Upon obtaining the final standard normal distribution and the posterior probability distributions, one can generate samples of each random variable $Z_T \ldots Z_2,Z_1,X$ in reverse order through Ancestral Sampling method. Simultaneously, initial data distribution $q(x)$ can be determined by employing Bayes theorem and the total probability theorem.
18
+
19
+ One might wonder: indirect methods require modeling and learning T posterior probability distributions, while direct methods only need to model one probability distribution, Why would we choose the indirect approach? Here's the reasoning: the initial data distribution might be quite complex and hard to represent directly with a probability model. In contrast, the complexity of each posterior probability distribution in indirect methods is significantly simpler, allowing it to be approximated by simple probability models. As we will see later, given certain conditions, posterior probability distributions can closely resemble Gaussian distributions, thus a simple conditional Gaussian model can be used for modeling.
20
+
21
+ <center> <img src="file/pipe.jpg" width="820" style="margin-top:12px"/> </center>
22
+ <center> Figure 1: Diffusion model schematic </center>
23
+ """, latex_delimiters=g_latex_del, elem_classes="normal mds", elem_id="md_introduction")
24
+ return
25
+
26
+
27
+ def md_transform_en():
28
+ global g_latex_del
29
+
30
+ with gr.Accordion(label="1. How To Transform", elem_classes="first_md", elem_id="transform"):
31
+
32
+ gr.Markdown(
33
+ r"""
34
+ To transform the initial data distribution into a simple standard normal distribution, the diffusion model uses the following transformation method:
35
+ \begin{align}
36
+ Z = \sqrt{\alpha} X + \sqrt{1-\alpha}\epsilon \qquad where \quad \alpha < 1, \quad \epsilon \sim \mathcal{N}(0, I) \tag{1.1}
37
+ \end{align}
38
+ where $X\sim q(x)$is any random variable,$Z\sim q(Z)$ is the transformed random variable。
39
+
40
+ This transformation can be divided into two sub-transformations。
41
+
42
+ The first sub-transformation performs a linear transformation ($\sqrt{\alpha}X$) on the random variable $X$. According to the conclusion of the literature[\[3\]](#linear_transform), the linear transformation makes the probability distribution of $X$ **narrower and taller**, and the extent of **narrowing and heightening** is directly proportional to the value of $\alpha$.
43
+
44
+ This can be specifically seen in Demo 1, where the first figure depicts a randomly generated one-dimensional probability distribution, and the second figure represents the probability distribution after the linear transformation. It can be observed that the curve of the third figure has become **narrower and taller** compared to the first image. Readers can experiment with different $\alpha$ to gain a more intuitive understanding.
45
+
46
+ The second sub-transformation is **adding independent random noise**($\sqrt{1-\alpha}\epsilon$). According to the conclusion of the literature[\[4\]](#sum_conv), **adding independent random variables** is equivalent to performing convolution on the two probability distributions. Since the probability distribution of random noise is Gaussian, it is equivalent to performing a **Gaussian Blur** operation. After blurring, the original probability distribution will become smoother and more similar to the standard normal distribution. The degree of blurring is directly proportional to the noise level ($\sqrt{1-\alpha}$).
47
+
48
+ For specifics, one can see Demo 1, where the first figure is a randomly generated one-dimensional probability distribution, and the third figure is the result after the transformation. It can be seen that the transformed probability distribution curve is smoother and there are fewer corners. The readers can test different $\alpha$ values to feel how the noise level affect the shape of the probability distribution. The last figure is the result after applying all two sub-transformations.
49
+ """, latex_delimiters=g_latex_del, elem_classes="normal mds", elem_id="md_transform")
50
+ return
51
+
52
+
53
+ def md_likelihood_en():
54
+ global g_latex_del
55
+
56
+ with gr.Accordion(label="2. Likelihood of The Transform", elem_classes="first_md", elem_id="likelihood"):
57
+
58
+ gr.Markdown(
59
+ r"""
60
+ From the transformation method (equation 1.1), it can be seen that the probability distribution of the forward conditional probability $q(z|x)$ is a Gaussian distribution, which is only related to the value of $\alpha$, regardless of the probability distribution of $q(x)$.
61
+ \begin{align}
62
+ q(z|x) &= \mathcal{N}(\sqrt{\alpha}x,\ 1-\alpha) \tag{2.1}
63
+ \end{align}
64
+ It can be understood by concrete examples in Demo 2. The third figure depict the shape of $q(z|x)$. From the figure, a uniform slanting line can be observed. This implies that the mean of $q(z|x)$ is linearly related to x, and the variance is fixed. The magnitude of $\alpha$ will determine the width and incline of the slanting line.
65
+ """, latex_delimiters=g_latex_del, elem_classes="normal mds", elem_id="md_likelihood")
66
+ return
67
+
68
+
69
+ def md_posterior_en():
70
+ global g_latex_del
71
+
72
+ with gr.Accordion(label="3. Posterior of The Transform", elem_classes="first_md", elem_id="posterior"):
73
+
74
+ gr.Markdown(
75
+ r"""
76
+ The posterior probability distribution does not have a closed form, but its shape can be inferred approximately through some technique.
77
+
78
+ According to Bayes formula, we have
79
+ \begin{align}
80
+ q(x|z) = \frac{q(z|x)q(x)}{q(z)} \tag{3.1}
81
+ \end{align}
82
+
83
+ When $z$ takes a fixed value, $q(z)$ is a constant, so the shape of $q(x|z)$ is only related to ${q(z|x)q(x)}$.
84
+ \begin{align}
85
+ q(x|z) \propto q(z|x)q(x) \qquad where\ z\ is\ fixed \tag{3.2}
86
+ \end{align}
87
+
88
+ From Equation 2.1, we can see that $q(z|x)$ is a Gaussian distribution, so we have
89
+ \begin{align}
90
+ q(x|z) &\propto \frac{1}{\sqrt{2\pi(1-\alpha)}}\exp{\frac{-(z-\sqrt{\alpha}x)^2}{2(1-\alpha)}}\ q(x)& \qquad &where\ z\ is\ fixed \tag{3.3} \newline
91
+ &= \frac{1}{\sqrt{\alpha}} \underbrace{\frac{1}{\sqrt{2\pi}\sigma}\exp{\frac{-(x-\mu)^2}{2\sigma^2}}}_{\text{GaussFun}}\ q(x)& \qquad &where\ \mu=\frac{z}{\sqrt{\alpha}}\quad \sigma=\sqrt{\frac{1-\alpha}{\alpha}} \tag{3.4}
92
+ \end{align}
93
+
94
+ It can be observed that the <b>GaussFun</b> part is a Gaussian function of $x$, with a mean of $\frac{z}{\sqrt{\alpha}}$ and a variance of $\sqrt{\frac{1-\alpha}{\alpha}}$, so the shape of $q(x|z)$ is determined by **the product of GaussFun and q(x)**.
95
+
96
+ According to the characteristics of <em>multiplication</em>, the characteristics of the shape of the $q(x|z)$ function can be summarized.
97
+
98
+ <ul>
99
+ <li>When the variance of the Gaussian function is small (small noise), or when $q(x)$ changes slowly, the shape of $q(x|z)$ will approximate to the Gaussian function, and have a simpler function form, which is convenient for modeling and learning.</li>
100
+
101
+ <li>When the variance of the Gaussian function is large (large noise), or when $q(x)$ changes drastically, the shape of $q(x|z)$ will be more complex, and greatly differ from a Gaussian function, which makes it difficult to model and learn.</li>
102
+ </ul>
103
+
104
+ The specifics can be seen in Demo 2. The fourth figure present the shape of the posterior $q(x|z)$, which shows an irregular shape and resembles a curved and uneven line. As $\alpha$ increases (noise decreases), the curve tends to be uniform and straight. Readers can adjust different $\alpha$ values and observe the relationship between the shape of posterior and the level of noise. In the last figure, the $\textcolor{blue}{\text{blue dash line}}$ represents $q(x)$, the $\textcolor{green}{\text{green dash line}}$ represents <b>GaussFun</b> in the equation 3.4, and the $\textcolor{orange}{\text{orange curve}}$ represents the result of multiplying the two function and normalizing it, which is the posterior probability $q(x|z=fixed)$ under a fixed z condition. Readers can adjust different values of z to observe how the fluctuation of $q(x)$ affect the shape of the posterior probability $q(x|z)$.
105
+
106
+ The posterior $q(x|z)$ under two special states are worth considering.
107
+ <ul>
108
+ <li>As $\alpha \to 0$, the variance of <b>GaussFun</b> tends to <b>$\infty$</b>, and $q(x|z)$ for different $z$ almost become identical, and almost the same as $q(x)$. Readers can set $\alpha$ to 0.01 in Demo 2 to observe the specific results.</li>
109
+
110
+ <li>As $\alpha \to 1$, the variance of <b>GaussFun</b> tends to <b>$0$</b>, The $q(x|z)$ for different $z$ values contract into a series of <em>Dirac delta functions</em> with different offsets equalling to $z$. However, there are some exceptions. When there are regions where $q(x)$ is zero, the corresponding $q(x|z)$ will no longer be a Dirac <em>delta function</em>, but a zero function. Readers can set $\alpha$ to 0.999 in Demo 2 to observe the specific results.</li>
111
+ </ul>
112
+ """, latex_delimiters=g_latex_del, elem_classes="normal mds", elem_id="md_posterior")
113
+ return
114
+
115
+
116
+ def md_forward_process_en():
117
+ global g_latex_del
118
+
119
+ title = "4. Transform Data Distribution To Normal Distribution"
120
+ with gr.Accordion(label=title, elem_classes="first_md", elem_id="forward_process"):
121
+
122
+ gr.Markdown(
123
+ r"""
124
+ For any arbitrary data distribution $q(x)$, the transform(equation 2.1) in section 2 can be continuously applied(equation 4.1~4.4). As the number of transforms increases, the output probability distribution will become increasingly closer to the standard normal distribution. For more complex data distributions, more iterations or larger noise are needed.
125
+
126
+ Specific details can be observed in Demo3. The first figure illustrates a randomly generated one-dimensional probability distribution. After seven transforms, this distribution looks very similar to the standard normal distribution. The degree of similarity increases with the number of iterations and the level of the noise. Given the same degree of similarity, fewer transforms are needed if the noise added at each step is larger (smaller $\alpha$ value). Readers can try different $\alpha$ values and numbers of transforms to see how similar the final probability distribution is.
127
+
128
+ The complexity of the initial probability distribution tends to be high, but as the number of transforms increases, the complexity of the probability distribution $q(z_t)$ will decrease. As concluded in section 4, a more complex probability distribution corresponds to a more complex posterior probability distribution. Therefore, in order to ensure that the posterior probability distribution is more similar to the Conditional Gaussian function (easier to learn), a larger value of $\alpha$ (smaller noise) should be used in the initial phase, and a smaller value of $\alpha$ (larger noise) can be appropriately used in the later phase to accelerate the transition to the standard normal distribution.
129
+
130
+ In the example of Demo 3.1, it can be seen that as the number of transforms increases, the corners of $q(z_t)$ become fewer and fewer. Meanwhile, the slanting lines in the plot of the posterior probability distribution $q(z_{t-1}|z_t)$ become increasingly straight and uniform, resembling more and more the conditional Gaussian distribution.
131
+
132
+ \begin{align}
133
+ Z_1 &= \sqrt{\alpha_1} X + \sqrt{1-\alpha_1}\epsilon_1 \tag{4.1} \newline
134
+ Z_2 &= \sqrt{\alpha_2} Z_1 + \sqrt{1-\alpha_2}\epsilon_2 \tag{4.2} \newline
135
+ &\dots \notag \newline
136
+ Z_{t} &= \sqrt{\alpha_t}Z_{t-1} + \sqrt{1-\alpha_t}\epsilon_{t} \tag{4.3} \newline
137
+ &\dots \notag \newline
138
+ Z_{T} &= \sqrt{\alpha_T}Z_{T-1} + \sqrt{1-\alpha_T}\epsilon_{T} \tag{4.4} \newline
139
+ &where \quad \alpha_t < 1 \qquad t\in {1,2,\dots,T} \notag
140
+ \end{align}
141
+
142
+ By substituting Equation 4.1 into Equation 4.2, and utilizing the properties of Gaussian distribution, we can derive the form of $q(z_2|x)$
143
+ \begin{align}
144
+ z_2 &= \sqrt{\alpha_2}(\sqrt{\alpha_1}x + \sqrt{1-\alpha_1}\epsilon_1) + \sqrt{1-\alpha_2}\epsilon_2 \tag{4.5} \newline
145
+ &= \sqrt{\alpha_2\alpha_1}x + \sqrt{\alpha_2-\alpha_2\alpha_1}\epsilon_1 + \sqrt{1-\alpha_2}\epsilon_2 \tag{4.6} \newline
146
+ &= \mathcal{N}(\sqrt{\alpha_1\alpha_2}x,\ 1-\alpha_1\alpha_2) \tag{4.7}
147
+ \end{align}
148
+
149
+ In the same way, it can be deduced recursively that
150
+ \begin{align}
151
+ q(z_t|x) &= \mathcal{N}(\sqrt{\alpha_1\alpha_2\cdots\alpha_t}x,\ 1-\alpha_1\alpha_2\cdots\alpha_t) = \mathcal{N}(\sqrt{\bar{\alpha_t}}x,\ 1-\bar{\alpha_t}) \qquad where\ \bar{\alpha_t} \triangleq \prod_{j=1}^t\alpha_j \tag{4.8}
152
+ \end{align}
153
+
154
+ Comparing the forms of Equation 4.8 and Equation 2.1, it can be found that their forms are completely consistent. If only focusing on the final transformed distribution $q(z_t)$, then the t consective small transformations can be replaced by one large transformation. The $\alpha$ of the large transformation is the accumulation of the $\alpha$ from each small transformation.
155
+
156
+ In the DDPM[\[2\]](#ddpm) paper, the authors used 1000 steps (T=1000) to transform the data distribution $q(x)$ to $q(z_T)$. The probability distribution of $q(z_T|x)$ is as follows:
157
+ \begin{align}
158
+ q(z_T|x) &= \mathcal{N}(0.00635\ x,\ 0.99998) \tag{4.9}
159
+ \end{align}
160
+
161
+ If considering only $q(z_T)$, a single transformation can also be used, which is as follows:
162
+ \begin{align}
163
+ Z_T = \sqrt{0.0000403}\ X + \sqrt{1-0.0000403}\ \epsilon = 0.00635\ X + 0.99998\ \epsilon \tag{4.10}
164
+ \end{align}
165
+ It can be seen that, after applying two transforms, the transformed distributions $q(z_T|x)$ are the same. Thus, $q(z_T)$ is also the same.
166
+ """, latex_delimiters=g_latex_del, elem_classes="normal mds", elem_id="md_forward_process")
167
+ return
168
+
169
+
170
+ def md_backward_process_en():
171
+ global g_latex_del
172
+
173
+ title = "5. Restore Data Distribution From Normal Distribution"
174
+ with gr.Accordion(label=title, elem_classes="first_md", elem_id="backward_process"):
175
+
176
+ gr.Markdown(
177
+ r"""
178
+ If the final probability distribution $q(z_T)$ and the posterior probabilities of each transform $q(x|z),q(z_{t-1}|z_t)$ are known, the data distribution $q(x)$ can be recovered through the Bayes Theorem and the Law of Total Probability, as shown in equations 5.1~5.4. When the final probability distribution $q(z_T)$ is very similar to the standard normal distribution, the standard normal distribution can be used as a substitute.
179
+
180
+ Specifics can be seen in Demo 3.2. In the example, $q(z_T)$ substitutes $\mathcal{N}(0,1)$, and the error magnitude is given through JS Divergence. The restored probability distribution $q(z_t)$ and $q(x)$ are identified by the $\textcolor{green}{\text{green curve}}$, and the original probability distribution is identified by the $\textcolor{blue}{\text{blue curve}}$. It can be observed that the data distribution $q(x)$ can be well restored, and the error (JS Divergence) will be smaller than the error caused by the standard normal distribution replacing $q(z_T)$.
181
+ \begin{align}
182
+ q(z_{T-1}) &= \int q(z_{T-1},z_T)dz_T = \int q(z_{T-1}|z_T)q(z_T)dz_T \tag{5.1} \newline
183
+ & \dots \notag \newline
184
+ q(z_{t-1}) &= \int q(z_{t-1},z_t)dz_t = \int q(z_{t-1}|z_t)q(z_t)dz_t \tag{5.2} \newline
185
+ & \dots \notag \newline
186
+ q(z_1) &= \int q(z_1,z_2) dz_1 = \int q(z_1|z_2)q(z_2)dz_2 \tag{5.3} \newline
187
+ q(x) &= \int q(x,z_1) dz_1 = \int q(x|z_1)q(z_1)dz_1 \tag{5.4} \newline
188
+ \end{align}
189
+ In this article, the aforementioned transform is referred to as the <b>Posterior Transform</b>. For example, in equation 5.4, the input of the transform is the probability distribution function $q(z_1)$, and the output is the probability distribution function $q(x)$.The entire transform is determined by the posterior $q(x|z_1)$. This transform can also be considered as the linear weighted sum of a set of basis functions, where the basis functions are $q(x|z_1)$ under different $z_1$, and the weights of each basis function are $q(z_1)$. Some interesting properties of this transform will be introduced in Section 7.
190
+
191
+ In Section 3, we have considered two special posterior probability distributions. Next, we analyze their corresponding <em>posterior transforms</em>.
192
+ <ul>
193
+ <li> When $\alpha \to 0$, the $q(x|z)$ for different $z$ are almost the same as $q(x)$. In other words, the basis functions of linear weighted sum are almost the same. In this state, no matter how the input changes, the output of the transformation is always $q(x)$."</li>
194
+ <li> When $\alpha \to 1$, the $q(x|z)$ for different $z$ values becomes a series of Dirac delta functions and zero functions. In this state, as long as the <em>support set</em> of the input distribution is included in the <em>support set</em> of $q(x)$, the output of the transformation will remain the same with the input.</li>
195
+ </ul>
196
+
197
+ In Section 5, it is mentioned that the 1000 transformations used in the DDPM[\[2\]](#ddpm) can be represented using a single transformation
198
+ \begin{align}
199
+ Z_T = \sqrt{0.0000403}\ X + \sqrt{1-0.0000403}\ \epsilon = 0.00635\ X + 0.99998\ \epsilon \tag{5.5}
200
+ \end{align}
201
+
202
+ Since $\\alpha=0.0000403$ is very small, the corresponding standard deviation of GaussFun (Equation 3.4) reaches 157.52. However, the range of $X$ is limited within $[-1, 1]$, which is far smaller than the standard deviation of GaussFun. Within the range of $x \\in [-1, 1]$, GaussFun should be close to a constant, showing little variation. Therefore, the $q(x|z_T)$ corresponding to different $z_T$ are almost the same as $q(x)$. In this state, the posterior transform corresponding to $q(x|z_T)$ does not depend on the input distribution, the output distribution will always be $q(x)$.
203
+
204
+ <b>Therefore, theoretically, in the DDPM model, it is not necessary to use the standard normal distribution to replace $q(z_T)$. Any other arbitrary distributions can also be used as a substitute.</b>
205
+ """, latex_delimiters=g_latex_del, elem_classes="normal mds", elem_id="md_backward_process")
206
+ return
207
+
208
+
209
+ def md_fit_posterior_en():
210
+ global g_latex_del
211
+
212
+ title = "6. Fitting Posterior With Conditional Gaussian Model"
213
+ with gr.Accordion(label=title, elem_classes="first_md", elem_id="fit_posterior"):
214
+
215
+ gr.Markdown(
216
+ r"""
217
+ From the front part of Section 4, it is known that the posterior probability distributions are unknown and related to $q(x)$. Therefore, in order to recover the data distribution or sample from it, it is necessary to learn and estimate each posterior probability distribution.
218
+
219
+ From the latter part of Section 4, it can be understood that when certain conditions are met, each posterior probability distribution $q(x|z), q(z_{t-1}|z_t)$ approximates the Gaussian probability distribution. Therefore, by constructing a set of conditional Gaussian probability models $p(x|z), p(z_{t-1}|z_t)$, we can learn to fit the corresponding $q(x|z), q(z_{t-1}|z_t)$.
220
+
221
+ Due to the limitations of the model's representative and learning capabilities, there will be certain errors in the fitting process, which will further impact the accuracy of restored $q(x)$. The size of the fitting error is related to the complexity of the posterior probability distribution. As can be seen from Section 4, when $q(x)$ is more complex or the added noise is large, the posterior probability distribution will be more complex, and it will differ greatly from the Gaussian distribution, thus leading to fitting errors and further affecting the restoration of $q(x)$.
222
+
223
+ Refer to Demo 3.3 for the specifics. The reader can test different $q(x)$ and $\alpha$, observe the fitting degree of the posterior probability distribution $q(z_{t-1}|z_t)$ and the accuracy of restored $q(x)$. The restored probability distribution is marked with $\textcolor{orange}{\text{orange}}$, and the error is also indicated by JS divergence.
224
+
225
+ Regarding the objective function for fitting, similar to other probability models, the cross-entropy loss can be optimized to make $p(z_{t-1}|z_t)$ approaching $q(z_{t-1}|z_t)$. Since $(z_{t-1}|z_t)$ is a conditional probability, it is necessary to fully consider all conditions. This can be achieved By Averaging the cross-entropy corresponding to each condition weighted by the probability of each condition happening. The final form of the loss function is as follows.
226
+ \begin{align}
227
+ loss &= -\int q(z_t) \overbrace{\int q(z_{t-1}|z_t) \log \textcolor{blue}{p(z_{t-1}|z_t)}dz_{t-1}}^{\text{Cross Entropy}}\ dz_t \tag{6.1} \newline
228
+ &= -\iint q(z_{t-1},z_t) \log \textcolor{blue}{p(z_{t-1}|z_t)}dz_{t-1}dz_t \tag{6.2}
229
+ \end{align}
230
+
231
+ KL divergence can also be optimized as the objective function. KL divergence and cross-entropy are equivalent[\\[10\\]](#ce_kl)
232
+ <span id="en_fit_0">
233
+ loss &= \int q(z_t) KL(q(z_{t-1}|z_t)\|\textcolor{blue}{p(z_{t-1}|z_t)})dz_t \tag{6.3} \newline
234
+ &= \int q(z_t) \int q(z_{t-1}|z_t) \frac{q(z_{t-1}|z_t)}{\textcolor{blue}{p(z_{t-1}|z_t)}} dz_{t-1} dz_t \tag{6.4} \newline
235
+ &= -\int q(z_t)\ \underbrace{\int q(z_{t-1}|z_t) \log \textcolor{blue}{p(z_{t-1}|z_t)}dz_{t-1}}{underline}{\text{Cross Entropy}}\ dz_t + \underbrace{\int q(z_t) \int q(z_{t-1}|z_t) \log q(z_{t-1}|z_t)}{underline}{\text{Is Constant}} dz \tag{6.5}
236
+ </span>
237
+
238
+ The integral in equation 6.2 does not have a closed form and cannot be directly optimized. The Monte Carlo integration can be used for approximate calculation. The new objective function is as follows:
239
+ \begin{align}
240
+ loss &= -\iint q(z_{t-1},z_t) \log \textcolor{blue}{p(z_{t-1}|z_t)}dz_{t-1}dz_t \tag{6.6} \newline
241
+ &\approx -\sum_{i=0}^N \log \textcolor{blue}{p(Z_{t-1}^i|Z_t^i)} \qquad where \quad (Z_{t-1}^i,Z_t^i) \sim q(z_{t-1},z_t) \tag{6.7}
242
+ \end{align}
243
+
244
+ The aforementioned samples $(Z_{t-1}^i,Z_t^i)$ follow a joint probability distribution $q(z_{t-1},z_t)$, which can be sampled via an <b>Ancestral Sampling</b>. The specific method is as follows: sample $X,Z_1,Z_2 \dots Z_{t-1},Z_t$ step by step through forward transformation (Formulas 4.1~4.4), and then reserve $(Z_{t-1},Z_t)$ as a sample. This sampling process is relatively slow. To speed up the sampling, we can take advantage of the known features of the probability distribution $q(z_t|x)$ (Formula 4.8). First, sample $X$ from $q(x)$, then sample $Z_{t-1}$ from $q(z_{t-1}|x)$, and finally sample $Z_t$ from $q(z_t|z_{t-1})$. Thus, a sample $(Z_{t-1},Z_t)$ is obtained.
245
+
246
+ Some people may question that the objective function in Equation 6.3 seems different from those in the DPM[\\[1\\]](#dpm) and DDPM[\\[2\\]](#ddpm) papers. In fact, these two objective functions are equivalent, and the proof is given below.
247
+
248
+ For <b>Consistent Terms</b>, the proof is as follows:
249
+
250
+ \begin{align}
251
+ loss &= -\iint q(z_{t-1},z_t)\ \log \textcolor{blue}{p(z_{t-1}|z_t)}dz_{t-1}dz_t \tag{6.8} \newline
252
+ &= -\iint \int q(x)q(z_{t-1}, z_t|x)dx\ \log \textcolor{blue}{p(z_{t-1}|z_t)}dz_{t-1}dz_t \tag{6.9} \newline
253
+ &= \overbrace{\iint \int q(x)q(z_{t-1}, z_t|x) \log q(z_{t-1}|z_t,x)dxdz_{t-1}dz_t}^{\text{This Term Is Constant And Is Represented By}\ \textcolor{orange}{C_1}} \tag{6.10} \newline
254
+ &\quad - \iint \int q(x)q(z_{t-1}, z_t|x) \log \textcolor{blue}{p(z_{t-1}|z_t)}dxdz_{t-1}dz_t - \textcolor{orange}{C_1} \tag{6.11} \newline
255
+ &= \iint \int q(x)q(z_{t-1},z_t|x) \log \frac{q(z_{t-1}|z_t,x)}{\textcolor{blue}{p(z_{t-1}|z_t)}}dxdz_{t-1}dz_t - \textcolor{orange}{C_1} \tag{6.12} \newline
256
+ &= \iint q(x)q(z_t|x)\int q(z_{t-1}|z_t,x) \log \frac{q(z_{t-1}|z_t,x)}{\textcolor{blue}{p(z_{t-1}|z_t)}}dz_{t-1}\ dz_xdz_t - \textcolor{orange}{C_1} \tag{6.13} \newline
257
+ &= \iint \ q(x)q(z_t|x) KL[q(z_{t-1}|z_t,x)\|\textcolor{blue}{p(z_{t-1}|z_t)}]dxdz_t - \textcolor{orange}{C_1} \tag{6.14} \newline
258
+ &\propto \iint \ q(x)q(z_t|x) KL[q(z_{t-1}|z_t,x)\|\textcolor{blue}{p(z_{t-1}|z_t)}]dxdz_t \tag{6.15} \newline
259
+ \end{align}
260
+
261
+ In the above formula, the term $C_1$ is a fixed value, which does not contain parameters to be optimized. Here, $q(x)$ is a fixed probability distribution, and $q(z_{t-1}|z_t)$ is also a fixed probability distribution, whose specific form is determined by $q(x)$ and the coefficient $\alpha$.
262
+
263
+ For the <b>Reconstruction Term</b>, it can be proven in a similar way.
264
+
265
+ \begin{align}
266
+ loss &= -\int q(z_1)\overbrace{\int q(x|z_1)\log \textcolor{blue}{p(x|z_1)}dx}^{\text{Cross Entropy}}\ dz_1 \tag{6.16} \newline
267
+ &= -\iint q(z_1,x)\log \textcolor{blue}{p(x|z_1)}dxdz_1 \tag{6.17} \newline
268
+ &= -\int q(x)\int q(z_1|x)\log \textcolor{blue}{p(x|z_1)}dz_1\ dx \tag{6.18}
269
+ \end{align}
270
+
271
+ Therefore, the objective function in equation 6.1 is equivalent with the DPM original objective function.
272
+
273
+ Based on the conclusion of the Consistent Terms proof and the relationship between cross entropy and KL divergence, an interesting conclusion can be drawn:
274
+ <span id="en_fit_1">
275
+ \mathop{\min}{underline}{\textcolor{blue}{p}} \int q(z_t) KL(q(z_{t-1}|z_t)\|\textcolor{blue}{p(z_{t-1}|z_t)})dz_t \iff \mathop{\min}{underline}{\textcolor{blue}{p}} \iint \ q(x)q(z_t|x) KL[q(z_{t-1}|z_t,x)\|\textcolor{blue}{p(z_{t-1}|z_t)}]dxdz_t \tag{6.19}
276
+ </span>
277
+ By comparing the expressions on the left and right, it can be observed that the objective function on the right side includes an additional variable $X$ compared to the left side. At the same time, there is an additional integral with respect to $X$, with the occurrence probability of $X$, denoted as $q(x)$, serving as the weighting coefficient for the integral.
278
+
279
+ Following a similar proof method, a more general relationship can be derived:
280
+ <span id="en_fit_2">
281
+ \mathop{\min}{underline}{\textcolor{blue}{p}} KL(q(z)\|\textcolor{blue}{p(z)}) \iff \mathop{\min}_{\textcolor{blue}{p}} \int \ q(x) KL(q(z|x)\|\textcolor{blue}{p(z)})dx \tag{6.20}
282
+ </span>
283
+
284
+ """, latex_delimiters=g_latex_del, elem_classes="normal mds", elem_id="md_fit_posterior")
285
+ return
286
+
287
+
288
+ def md_posterior_transform_en():
289
+ global g_latex_del
290
+
291
+ with gr.Accordion(label="7. Posterior Transform", elem_classes="first_md", elem_id="posterior_transform"):
292
+
293
+ gr.Markdown(
294
+ r"""
295
+ <h3 style="font-size:18px"> Contraction Mapping and Converging Point </h3>
296
+ \begin{align}
297
+ q(x) &= \int q(x,z) dz = \int q(x|z)q(z)dz \tag{7.1}
298
+ \end{align}
299
+
300
+ Through extensive experiments with one-dimensional random variables, it was found that the <b>Posterior Transform</b> exhibits the characteristics of <b>Contraction Mapping</b>. This means that, for any two probability distributions $q_{i1}(z) and $q_{i2}(z), after posterior transform, we get $q_{o1}(x)$ and $q_{o2}(x)$. The distance between $q_{o1}(x)$ and $q_{o2}(x)$ is always less than the distance between $q_{i1}(x)$ and $q_{i2}(x)$. Here, the distance can be measured using JS divergence or Total Variance. Furthermore, the contractive ratio of this contraction mapping is positively related to the size of the added noise.
301
+ \begin{align}
302
+ dist(q_{o1}(z),\ q_{o2}(z)) < dist(q_{i1}(x),\ q_{i2}(x)) \tag{7.2}
303
+ \end{align}
304
+
305
+ Readers can refer to Demo 4.1, where the first three figure present a transform process. The first figure is an arbitrary data distribution $q(x)$, the third figure is the transformed probability distribution, and second figure is the posterior probability distribution $q(x|z)$. You can change the random seed to generate a new data distribution$q(x)$, and adjust the value of $\alpha$ to introduce different degrees of noise.
306
+
307
+ The last two figures show contraction of the transform. The fourth figure displays two randomly generated input distributions and their distance, $div_{in}$. The fifth figure displays the two output distributions after transform, with the distance denoted as $div_{out}$.
308
+
309
+ Readers can change the input random seed to toggle different inputs. It can be observed from the figures that $div_{in}$ is always smaller than $div_{out}$ for any input. Additionally, if you change the value of $\alpha$, you will see that the smaller the $\alpha$(larger noise), the smaller the ratio of $div_{out}/div_{in}$,indicating a larger rate of contraction.
310
+
311
+ According to the Banach fixed-point theorem<a href="#fixed_point">[5]</a>, a contraction mapping has a unique fixed point (converged point). That is to say, for any input distribution, the <b>Posterior Transform</b> can be applied continuously through iterations, and as long as the number of iterations is sufficient, the final output would be the same distribution. After a large number of one-dimensional random variable experiments, it was found that the fixed point (converged point) is <b>located near $q(x)$</b>. Also, the location is related to the value of $\alpha$; the smaller $\alpha$ (larger noise), the closer it is.
312
+
313
+ Readers can refer to Demo 4.2, which illustrates an example of applying posterior transform iteratively. Choose an appropriate number of iterations, and click on the button of <em>Apply</em>, and the iteration process will be draw step by step. Each subplot shows the transformed output distribution($\textcolor{green}{\text{green curve}}$) from each transform, with the reference distribution $q(x)$ expressed as a $\textcolor{blue}{\text{blue curve}}$, as well as the distance $div$ between the output distribution and $q(x)$. It can be seen that as the number of iterations increases, the output distribution becomes more and more similar to $q(x)$, and will eventually stabilize near $q(x)$. For more complicated distributions, more iterations or greater noise may be required. The maximum number of iterations can be set to tens of thousands, but it'll take longer.
314
+
315
+ For the one-dimensional discrete case, $q(x|z)$ is discretized into a matrix (denoted as $Q_{x|z}$), $q(z)$ is discretized into a vector (denoted as $\boldsymbol{q_i}$). The integration operation $\int q(x|z)q(z)dz$ is discretized into a **matrix-vector** multiplication operation, thus the posterior transform can be written as
316
+ \begin{align}
317
+ \boldsymbol{q_o} &= Q_{x|z}\ \boldsymbol{q_i} & \quad\quad &\text{1 iteration} \tag{7.3} \newline
318
+ \boldsymbol{q_o} &= Q_{x|z}\ Q_{x|z}\ \boldsymbol{q_i} & \quad\quad &\text{2 iteration} \tag{7.4} \newline
319
+ & \dots & \notag \newline
320
+ \boldsymbol{q_o} &= (Q_{x|z})^n\ \boldsymbol{q_i} & \quad\quad &\text{n iteration} \tag{7.5} \newline
321
+ \end{align}
322
+ In order to better understand the property of the transform, the matrix $(Q_{x|z})^n$ is also plotted in Demo 4.2. From the demo we can see that, as the iterations converge, the row vectors of the matrix $(Q_{x|z})^n$ will become a constant vector, that is, all components of the vector will be the same, which will appear as a horizontal line in the denisty plot.
323
+
324
+ <center> <img src="file/fig2.png" width="960" style="margin-top:12px"/> </center>
325
+ <center> Figure 2: Only one component in support </center>
326
+
327
+ The following will prove that with some conditions, the posterior transform is a contraction mapping, and there exists a unique point, which is also the converged point. The proof assumes that the random variable is discrete, so the posterior transform can be regarded as a single step transition of a <b>discrete Markov Chain</b>. The posterior $q(x|z)$ corresponds to the <b>transfer matrix</b>. Continuous variables can be considered as discrete variables with infinite states.
328
+ <ol style="list-style-type:decimal">
329
+ <li> When $q(x)$ is greater than 0, the posterior transform matrix $q(x|z)$ will be greater than 0 too. Therefore, this matrix is the transition matrix of an $\textcolor{red}{\text{irreducible}}\ \textcolor{green}{\text{aperiodic}}$ Markov Chain. According to the conclusion of the literature <a href="#mc_basic_p6">[13]</a>, this transformation is a contraction mapping with respect to Total Variance metric. Therefore, according to the Banach fixed-point theorem, this transformation has a unique fixed point(converged point). </li>
330
+
331
+ <li> When $q(x)$ is partially greater than 0, and the support of $q(x)$ (the region where $q(x)$ is greater than 0) consists only one connected component (Figure 2), several conclusions can be drawn from equation (3.4):
332
+
333
+ <ol style="list-style-type:lower-alpha; padding-inline-start: 0px;font-size:16px;">
334
+ <li> When $z$ and $x$ are within the support set, since both $q(x)$ and GaussFun are greater than 0, the diagonal elements of the transfer matrix $\\{q(x|z)|z=x\\}$ are greater than 0. This means that the state within the support set is $\textcolor{green}{\text{aperiodic}}$. </li>
335
+
336
+ <li> When $z$ and $x$ are within the support set, since GaussFun's support set has a certain range, elements above and below the diagonal $\{q(x|z)|x=z+\epsilon\}$is also greater than 0. This means that states within the support set are accessible to each other, forming a $\textcolor{red}{\text{Communication Class}}$<a href="#mc_basic_d4">[14]</a>, see in Figure 2b. </li>
337
+
338
+ <li> When <em>$z$ is within the support set</em> and <em>$x$ is outside the support set</em>, ${q(x|z)}$ is entirely 0. This means that the state within the support set is <em>inaccessible</em> to the state outside the support set (Inaccessible Region in Figure 2b) </li>
339
+
340
+ <li> When <em>$z$ is outside the support set</em> and <em>$x$ is inside the support set</em>, due to the existence of a certain range of the support set of GaussFun, there are some extension areas (Extension Region in Figure 2b), where the corresponding $\{q(x|z)|x \in support\}$ is not all zero. This means that the state of this part of the extension area can <em>unidirectionally</em> access (access) the state inside the support set (Unidirectional Region in Figure 2b).</li>
341
+
342
+ <li> When <em>$z$ is outside the support set</em> and <em>$x$ is outside the support set</em>, the corresponding $q(x|z)$ is entirely zero. This implies that, states outside the support set will not transit to states outside the support set. In other words, states outside the support set only originate from states within the support set. </li>
343
+
344
+ </ol>
345
+ <p style="margin-top:8px">
346
+ From (c), we know that states within the support set will not transition to states outside of the support set. From (a) and (b), we know that the states within the support set are non-periodic and form a Communicate Class. Therefore, the states within the support set independently form an irreducible and non-periodic Markov Chain. According to the conclusion of Theorem 11.4.1 in reference <a href="#mc_limit">[7]</a>, as $n\to\infty$, $q(x|z)^n$ will converge to a constant matrix, with each column vector in the matrix being identical. This implies that for different values of z, $q(x|z)^n$ are the same (as seen in Figure 2c). In Addition, according to (d) and (e), there exist some states z, which are outside of the support set, that can transition into the support set and will carry information from within the support set back to the outside. Thus, the corresponding $q(x|z)^n$ for these z states (the $q(x|z_{ex})$ region in Figure 2c) will equal the corresponding $q(x|z)^n$ in the support set (the $q(x|z_{sup})$ region in Figure 2c).
347
+ </p>
348
+
349
+ <p style="margin-top:8px">
350
+ Therefore, it can be concluded that when the state is confined within the support set and two extension regions, $\lim_{n\to\infty}{q(x|z)^n}$ will converge to a fixed matrix, and each column vector is identical. Hence, for any input distribution, if posterior transforms are continuously applied, it will eventually converge to a fixed distribution, which is equal to the column vector of the converged matrix. Based on the conclusion from the literature <a href=\"#fp_converse\">[9]</a>, when a iterative transform converges to a unique fixed point, this transform is a Contraction Mapping with respect to a certain metric.
351
+ </p>
352
+ </li>
353
+
354
+ <li> When $q(x)$ is partially greater than 0, and multiple connected component exist in the support set of $q(x)$, and the maximum distance of each connected component <b>can</b> be covered by the support set of corresponding GaussFun, the states within each connected domain <b>constitute only one Communicate Class</b>. As shown in Figure 3, $q(x)$ has two connected component. On the edge of the first component, the support set of GaussFun corresponding to $q(x|z=-0.3)$ can span the gap to reach the second component, so the states of the first component can <em>access</em> the states of the second component. On the edge of the second component, the support set of GaussFun corresponding to $q(x|z=0)$ can also span the gap to reach the first. Thus, the states of the second component can <em>access</em> the states of the first component, so these two component form a Communicate Class. Therefore, similar to the case with a single component, when states are confined to each component, gaps, and extension areas, the posterior transform has a unique iterative convergence point, which is a contraction mapping with respect to a certain metric. </li>
355
+
356
+ <li> When $q(x)$ is partially greater than 0, and multiple connected component exist in the support set of $q(x)$, and the maximum distance of each connected component <b>cannot</b> be covered by the support set of corresponding GaussFun, the states within each component <b>constitute multiple Communicate Classes</b>, as shown in Figure 4. Under such circumstances, as $n\to\infty$, $q(x|z)^n$ will also converge to a fixed matrix, but not all the column vectors are identical. Therefore, the posterior transforma is not a strict contraction mapping. However, when the state of the input distribution is confined to a single Communicate Class and its corresponding extension, the posterior transform is also a contraction mapping with a unique convergence point. </li>
357
+ </ol>
358
+
359
+ <center> <img src="file/fig3.png" width="960" style="margin-top:12px"/> </center>
360
+ <center> Figure 3: Two components which can communicate with each other </center>
361
+
362
+ <center> <img src="file/fig4.png" width="960" style="margin-top:12px"/> </center>
363
+ <center> Figure 4: Two components which <b>cannot</b> communicate with each other </center>
364
+
365
+ Additionally, there exists a more generalized relation about the posterior transform that is independent of $q(x|z)$: the Total Variance distance between two output distributions will always be <b>less than or equal to</b> the Total Variance distance between their corresponding input distributions, that is
366
+ \begin{align}
367
+ dist(q_{o1}(x),\ q_{o2}(x)) <= dist(q_{i1}(z),\ q_{i2}(z)) \notag
368
+ \end{align}
369
+ The proof is given below in discrete form:
370
+ \begin{align}
371
+ \lVert q_{o1}-q_{o2}\rVert_{TV} &= \lVert Q_{x|z}q_{i1} - Q_{x|z}q_{i2}\rVert_{TV} \tag{7.6} \newline
372
+ &= \sum_{m}\textcolor{red}{|}\sum_{n}Q_{x|z}(m,n)q_{i1}(n) - \sum_{n}Q_{x|z}(m,n)q_{i2}(n)\textcolor{red}{|} \tag{7.7} \newline
373
+ &= \sum_{m}\textcolor{red}{|}\sum_{n}Q_{x|z}(m,n)(q_{i1}(n) - q_{i2}(n))\textcolor{red}{|} \tag{7.8} \newline
374
+ &\leq \sum_{m}\sum_{n}Q_{x|z}(m,n)\textcolor{red}{|}(q_{i1}(n) - q_{i2}(n))\textcolor{red}{|} \qquad \qquad \qquad \text{Absolute value inequality} \tag{7.9} \newline
375
+ &= \sum_{n}\textcolor{red}{|}(q_{i1}(n) - q_{i2}(n))\textcolor{red}{|} \sum_{m} Q_{x|z}(m,n) \qquad \qquad \qquad \sum_{m} Q_{x|z}(m,n) = 1 \tag{7.10} \newline
376
+ &= \sum_{n}\textcolor{red}{|}(q_{i1}(n) - q_{i2}(n))\textcolor{red}{|} \tag{7.11}
377
+ \end{align}
378
+ In this context, $Q_{x|z}(m,n)$ represents the element at the m-th row and n-th column of the matrix $Q_{x|z}$, and $q_{i1}(n)$ represents the n-th element of the vector $q_{i1}$.
379
+
380
+ The relationship between the converged distribution and the input distribution q(x) cannot be rigorously proven at present.
381
+
382
+ <h3 style="font-size:18px"> Anti-noise Capacity In Restoring Data Distribution</h3>
383
+ From the above analysis, we know that when certain conditions are satisfied, the <em>posterior transform</em> is a contraction mapping. Therefore, the following relationship exists:
384
+ \begin{align}
385
+ dist(q(x),\ q_o(x)) < dist(q(z),\ q_i(z)) \tag{7.12}
386
+ \end{align}
387
+ Wherein, $q(z)$ is the ideal input distribution, $q(x)$ is the ideal output distribution, $q_i(x)$ is any arbitrary input distribution, and $q_o(x)$ is the output distribution obtained after transforming $q_i(z)$.
388
+
389
+ The above equation indicates that the distance between the output distribution $q_o(x)$ and the ideal output distribution q(x) will always be <b>less than</b> the distance between the input distribution $q_i(z)$ and the ideal input distribution q(x). Hence, the <em>posterior transform</em> has certain resistance to noise. This means that during the process of restoring $q(x)$(Section 5), even if the <em>tail distribution</em> $q(z_T)$ contains some error, the error of the outputed distribution $q(x)$ will be smaller than the error of input after undergoing a series of transform.
390
+
391
+ Refer specifically to Demo 3.2, where by increasing the value of the <b>noise ratio</b>, noise can be added to the <em>tail distribution</em> $q(z_T)$. Clicking the "apply" button will gradually draw out the restoring process, with the restored distribution represented by a $\textcolor{red}{\text{red curve}}$, and the error size will be computed by the JS divergence. You will see that the error of restored $q(x)$ is always less than the error of $q(z_T)$.
392
+
393
+ From the above discussion, we know that the smaller the $\alpha$ (the larger the noise used in the transform process), the greater the contractive ratio of the contraction mapping, and thus, the stronger the ability to resist noise.
394
+
395
+ """, latex_delimiters=g_latex_del, elem_classes="normal mds", elem_id="md_posterior_transform")
396
+ return
397
+
398
+
399
+ def md_deconvolution_en():
400
+ global g_latex_del
401
+
402
+ title = "8. Can the data distribution be restored by deconvolution?"
403
+ with gr.Accordion(label=title, elem_classes="first_md", elem_id="deconvolution"):
404
+ gr.Markdown(
405
+ r"""
406
+ As mentioned in the section 2, the transformation of Equation 2.1 can be divided into two sub-transformations, the first one being a linear transformation and the second being adding independent Gaussian noise. The linear transformation is equivalent to a scaling transform of the probability distribution, so it has an inverse transformation. Adding independent Gaussian noise is equivalent to the execution of a convolution operation on the probability distribution, which can be restored through <b>deconvolution</b>. Therefore, theoretically, the data distribution $q(x)$ can be recovered from the final probability distribution $q(z_T)$ through <b>inverse linear transform</b> and <b>deconvolution</b>.
407
+
408
+ However, in actuality, some problems do exist. Due to the extreme sensitivity of deconvolution to errors, having high input sensitivity, even a small amount of input noise can lead to significant changes in output[\[11\]](#deconv_1)[\[12\]](#deconv_2). Meanwhile, in the diffusion model, the standard normal distribution is used as an approximation to replace $q(z_T)$, thus, noise is introduced at the initial stage of recovery. Although the noise is relatively small, because of the sensitivity of deconvolution, the noise will gradually amplify, affecting the recovery.
409
+
410
+ In addition, the infeasibility of <b>deconvolution restoring</b> can be understood from another perspective. Since the process of forward transform (equations 4.1 to 4.4) is fixed, the convolution kernel is fixed. Therefore, the corresponding deconvolution transform is also fixed. Since the initial data distribution $q(x)$ is arbitrary, any probability distribution can be transformed into an approximation of $\mathcal{N}(0,I)$ through a series of fixed linear transforms and convolutions. If <b>deconvolution restoring</b> is feasible, it means that a fixed deconvolution can be used to restore any data distribution $q(x)$ from the $\mathcal{N}(0,I)$ , this is clearly <b>paradoxical</b>. The same input, the same transform, cannot have multiple different outputs.
411
+ """, latex_delimiters=g_latex_del, elem_classes="normal mds", elem_id="md_deconvolution")
412
+ return
413
+
414
+
415
+ def md_reference_en():
416
+ global g_latex_del
417
+
418
+ with gr.Accordion(label="Reference", elem_classes="first_md", elem_id="reference"):
419
+
420
+ gr.Markdown(
421
+ r"""
422
+ <a id="dpm" href="https://arxiv.org/abs/1503.03585"> [1] Deep Unsupervised Learning Using Nonequilibrium Thermodynami </a>
423
+
424
+ <a id="ddpm" href="https://arxiv.org/abs/1503.03585"> [2] Denoising Diffusion Probabilistic Models </a>
425
+
426
+ <a id="linear_transform" href="https://stats.libretexts.org/Bookshelves/Probability_Theory/Probability_Mathematical_Statistics_and_Stochastic_Processes_(Siegrist)/03%3A_Distributions/3.07%3A_Transformations_of_Random_Variables"> [3] Linear Transformations of Random Variable </a>
427
+
428
+ <a id="sum_conv" href="https://stats.libretexts.org/Bookshelves/Probability_Theory/Probability_Mathematical_Statistics_and_Stochastic_Processes_(Siegrist)/03%3A_Distributions/3.07%3A_Transformations_of_Random_Variables"> [4] Sums and Convolution </a>
429
+
430
+ <a id="fixed_point" href="https://en.wikipedia.org/wiki/Banach_fixed-point_theorem"> [5] Banach fixed-point theorem </a>
431
+
432
+ <a id="ctr" href="https://en.wikipedia.org/wiki/Contraction_mapping"> [6] Contraction mapping </a>
433
+
434
+ <a id="mc_limit" href="https://stats.libretexts.org/Bookshelves/Probability_Theory/Book%3A_Introductory_Probability_(Grinstead_and_Snell)/11%3A_Markov_Chains/11.04%3A_Fundamental_Limit_Theorem_for_Regular_Chains"> [7] Fundamental Limit Theorem for Regular Chains </a>
435
+
436
+ <a id="mc_basic_p6" href="http://galton.uchicago.edu/~lalley/Courses/312/MarkovChains.pdf"> [8] Markov Chain:Basic Theory - Proposition 6 </a>
437
+
438
+ <a id="fp_converse" href="https://arxiv.org/abs/1702.07339"> [9] A Converse to Banach's Fixed Point Theorem and its CLS Completeness </a>
439
+
440
+ <a id="ce_kl" href="https://en.wikipedia.org/wiki/Cross-entropy#Cross-entropy_minimization"> [10] Cross-entropy minimization </a>
441
+
442
+ <a id="deconv_1" href="https://thewolfsound.com/deconvolution-inverse-convolution/"> [11] Deconvolution Using Frequency-Domain Division </a>
443
+
444
+ <a id="deconv_2" href="https://www.strollswithmydog.com/deconvolution-by-division-in-the-frequency-domain/"> [12] deconvolution-by-division-in-the-frequency-domain </a>
445
+
446
+ <a id="mc_basic_t7" href="http://galton.uchicago.edu/~lalley/Courses/312/MarkovChains.pdf"> [13] Markov Chain:Basic Theory - Theorem 7 </a>
447
+
448
+ <a id="mc_basic_d4" href="http://galton.uchicago.edu/~lalley/Courses/312/MarkovChains.pdf"> [14] Markov Chain:Basic Theory - Definition 4 </a>
449
+
450
+ """, latex_delimiters=g_latex_del, elem_classes="normal mds", elem_id="md_reference")
451
+
452
+ return
453
+
454
+
455
+ def md_about_en():
456
+ global g_latex_del
457
+
458
+ with gr.Accordion(label="About", elem_classes="first_md", elem_id="about"):
459
+
460
+ gr.Markdown(
461
+ r"""
462
+ <b>APP</b>: This APP is developed using Gradio and deployed on HuggingFace. Due to limited resources (2 cores, 16G memory), the response may be slow. For a better experience, it is recommended to clone the source code from <a href="https://github.com/blairstar/The_Art_of_DPM">github</a> and run it locally. This program only relies on Gradio, SciPy, and Matplotlib.
463
+
464
+ <b>Author</b>: Zhenxin Zheng, Senior computer vision engineer with ten years of algorithm development experience, Formerly employed by Tencent and JD.com, currently focusing on image and video generation.
465
+
466
+ <b>Email</b>: [email protected].
467
+ """, latex_delimiters=g_latex_del, elem_classes="normal mds", elem_id="md_about")
468
+
469
+ return
470
+
471
+
472
+ def run_app():
473
+
474
+ # with gr.Blocks(css=g_css, js="() => { insert_special_formula(); }", head=js_head) as demo:
475
+ with gr.Blocks(css=g_css, js="() => {insert_special_formula(); write_markdown();}", head=js_head) as demo:
476
+ md_introduction_en()
477
+
478
+ md_transform_en()
479
+
480
+ md_likelihood_en()
481
+
482
+ md_posterior_en()
483
+
484
+ md_forward_process_en()
485
+
486
+ md_backward_process_en()
487
+
488
+ md_fit_posterior_en()
489
+
490
+ md_posterior_transform_en()
491
+
492
+ md_deconvolution_en()
493
+
494
+ md_reference_en()
495
+
496
+ md_about_en()
497
+
498
+ demo.launch(allowed_paths=["/"])
499
+
500
+ return
501
+
502
+
503
+ if __name__ == "__main__":
504
+ run_app()
RenderMarkdownZh.py ADDED
@@ -0,0 +1,493 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ import gradio as gr
3
+ from Misc import g_css, g_latex_del, js_head
4
+
5
+
6
+ def md_introduction_zh():
7
+ global g_latex_del
8
+
9
+ with gr.Accordion(label="0. Introduction", elem_classes="first_md", elem_id="introduction"):
10
+
11
+ gr.Markdown(
12
+ f"""
13
+ 扩散模型[\[1\]](#dpm)[\[2\]](#ddpm)是当前图像生成和视频生成使用的主要方式,但由于其晦涩的理论,很多工程师并不能很好地理解。本文将提供一种非常直观易懂的方式,方便读者理解把握扩散模型的原理。特别地,将以互动的形式,以一维随机随机变量的扩散模型进行举例,直观解释扩散模型的多个有趣的性质。
14
+
15
+ 扩散模型是一个概率模型。概率模型主要提供两方面的功能:计算给定样本出现的概率;采样生成新样本。扩散模型侧重于第二方面,方便采样新样本,从而实现"生成"的任务。
16
+
17
+ 扩散模型与一般的概率模型(如GMM)不同,直接建模随机变量的概率分布。扩散模型采用一种间接方式,利用“随机变量变换”的方式(如图1a),逐步将待建模的概率分布(数据分布)转变成"标准正态分布",同时,建模学习各个变换对应的后验概率分布(图1b-c)。有了最终的标准正态分布和各个后验概率分布,则可通过祖先采样的方式,从反向逐步采样得到各个随机变量$Z_T \ldots Z_2,Z_1,X$的样本。同时也可通过贝叶斯公式和全概率公式确定初始的数据分布$q(x)$。
18
+
19
+ 可能会有这样的疑问:间接的方式需要建模学习T个后验概率分布,直接方式只需要建模学习一个概率分布,为什么要选择间接的方式呢?是这样子的:初始的数据分布可能很复杂,很难用一个概率模型直接表示;而对于间接的方式,各个后验概率分布的复杂度会简单许多,可以用简单的概率模型进行拟合。下面将会看到,当满足一些条件时,后验概率分布将非常接近高斯分布,所以可以使用简单的条件高斯模型进行建模。
20
+
21
+ <center> <img src="file/pipe.jpg" width="820" style="margin-top:12px"/> </center>
22
+ <center> Figure 1: Diffusion model schematic </center>
23
+ """, latex_delimiters=g_latex_del, elem_classes="normal mds", elem_id="md_introduction")
24
+ return
25
+
26
+
27
+ def md_transform_zh():
28
+ global g_latex_del
29
+
30
+ with gr.Accordion(label="1. How To Transform", elem_classes="first_md", elem_id="transform"):
31
+
32
+ gr.Markdown(
33
+ r"""
34
+ 为了将初始的数据分布转换为简单的标准正态分布,扩散模型采用如下的变换方式
35
+ \begin{align}
36
+ Z = \sqrt{\alpha} X + \sqrt{1-\alpha}\epsilon \qquad where \quad \alpha < 1, \quad \epsilon \sim \mathcal{N}(0, I) \tag{1.1}
37
+ \end{align}
38
+ 其中$X\sim q(x)$是任意的随机变量,$Z\sim q(Z)$是变换后的随机变量。
39
+
40
+ 此变换可分为两个子变换。
41
+
42
+ 第一个子变换是对随机变量$X$执行一个线性变换($\sqrt{\alpha}X$),根据文献[\[3\]](#linear_transform)的结论,线性变换使$X$的概率分布“变窄变高”,并且"变窄变高"的程度与$\alpha$的值成正比;具体可看Demo 1,左1图为随机生成的一维的概率分布,左2图是经过线性变换后的概率分布,可以看出,与左1图相比,左2图的曲线“变窄变高”了。读者可亲自测试不同的$\alpha$值,获得更直观的理解。
43
+
44
+ 第二个子变换是“加上独立的随机噪声”($\sqrt{1-\alpha}\epsilon$),根据文献[\[4\]](#sum_conv)的结论,“加上独立的随机变量”等效于对两个概率分布执行卷积,由于随机噪声的概率分布为高斯形状,所以相当于执行”高斯模糊“的操作。经过模糊后,原来的概率分布将变得更加平滑,与标准正态分布将更加相似。模糊的程度与噪声大小($1-\alpha$)正相关。具体可看Demo 1,左1图是随机生成的一维概率分布,左3图是经过变换后的结果,可以看出,变换后的曲线变光滑了,棱角变少了。读者可测试不同的$\alpha$值,感受噪声大小对概率分布曲线形状的影响。左4图是综合两个子变换后的结果。
45
+ """, latex_delimiters=g_latex_del, elem_classes="normal mds", elem_id="md_transform")
46
+ return
47
+
48
+
49
+ def md_likelihood_zh():
50
+ global g_latex_del
51
+
52
+ with gr.Accordion(label="2. Likelihood of The Transform", elem_classes="first_md", elem_id="likelihood"):
53
+
54
+ gr.Markdown(
55
+ r"""
56
+ 由变换的方式(式1.1)可以看出,前向条件概率$q(z|x)$的概率分布为高斯分布,且只与$\alpha$的值有关,与$q(x)$的概率分布无关。
57
+ \begin{align}
58
+ q(z|x) &= \mathcal{N}(\sqrt{\alpha}x,\ 1-\alpha) \tag{2.1}
59
+ \end{align}
60
+ 具体可看Demo 2,左3图展示了$q(z|x)$的形状,从图中可以看到一条均匀的斜线,这意味着$q(z|x)$的均值与x线性相关,方差固定不变。$\alpha$值的大小将决定斜线宽度和倾斜程度。
61
+ """, latex_delimiters=g_latex_del, elem_classes="normal mds", elem_id="md_likelihood")
62
+ return
63
+
64
+
65
+ def md_posterior_zh():
66
+ global g_latex_del
67
+
68
+ with gr.Accordion(label="3. Posterior of The Transform", elem_classes="first_md", elem_id="posterior"):
69
+
70
+ gr.Markdown(
71
+ r"""
72
+ 后验概率分布没有闭合的形式,但可以通过一些方法,推断其大概的形状,并分析影响其形状的因素。
73
+
74
+ 根据Bayes公式,有
75
+ \begin{align}
76
+ q(x|z) = \frac{q(z|x)q(x)}{q(z)} \tag{3.1}
77
+ \end{align}
78
+
79
+ 当$z$是取固定值时,$q(z)$是常数,所以$q(x|z)$的形状只与${q(z|x)q(x)}$有关。
80
+ \begin{align}
81
+ q(x|z) \propto q(z|x)q(x) \qquad where\ z\ is\ fixed \tag{3.2}
82
+ \end{align}
83
+ 由式2.1可知,$q(z|x)$为高斯分布,于是有
84
+ \begin{align}
85
+ q(x|z) &\propto \frac{1}{\sqrt{2\pi(1-\alpha)}}\exp{\frac{-(z-\sqrt{\alpha}x)^2}{2(1-\alpha)}}\ q(x)& \qquad &where\ z\ is\ fixed \tag{3.3} \newline
86
+ &= \frac{1}{\sqrt{\alpha}} \underbrace{\frac{1}{\sqrt{2\pi}\sigma}\exp{\frac{-(x-\mu)^2}{2\sigma^2}}}_{\text{GaussFun}}\ q(x)& \qquad &where\ \mu=\frac{z}{\sqrt{\alpha}}\quad \sigma=\sqrt{\frac{1-\alpha}{\alpha}} \tag{3.4}
87
+ \end{align}
88
+
89
+ 可以看出,<b>GaussFun</b>部分是关于$x$的高斯函数,均值为$\frac{z}{\sqrt{\alpha}}$,方差为$\sqrt{\frac{1-\alpha}{\alpha}}$,所以$q(x|z)$的形状由“<b>GaussFun与$q(x)$相乘</b>”决定。
90
+
91
+ 根据”乘法“的特点,可以总结$q(x|z)$函数形状具有的特点。
92
+ <ul>
93
+ <li> 当高斯函数的方差较小(较小噪声),或者$q(x)$变化缓慢时,$q(x|z)$的形状将近似于高斯函数,函数形式较简单,方便建模学习。</li>
94
+ <li> 当高斯函数的方差较大(较大噪声),或者$q(x)$剧烈变化时,$q(x|z)$的形状将较复杂,与高斯函数有较大的差别,难以建模学习。</li>
95
+ </ul>
96
+
97
+ 具体可看Demo 2,左4图给出后验概率分布$q(x|z)$的形态,可以看出,其形状较不规则,像一条弯曲且不均匀的曲线。当$\alpha$较大时(噪声较小),曲线将趋向于均匀且笔直。读者可调整不同的$\alpha$值,观察后验概率分布与噪声大小的关系;左5图,$\textcolor{blue}{蓝色虚线}$给出$q(x)$,$\textcolor{green}{绿色虚线}$给出式3.4中的GaussFun,$\textcolor{orange}{黄色实线}$给出两者相乘并归一化的结果,即固定z条件下后验概率$q(x|z=fixed)$。读者可调整不同z值,观察$q(x)$的波动变化对后验概率$q(x|z)$形态的影响。
98
+
99
+ 两个特殊状态下的后验概率分布$q(x|z)$值得考虑一下。
100
+ <ul>
101
+ <li> 当$\alpha \to 0$时,GaussFun的方差趋向于<b>无穷大</b>,不同$z$值的$q(x|z)$几乎变成一致,并与$q(x)$几乎相同。读者可在Demo 2中,将$\alpha$设置为0.01,观察具体的结果。</li>
102
+ <li> 当$\alpha \to 1$时,GaussFun的方差趋向于<b>无穷小</b>,不同$z$值的$q(x|z)$收缩成一系列不同偏移量的Dirac delta函数, 偏移量等于$z$。但有一些例外,当q(x)存在为零的区域时,其对应的q(x|z)将不再为Dirac delta函数,而是零函数。可在Demo 2中,将$\alpha$设置为0.999,观察具体的结果。</li>
103
+ </ul>
104
+ """, latex_delimiters=g_latex_del, elem_classes="normal mds", elem_id="md_posterior")
105
+ return
106
+
107
+
108
+ def md_forward_process_zh():
109
+ global g_latex_del
110
+
111
+ title = "4. Transform Data Distribution To Normal Distribution"
112
+ with gr.Accordion(label=title, elem_classes="first_md", elem_id="forward_process"):
113
+
114
+ gr.Markdown(
115
+ r"""
116
+ 对于任意的数据分布$q(x)$,均可连续应用上述的变换(如式4.1~4.4),随着变换的次数的增多,输出的概率分布将变得越来越接近于标准正态分布。对于较复杂的数据分布,需要较多的次数或者较大的噪声。
117
+
118
+ 具体可看Demo 3.1,第一子图是随机生成的一维概率分布,经过7次的变换后,最终的概率分布与标准正态分布非常相似。相似的程度与迭代的次数和噪声大小正相关。对于相同的相似程度,如果每次所加的噪声较大(较小的$\alpha$值),那所需变换的次数将较少。读者可尝试不同的$\alpha$值和次数,观测最终概率分布的相似程度。
119
+
120
+ 起始概率分布的复杂度会比较高,随着变换的次数增多,概率分布$q(z_t)$的复杂度将会下降。根据第3节结论,更复杂的概率分布对应更复杂的后验概率分布,所以,为了保证后验概率分布与高斯函数较相似(较容易学习),在起始阶段,需使用较大的$\alpha$(较小的噪声),后期阶段可适当使用较小的$\alpha$(较大的噪声),加快向标准正态分布转变。
121
+
122
+ 在Demo3的例子可以看到,随着变换次数增多,$q(z_t)$的棱角变得越来越少,同时,后验概率分布$q(z_{t-1}|z_t)$图中的斜线变得越来越笔直匀称,越来越像条件高斯分布。
123
+
124
+ \begin{align}
125
+ Z_1 &= \sqrt{\alpha_1} X + \sqrt{1-\alpha_1}\epsilon_1 \tag{4.1} \newline
126
+ Z_2 &= \sqrt{\alpha_2} Z_1 + \sqrt{1-\alpha_2}\epsilon_2 \tag{4.2} \newline
127
+ &\dots \notag \newline
128
+ Z_{t} &= \sqrt{\alpha_t}Z_{t-1} + \sqrt{1-\alpha_t}\epsilon_{t} \tag{4.3} \newline
129
+ &\dots \notag \newline
130
+ Z_{T} &= \sqrt{\alpha_T}Z_{T-1} + \sqrt{1-\alpha_T}\epsilon_{T} \tag{4.4} \newline
131
+ &where \quad \alpha_t < 1 \qquad t\in {1,2,\dots,T} \notag
132
+ \end{align}
133
+
134
+ 把式4.1代入式4.2,同时利用高斯分布的性质,可得出$q(z_2|x)$的概率分布的形式
135
+ \begin{align}
136
+ z_2 &= \sqrt{\alpha_2}(\sqrt{\alpha_1}x + \sqrt{1-\alpha_1}\epsilon_1) + \sqrt{1-\alpha_2}\epsilon_2 \tag{4.5} \newline
137
+ &= \sqrt{\alpha_2\alpha_1}x + \sqrt{\alpha_2-\alpha_2\alpha_1}\epsilon_1 + \sqrt{1-\alpha_2}\epsilon_2 \tag{4.6} \newline
138
+ &= \mathcal{N}(\sqrt{\alpha_1\alpha_2}x,\ 1-\alpha_1\alpha_2) \tag{4.7}
139
+ \end{align}
140
+
141
+ 同理,可递推得出
142
+ \begin{align}
143
+ q(z_t|x) &= \mathcal{N}(\sqrt{\alpha_1\alpha_2\cdots\alpha_t}x,\ 1-\alpha_1\alpha_2\cdots\alpha_t) = \mathcal{N}(\sqrt{\bar{\alpha_t}}x,\ 1-\bar{\alpha_t}) \qquad where\ \bar{\alpha_t} \triangleq \prod_{j=1}^t\alpha_j \tag{4.8}
144
+ \end{align}
145
+
146
+ 比较式4.8和式2.1的形式,可发现,两者的形式是完全一致的。如果只关注最终变换后的分布$q(z_t)$,那么连续t次的小变换可用一次大变换替代,大变换的$\alpha$是各个小变换的$\alpha$累积。
147
+
148
+ 在DDPM[\[2\]](#ddpm)论文中,作者使用了1000步(T=1000),将数据分布$q(x)$转换至$q(z_T)$,$q(z_T|x)$的概率分布如下:
149
+ \begin{align}
150
+ q(z_T|x) &= \mathcal{N}(0.00635\ x,\ 0.99998) \tag{4.9}
151
+ \end{align}
152
+
153
+ 如果只考虑$q(z_T)$,也可使用一次变换代替,变换如下:
154
+ \begin{align}
155
+ Z_T = \sqrt{0.0000403}\ X + \sqrt{1-0.0000403}\ \epsilon = 0.00635\ X + 0.99998\ \epsilon \tag{4.10}
156
+ \end{align}
157
+ 可以看出,应用两种变换后,变换后的分布$q(z_T|x)$相同,因此,$q(z_T)$也相同。
158
+ """, latex_delimiters=g_latex_del, elem_classes="normal mds", elem_id="md_forward_process")
159
+ return
160
+
161
+
162
+ def md_backward_process_zh():
163
+ global g_latex_del
164
+
165
+ title = "5. Restore Data Distribution From Normal Distribution"
166
+ with gr.Accordion(label=title, elem_classes="first_md", elem_id="backward_process"):
167
+
168
+ gr.Markdown(
169
+ r"""
170
+ 如果知道了最终的概率分布$q(z_T)$及各个转换过程的后验概率$q(x|z),q(z_{t-1}|z_t)$,则可通过“贝叶斯公式”和“全概率公式”恢复数据分布$q(x)$,见式5.1~5.4。当最终的概率分布$q(z_T)$与标准正态分布很相似时,可用标准正态分布代替。
171
+
172
+ 具体可看Demo 3.2。示例中$q(z_T)$使用$\mathcal{N}(0,1)$代替,同时通过JS Div给出了误差大小。恢复的概率分布$q(z_t)$及$q(x)$使用$\textcolor{green}{绿色曲线}$标识,原始的概率分布使用$\textcolor{blue}{蓝色曲线}$标识。可以看出,数据分布$q(x)$能够被很好地恢复回来,并且误差(JS Divergence)会小于标准正态分布替换$q(z_T)$引起的误差。
173
+ \begin{align}
174
+ q(z_{T-1}) &= \int q(z_{T-1},z_T)dz_T = \int q(z_{T-1}|z_T)q(z_T)dz_T \tag{5.1} \newline
175
+ & \dots \notag \newline
176
+ q(z_{t-1}) &= \int q(z_{t-1},z_t)dz_t = \int q(z_{t-1}|z_t)q(z_t)dz_t \tag{5.2} \newline
177
+ & \dots \notag \newline
178
+ q(z_1) &= \int q(z_1,z_2) dz_1 = \int q(z_1|z_2)q(z_2)dz_2 \tag{5.3} \newline
179
+ q(x) &= \int q(x,z_1) dz_1 = \int q(x|z_1)q(z_1)dz_1 \tag{5.4} \newline
180
+ \end{align}
181
+ 在本文中,将上述恢复过程(式5.1~5.4)��使用的变换称之为“后验概率变换”。例如,在式5.4中,变换的输入为概率分布函数$q(z_1)$,输出为概率分布函数$q(x)$,整个变换由后验概率分布$q(x|z_1)$决定。此变换也可看作为一组基函数的线性加权和,基函数为不同条件下的$q(x|z_1)$,各个基函数的权重为$q(z_1)$。在第7节,将会进一步介绍此变换的一些有趣性质。
182
+
183
+ 在第3节中,我们考虑了两个特殊的后验概率分布。接下来,分析其对应的”后验概率变换“。
184
+ <ul>
185
+ <li> 当$\alpha \to 0$时,不同$z$值的$q(x|z)$均与$q(x)$几乎相同,也就是说,线性加权和的基函数几乎相同。此状态下,不管输入如何变化,变换的输出总为$q(x)$。</li>
186
+ <li> 当$\alpha \to 1$时,不同$z$值的$q(x|z)$收缩成一系列不同偏移量的Dirac delta函数及零函数。此状态下,只要输入分布的支撑集(support set)包含于$q(x)$的支撑集,变换的输出与输入将保持一致。</li>
187
+ </ul>
188
+
189
+ 在第5节中提到,DDPM[\[2\]](#ddpm)论文所使用的1000次变换可使用一次变换表示:
190
+ \begin{align}
191
+ Z_T = \sqrt{0.0000403}\ X + \sqrt{1-0.0000403}\ \epsilon = 0.00635\ X + 0.99998\ \epsilon \tag{5.5}
192
+ \end{align}
193
+ 由于$\alpha=0.0000403$非常小,其对应的GaussFun(式3.4)的标准差达到157.52,而$X$的范围限制在$[-1, 1]$,远小于GaussFun的标准差。在$x \in [-1, 1]$范围内,GaussFun应该接近于常量,没有什么变化,所以不同的$z_T$对应的$q(x|z_T)$均与$q(x)$几乎相同。在这种状态下,对于$q(x|z_T)$相应的后验概率变换,不管输入分布是什么,输出分布都将是$q(x)$。
194
+
195
+ <b>所以,理论上,在DDPM模型中,无需非得使用标准正态分布代替$q(z_T)$,也可使用其它任意的分布代替。</b>
196
+
197
+ """, latex_delimiters=g_latex_del, elem_classes="normal mds", elem_id="md_backward_process")
198
+ return
199
+
200
+
201
+ def md_fit_posterior_zh():
202
+ global g_latex_del
203
+
204
+ title = "6. Fitting Posterior With Conditional Gaussian Model"
205
+ with gr.Accordion(label=title, elem_classes="first_md", elem_id="fit_posterior"):
206
+
207
+ # because of the render bug in gradio markdown, some formulas are render in ExtraBlock.js
208
+ gr.Markdown(
209
+ r"""
210
+ 由第四节前半部分可知,各个后验概率分布是未知的,并且与$q(x)$有关。所以,为了恢复数据分布或者从数据分布中采样,需要对各个后验概率分布进行学习估计。
211
+
212
+ 由第四节后半部分可知,当满足一定条件时,各个后验概率分布$q(x|z)、q(z_{t-1}|z_t)$近似于高斯概率分布,所以可通过构建一批条件高斯概率模型$p(x|z),p(z_{t-1}|z_t)$,学习拟合对应的$q(x|z),q(z_{t-1}|z_t)$。
213
+
214
+ 由于模型表示能力和学习能力的局限性,拟合过程会存在一定的误差,进一步会影响恢复$q(x)$的准确性。拟合误差大小与后验概率分布的形状有关。由第4节可知,当$q(x)$较复杂或者所加噪声较大时,后验概率分布会较复杂,与高斯分布差别较大,从而导致拟合误差,进一步影响恢复$q(x)$。
215
+
216
+ 具体可看Demo 3.3,读者可测试不同复杂程度的$q(x)$和$\alpha$,观看后验概率分布$q(z_{t-1}|z_t)$的拟合程度,以及恢复$q(x)$的准确度。恢复的概率分布使用$\textcolor{orange}{橙色}$标识,同时也通过JS divergence给出误差。
217
+
218
+ 关于拟合的目标函数,与其它概率模型类似,可$\textcolor{red}{优化交叉熵损失}$,使$p(z_{t-1}|z_t)$逼近于$q(z_{t-1}|z_t)$。由于$(z_{t-1}|z_t)$是条件概率,所以需要综合考虑各个条件,以<b>各个条件发生的概率$q(z_t)$</b>加权平均<b>各个条件对应的交叉熵</b>。最终的损失函数形式如下:
219
+ \begin{align}
220
+ loss &= -\int q(z_t)\ \overbrace{\int q(z_{t-1}|z_t) \log \textcolor{blue}{p(z_{t-1}|z_t)}dz_{t-1}}^{\text{Cross Entropy}}\ dz_t \tag{6.1} \newline
221
+ &= -\iint q(z_{t-1},z_t) \log \textcolor{blue}{p(z_{t-1}|z_t)}dz_{t-1}dz_t \tag{6.2}
222
+ \end{align}
223
+ 也可以KL散度作为目标函数进行优化,KL散度与交叉熵是等价的[\[10\]](#ce_kl)。
224
+ <span id="zh_fit_0">
225
+ loss &= \int q(z_t) KL(q(z_{t-1}|z_t)\|\textcolor{blue}{p(z_{t-1}|z_t)})dz_t \tag{6.3} \newline
226
+ &= \int q(z_t) \int q(z_{t-1}|z_t) \frac{q(z_{t-1}|z_t)}{\textcolor{blue}{p(z_{t-1}|z_t)}} dz_{t-1} dz_t \tag{6.4} \newline
227
+ &= -\int q(z_t)\ \underbrace{\int q(z_{t-1}|z_t) \log \textcolor{blue}{p(z_{t-1}|z_t)}dz_{t-1}}{underline}{\text{Cross Entropy}}\ dz_t + \underbrace{\int q(z_t) \int q(z_{t-1}|z_t) \log q(z_{t-1}|z_t)}{underline}{\text{Is Constant}} dz \tag{6.5}
228
+ </span>
229
+
230
+ 式6.2的积分没有闭合的形式,不能直接优化。可使用蒙特卡罗(Monte Carlo)积分近似计算,新的目标函数如下:
231
+ \begin{align}
232
+ loss &= -\iint q(z_{t-1},z_t) \log \textcolor{blue}{p(z_{t-1}|z_t)}dz_{t-1}dz_t \tag{6.6} \newline
233
+ &\approx -\sum_{i=0}^N \log \textcolor{blue}{p(Z_{t-1}^i|Z_t^i)} \qquad where \quad (Z_{t-1}^i,Z_t^i) \sim q(z_{t-1},z_t) \tag{6.7}
234
+ \end{align}
235
+
236
+ 上述的样本$(Z_{t-1}^i,Z_t^i)$服从联合概率分布$q(z_{t-1},z_t)$,可通过祖先采样的方式采样得到。具体方式如下:通过正向转换的方式(式4.1~4.4),逐步采样$X,Z_1,Z_2\dots Z_{t-1},Z_t$,然后留下$(Z_{t-1},Z_t)$作为一个样本。但这种采样方式比较慢,可利用$q(z_t|x)$概率分布已知的特点(式4.8)加速采样,先从$q(x)$采样$X$,然后由$q(z_{t-1}|x)$采样$Z_{t-1}$,最后由$q(z_t|z_{t-1})$采样$Z_t$,于是得到一个样本$(Z_{t-1},Z_t)$。
237
+
238
+ 可能有些人会有疑问,式6.3的形式跟DPM[\[1\]](#dpm)和DDPM[\[2\]](#ddpm)论文里的形式不太一样。实际上,这两个目标函数是等价的,下面给出证明。
239
+
240
+ 对于一致项(Consistent Term),证明如下:
241
+
242
+ \begin{align}
243
+ loss &= -\iint q(z_{t-1},z_t)\ \log \textcolor{blue}{p(z_{t-1}|z_t)}dz_{t-1}dz_t \tag{6.8} \newline
244
+ &= -\iint \int q(x)q(z_{t-1}, z_t|x)dx\ \log \textcolor{blue}{p(z_{t-1}|z_t)}dz_{t-1}dz_t \tag{6.9} \newline
245
+ &= \overbrace{\iint \int q(x)q(z_{t-1}, z_t|x) \log q(z_{t-1}|z_t,x)dxdz_{t-1}dz_t}^{\text{This Term Is Constant And Is Represented By}\ \textcolor{orange}{C_1}} \tag{6.10} \newline
246
+ &\quad - \iint \int q(x)q(z_{t-1}, z_t|x) \log \textcolor{blue}{p(z_{t-1}|z_t)}dxdz_{t-1}dz_t - \textcolor{orange}{C_1} \tag{6.11} \newline
247
+ &= \iint \int q(x)q(z_{t-1},z_t|x) \log \frac{q(z_{t-1}|z_t,x)}{\textcolor{blue}{p(z_{t-1}|z_t)}}dxdz_{t-1}dz_t - \textcolor{orange}{C_1} \tag{6.12} \newline
248
+ &= \iint q(x)q(z_t|x)\int q(z_{t-1}|z_t,x) \log \frac{q(z_{t-1}|z_t,x)}{\textcolor{blue}{p(z_{t-1}|z_t)}}dz_{t-1}\ dz_xdz_t - \textcolor{orange}{C_1} \tag{6.13} \newline
249
+ &= \iint \ q(x)q(z_t|x) KL[q(z_{t-1}|z_t,x)\|\textcolor{blue}{p(z_{t-1}|z_t)}]dxdz_t - \textcolor{orange}{C_1} \tag{6.14} \newline
250
+ &\propto \iint \ q(x)q(z_t|x) KL[q(z_{t-1}|z_t,x)\|\textcolor{blue}{p(z_{t-1}|z_t)}]dxdz_t \tag{6.15} \newline
251
+ \end{align}
252
+
253
+ 上式中的$C_1$项是一个固定值,不包含待优化的参数,其中,$q(x)$是固定的概率分布,$q(z_{t-1}|z_t)$也是固定概率分布,具体形式由$q(x)$及系数$\alpha$确定。
254
+
255
+ 对于重构项(Reconstruction Term),可通过类似的方式证明:
256
+ \begin{align}
257
+ loss &= -\int q(z_1)\overbrace{\int q(x|z_1)\log \textcolor{blue}{p(x|z_1)}dx}^{\text{Cross Entropy}}\ dz_1 \tag{6.16} \newline
258
+ &= -\iint q(z_1,x)\log \textcolor{blue}{p(x|z_1)}dxdz_1 \tag{6.17} \newline
259
+ &= -\int q(x)\int q(z_1|x)\log \textcolor{blue}{p(x|z_1)}dz_1\ dx \tag{6.18}
260
+ \end{align}
261
+
262
+ 因此,式6.1的目标函数与DPM的目标函数是等价的。
263
+
264
+ 根据一致项证明的结论,以及交叉熵与KL散度的关系,可得出一个有趣的结论:
265
+ <span id="zh_fit_1">
266
+ \mathop{\min}{underline}{\textcolor{blue}{p}} \int q(z_t) KL(q(z_{t-1}|z_t)\|\textcolor{blue}{p(z_{t-1}|z_t)})dz_t \iff \mathop{\min}{underline}{\textcolor{blue}{p}} \iint \ q(x)q(z_t|x) KL[q(z_{t-1}|z_t,x)\|\textcolor{blue}{p(z_{t-1}|z_t)}]dxdz_t
267
+ </span>
268
+ 比较左右两边的式子,可以看出,右边的目标函数比左边的目标函数多了一个条件变量$X$,同时也多了一个关于$X$积分,并且以$X$的发生的概率$q(x)$作为积分的加权系数。
269
+
270
+ 依照类似的思路,可推导出一个更通用的关系:
271
+ <span id="zh_fit_2">
272
+ \mathop{\min}{underline}{\textcolor{blue}{p}} KL(q(z)\|\textcolor{blue}{p(z)}) \iff \mathop{\min}_{\textcolor{blue}{p}} \int \ q(x) KL(q(z|x)\|\textcolor{blue}{p(z)})dx
273
+ </span>
274
+ """, latex_delimiters=g_latex_del, elem_classes="normal mds", elem_id="md_fit_posterior")
275
+ return
276
+
277
+
278
+ def md_posterior_transform_zh():
279
+ global g_latex_del
280
+
281
+ with gr.Accordion(label="7. Posterior Transform", elem_classes="first_md", elem_id="posterior_transform"):
282
+
283
+ gr.Markdown(
284
+ r"""
285
+ <h3 style="font-size:18px"> Contraction Mapping and Fixed Point </h3>
286
+ \begin{align}
287
+ q(x) &= \int q(x,z) dz = \int q(x|z)q(z)dz \tag{7.1}
288
+ \end{align}
289
+
290
+ 经过大量一维随机变量的实验发现,后验概率变换呈现出“压缩映射”(Contraction Mapping[\[6\]](#ctr))的特征。也是说,对任意的两个概率分布$q_{i1}(z)和q_{i2}(z)$,经过后验概率变换后得到$q_{o1}(x)$和$q_{o2}(x)$,$q_{o1}(z)$和$q_{o2}(z)$的距离<b>总是小于</b>$q_{i1}(x)$和$q_{i2}(x)$的距离。这里的距离可使用JS Divergence或Total Variance或度量。并且,这个压缩映射的压缩程度跟所加噪声大小正相关。
291
+ \begin{align}
292
+ dist(q_{o1}(z),\ q_{o2}(z)) < dist(q_{i1}(x),\ q_{i2}(x)) \tag{7.2}
293
+ \end{align}
294
+
295
+ 读者可查看Demo 4.1,左侧三个图呈现一个变换的过程,左1图是任意的数据分布$q(x)$,左3图是变换后的概率分布,左2图是后验概率分布。可更改随机种子生成新的数据分布,调整$\alpha$值引入不同程度的噪声。左侧最后两个图展示变换的“压缩性质”,左4图展示随机生成的两个输入分布,同时给出其距离度量值$div_{in}$;左5图展示经过变换后的两个输出分布,输出分布之间的距离标识为$div_{out}$。读者可改变输入的随机种子,切换不同的输入。可在图中看到,对于任意的输入,$div_{in}$总是小于$div_{out}$。另外,也可改变$\alpha$的值,将会看到,$\alpha$越小(噪声越大),$\frac{div_{out}}{div_{in}}$的比值也越小,即收缩率越大。
296
+
297
+ 由Banach fixed-point theorem<a href="#fixed_point">[5]</a>可知,压缩映射存在惟一一个定点(收敛点)。也就是说,对于任意的输入分布,可以连续迭代应用“后验概率变换”,只要迭代次数足够多,最终都会输出同一个分布。经过大量一维随机变量实验发现,定点(收敛点)<b>位于$q(x)$附近</b>。并且,与$\alpha$的值有关,$\alpha$越小(噪声越大),离得越近。
298
+
299
+ 读者可看Demo 4.2,此部分展示迭代收敛的例子。选择合适的迭代次数,点中“apply iteration transform”,将逐步画出迭代的过程,每个子图均会展示各自变换后的输出分布($\textcolor{green}{绿色曲线}$),收敛的参考点分布$q(x)$以$\textcolor{blue}{蓝色曲线}$画出,同时给出输出分布与$q(x)$之间的距离$dist$。可以看出,随着迭代的次数增加,输出分布与$q(x)$越来越相似,并最终会稳定在$q(x)$附近。对于较复杂的分布,可能需要较多迭代的次数或者较大的噪声。迭代次数可以设置为上万步,但会花费较长时间。
300
+
301
+ 对于一维离散的情况,$q(x|z)$将离散成一个矩阵(暂记为$Q_{x|z}$),$q(z)$离散成一个向量(记为$\boldsymbol{q_i}$),积分操作$\int q(x|z)q(z)dz$将离散成"矩阵-向量"乘法操作,所以后验概率变换可写成
302
+ \begin{align}
303
+ \boldsymbol{q_o} &= Q_{x|z}\ \boldsymbol{q_i} & \quad\quad &\text{1 iteration} \tag{7.3} \newline
304
+ \boldsymbol{q_o} &= Q_{x|z}\ Q_{x|z}\ \boldsymbol{q_i} & \quad\quad &\text{2 iteration} \tag{7.4} \newline
305
+ & \dots & \notag \newline
306
+ \boldsymbol{q_o} &= (Q_{x|z})^n\ \boldsymbol{q_i} & \quad\quad &\text{n iteration} \tag{7.5} \newline
307
+ \end{align}
308
+ 于是,为了更深入地理解变换的特点,Demo 4.2也画出矩阵$(Q_{x|z})^n$的结果。从图里可以看到,当迭代趋向收敛时,矩阵$(Q_{x|z})^n$的行向量将变成一个常数向量,即向量的各分量都相等。在二维密度图里将表现为一条横线。
309
+
310
+ <center> <img src="file/fig2.png" width="960" style="margin-top:12px"/> </center>
311
+ <center> Figure 2: Only one component in support </center>
312
+
313
+ 下面分几种情况证明,后验概率变换是一个压缩映射,并存在惟一收敛点。证明的过程假设随机变量是离散型的,因此,后验概率变换可看作是一个<b>离散Markov Chain</b>的一步转移,后验概率$q(x|z)$对应于<b>转移矩阵</b>(Transfer Matrix)。连续型的变量可认为是无限多状态的离散型变量。
314
+
315
+ <ol style="list-style-type:decimal">
316
+ <li> 当$q(x)$均大于0时,后验概率变换矩阵$q(x|z)$将大于0,于是此矩阵是一个$\textcolor{red}{不可约}\textcolor{green}{非周期}$的Markov Chain的转移矩阵,根据文献<a href="#mc_basic_p6">[13]</a>的结论,此变换是一个关于Total Variance度量的压缩映射,于是,根据Banach fixed-point theorem,此变换存在惟一定点(收敛点)。</li>
317
+
318
+ <li> 当$q(x)$部分大于0,并且$q(x)$的支撑集($q(x)$大于0的区域)只存在一个连通域时(图2),由式(3.4)可分析出几个结论:
319
+
320
+ <ol style="list-style-type:lower-alpha; padding-inline-start: 0px;font-size:16px;">
321
+ <li> 当$z$和$x$在支撑集内时,由于$q(x)$和GaussFun均大于0,所以,转移矩阵的对角元素$\{q(x|z)|z=x\}$大于0。这意味着,支撑集内的状态是$\textcolor{green}{非周期}$的。</li>
322
+
323
+ <li> 当$z$和$x$在支撑集内时,由于GaussFun的支撑集存在一定的半径,所以,在对角元素上下附近区域内的$\{q(x|z)|x=z+\epsilon\}$也大于0。这意味着,支撑集内的状态可相互访问(accessible),形成一个$\textcolor{red}{\text{Communication Class}}$<a href="#mc_basic_d4">[14]</a>。</li>
324
+
325
+ <li> 当<em>$z$在支撑集内</em>且<em>$x$在支撑集外</em>时,${q(x|z)}$全为0。这意味着,支撑集内的状态<em>不可访问</em>支撑集外的状态(图2b的inaccessible区域)。</li>
326
+
327
+ <li> 当<em>$z$在支撑集外</em>且<em>$x$在支撑集内</em>时,由于GaussFun的支撑集存在一定的范围,所以,存在部分扩展区域(图2b的extension区域),其对应的$\{q(x|z)|x\in support\}$不全为0。这意味着,此部分扩展区域的状态可<em>单向</em>访问(access)支撑集内的状态(图2b的unidirectional区域)。</li>
328
+
329
+ <li> 当<em>$z$在支撑集外</em>且<em>$x$在支撑集外</em>时,对应的$q(x|z)$全为0。这意味着,支撑集外的状态不会转移至支撑集外的状态,也就是说,支撑集外的状态只来源于支撑集内的状态。</li>
330
+
331
+ <p style="margin-top:8px">
332
+ 由(c)可知,支撑集内的状态<em>不会转移到</em>支撑集外的状态,由(a)和(b)可知,支撑集内的状态是非周期且构成一个Communicate Class,所以,支撑集内的状态独立构成一个不可约且非周期的Markov Chain,根据文献<a href="#mc_limit">[7]</a>中Theorem 11.4.1的结论,当$n\to+\infty$时,$q(x|z)^n$收敛于一个固定矩阵,并且矩阵每个列向量都相同。这意味着,对于不同的z,$q(x|z)^n$都相同(可见图2c)。另外,由(d)和(e)可知,存在部分支撑集外的z状态,能转移至支撑集内,并且会带着支撑集内的信息转移回支撑集外,于是,此部分z状态对应的$q(x|z)$(图2c的$q(x|z_{ex})$区域)也会等于支撑集内对应的$q(x|z)$(图2c的$q(x|z_{sup})$区域)。
333
+ </p>
334
+
335
+ <p style="margin-top:8px">
336
+ 所以,可以得出结论,当状态限制在支撑集和两个扩展区域内时,$\lim_{n\to\infty}{q(x|z)^n}$会收敛于一个固定矩阵,并且每个列向量均相同。于是,对于任意的输入分布,如果连续应用足够多后验概率变换,最终会收敛于一个固定分布,此分布等于收敛的矩阵的列向量。根据文献<a href="#fp_converse">[9]</a>的结论,当迭代变换收敛于惟一定点时,此变换是关于某个metric的Contraction Mapping。
337
+ </p>
338
+
339
+ </ol>
340
+ </li>
341
+
342
+ <li> 当$q(x)$部分大于0,$q(x)$的支撑集存在多个连通域,并且各个连通域的最大距离<b>能</b>被相应的GaussFun的支撑集所覆盖时,那各个连通域内的状态构成一个Communicate Class。如图3所示,$q(x)$存在两个连通域,在第一个连通域的边缘,$q(x|z=-0.3)$对应的GaussFun的支撑集能跨越间隙到达第二个连通域,于是第一个连通域的状态能<em>访问</em>第二个连通域的状态;在第二个连通域的边缘,$q(x|z=0)$对应的GaussFun的支撑集也能跨越间隙到达第一个连通域,于是第二个连通域的状态能<em>访问</em>第一个连通域的状态,所以两个连通域构成一个Communicate Class。因此,与单个连通域的情况类似,当状态限制在各个连通域、间隙及扩展区域内时,后验概率变换存在惟一一个迭代收敛点,并且是关于某个metric的压缩映射。</li>
343
+
344
+ <li> 当$q(x)$部分大于0,$q(x)$的支撑集存在多个连通域时,并且各个连通域的最大距离<b>不能</b>被相应的GaussFun的支撑集所覆盖时,那各个连通域内的状态构成多个Communicate Class,如图4所示。此情况下,当$n\to\infty$时,$q(x|z)^n$也会收敛于一个固定矩阵,但每个列向量不尽相同。所以,后验概率变��不是一个严格的压缩映射。但当输入分布的状态限制在单个Communicate Class及相应的扩展范围内时,后验概率变换也是一个压缩映射,存在惟一收敛点。</li>
345
+ </ol>
346
+
347
+ <center> <img src="file/fig3.png" width="960" style="margin-top:12px"/> </center>
348
+ <center> Figure 3: Two component which can communicate with each other </center>
349
+
350
+ <center> <img src="file/fig4.png" width="960" style="margin-top:12px"/> </center>
351
+ <center> Figure 4: Two component which <b>cannot</b> communicate with each other </center>
352
+
353
+ 另外,后验概率变换存在一个更通用的关系,与$q(x|z)$的具体值无关: 两个输出分布的之间的Total Variance距离总是会<b>小于等于</b>对应输入分布之间的Total Variance距离,即
354
+ \begin{align}
355
+ dist(q_{o1}(x),\ q_{o2}(x)) <= dist(q_{i1}(z),\ q_{i2}(z)) \notag
356
+ \end{align}
357
+ 下面通过离散的形式给出证明:
358
+ \begin{align}
359
+ \lVert q_{o1}-q_{o2}\rVert_{TV} &= \lVert Q_{x|z}q_{i1} - Q_{x|z}q_{i2}\rVert_{TV} \tag{7.6} \newline
360
+ &= \sum_{m}\textcolor{red}{|}\sum_{n}Q_{x|z}(m,n)q_{i1}(n) - \sum_{n}Q_{x|z}(m,n)q_{i2}(n)\textcolor{red}{|} \tag{7.7} \newline
361
+ &= \sum_{m}\textcolor{red}{|}\sum_{n}Q_{x|z}(m,n)(q_{i1}(n) - q_{i2}(n))\textcolor{red}{|} \tag{7.8} \newline
362
+ &\leq \sum_{m}\sum_{n}Q_{x|z}(m,n)\textcolor{red}{|}(q_{i1}(n) - q_{i2}(n))\textcolor{red}{|} \qquad \qquad \qquad \text{Absolute value inequality} \tag{7.9} \newline
363
+ &= \sum_{n}\textcolor{red}{|}(q_{i1}(n) - q_{i2}(n))\textcolor{red}{|} \sum_{m} Q_{x|z}(m,n) \qquad \qquad \qquad \sum_{m} Q_{x|z}(m,n) = 1 \tag{7.10} \newline
364
+ &= \sum_{n}\textcolor{red}{|}(q_{i1}(n) - q_{i2}(n))\textcolor{red}{|} \tag{7.11}
365
+ \end{align}
366
+ 其中,$Q_{x|z}(m,n)$表示矩阵$Q_{x|z}$的第m行第n列的元素,$q_{i1}(n)$表示向量$q_{i1}$的第n个元素。
367
+
368
+ 关于定点分布与输入分布q(x)之间距离的关系,目前尚不能严格证明。
369
+
370
+ <h3 style="font-size:18px"> 恢复数据分布过程中的抗噪声能力 </h3>
371
+ 由上面的分析可知,当满足一些条件时,"后验概率变换"是一个压缩映射,所以存在如下的关系:
372
+ \begin{align}
373
+ dist(q(x),\ q_o(x)) < dist(q(z),\ q_i(z)) \tag{7.12}
374
+ \end{align}
375
+ 其中,$q(z)$是理想的输入分布,$q(x)$理想的输出分布,$q_i(x)$是任意的输入分布,$q_o(x)$是$q_i(z)$经过变换后的输出分布。
376
+
377
+ 上式表明,输出的分布$q_o(x)$与理想输出分布q(x)之间的距离总会</em>小于</em>输入分布$q_i(z)$与理想输入分布q(x)的距离。于是,"后验概率变换"具备一定的抵抗噪声能力。这意味着,在恢复$q(x)$的过程中,哪怕输入的“末尾分布$q(z_T)”$存在一定的误差,经过一系列变换后,输出的“数据分布$q(x)$“的误差也会比输入的误差更小。
378
+
379
+ 具体可看Demo 3.2,通过增加“noise ratio”的值可以向“末尾分布$q(z_T)$”添加噪声,点击“apply”按钮将逐步画出恢复的过程,恢复的分布以$\textcolor{red}{红色曲线}$画出,同时也会通过JS散度标出误差的大小。将会看到,恢复的$q(x)$的误差总是小于$q(z_T)$的误差。
380
+
381
+ 由上面的讨论可知,$\alpha$越小(即变换过程中使用的噪声越大),压缩映射的压缩率越大,于是,抗噪声的能力也越强。
382
+ """, latex_delimiters=g_latex_del, elem_classes="normal mds", elem_id="md_posterior_transform")
383
+ return
384
+
385
+
386
+ def md_deconvolution_zh():
387
+ global g_latex_del
388
+
389
+ title = "8. Can the data distribution be restored by deconvolution?"
390
+ with gr.Accordion(label=title, elem_classes="first_md", elem_id="deconvolution"):
391
+
392
+ gr.Markdown(
393
+ r"""
394
+ 在第二节中提到,式2.1的变换可分为两个子变换,第一个子变换为”线性变换“,第二个为“加上独立高斯噪声”。线性变换相当于对概率分布进行拉伸变换,所以存在逆变换。"加上独立高斯噪声”相当于对概率分布��行卷积操作,卷积操作可通过逆卷积恢复。所以,理论上,可通过“逆线性变换”和“逆卷积”从最终的概率分布$q(z_T)$恢复数据分布$q(x)$。
395
+
396
+ 但实际上,会存在一些问题。由于逆卷积对误差极为敏感,具有很高的输入灵敏度,很小的输入噪声就会引起输出极大的变化[\[11\]](#deconv_1)[\[12\]](#deconv_2)。而在扩散模型中,会使用标准正态分布近似代替$q(z_T)$,因此,在恢复的起始阶段就会引入噪声。虽然噪声较小,但由于逆卷积的敏感性,噪声会逐步放大,影响恢复。
397
+
398
+ 另外,也可以从另一个角度理解“逆卷积恢复”的不可行性。由于前向变换的过程(式4.1~4.4)是确定的,所以卷积核是固定的,因此,相应的“逆卷积变换“也是固定的。由于起始的数据分布$q(x)$可以是任意的分布,所以,通过一系列固定的“卷积正变换”,可以将任意的概率分布转换成近似$\mathcal{N}(0,I)$的分布。如“逆卷积变换“可行,则意味着,可用一个固定的“逆卷积变换",将$\mathcal{N}(0,I)$分布恢复成任意的数据分布$q(x)$,这明显是一个悖论。同一个输入,同一个变换,不可能会有多个输出。
399
+ """, latex_delimiters=g_latex_del, elem_classes="normal mds", elem_id="md_deconvolution")
400
+ return
401
+
402
+
403
+
404
+ def md_reference_zh():
405
+ global g_latex_del
406
+
407
+ with gr.Accordion(label="Reference", elem_classes="first_md", elem_id="reference"):
408
+
409
+ gr.Markdown(
410
+ r"""
411
+ <a id="dpm" href="https://arxiv.org/abs/1503.03585"> [1] Deep Unsupervised Learning Using Nonequilibrium Thermodynami </a>
412
+
413
+ <a id="ddpm" href="https://arxiv.org/abs/1503.03585"> [2] Denoising Diffusion Probabilistic Models </a>
414
+
415
+ <a id="linear_transform" href="https://stats.libretexts.org/Bookshelves/Probability_Theory/Probability_Mathematical_Statistics_and_Stochastic_Processes_(Siegrist)/03%3A_Distributions/3.07%3A_Transformations_of_Random_Variables"> [3] Linear Transformations of Random Variable </a>
416
+
417
+ <a id="sum_conv" href="https://stats.libretexts.org/Bookshelves/Probability_Theory/Probability_Mathematical_Statistics_and_Stochastic_Processes_(Siegrist)/03%3A_Distributions/3.07%3A_Transformations_of_Random_Variables"> [4] Sums and Convolution </a>
418
+
419
+ <a id="fixed_point" href="https://en.wikipedia.org/wiki/Banach_fixed-point_theorem"> [5] Banach fixed-point theorem </a>
420
+
421
+ <a id="ctr" href="https://en.wikipedia.org/wiki/Contraction_mapping"> [6] Contraction mapping </a>
422
+
423
+ <a id="mc_limit" href="https://stats.libretexts.org/Bookshelves/Probability_Theory/Book%3A_Introductory_Probability_(Grinstead_and_Snell)/11%3A_Markov_Chains/11.04%3A_Fundamental_Limit_Theorem_for_Regular_Chains"> [7] Fundamental Limit Theorem for Regular Chains </a>
424
+
425
+ <a id="mc_basic_p6" href="http://galton.uchicago.edu/~lalley/Courses/312/MarkovChains.pdf"> [8] Markov Chain:Basic Theory - Proposition 6 </a>
426
+
427
+ <a id="fp_converse" href="https://arxiv.org/abs/1702.07339"> [9] A Converse to Banach's Fixed Point Theorem and its CLS Completeness </a>
428
+
429
+ <a id="ce_kl" href="https://en.wikipedia.org/wiki/Cross-entropy#Cross-entropy_minimization"> [10] Cross-entropy minimization </a>
430
+
431
+ <a id="deconv_1" href="https://thewolfsound.com/deconvolution-inverse-convolution/"> [11] Deconvolution Using Frequency-Domain Division </a>
432
+
433
+ <a id="deconv_2" href="https://www.strollswithmydog.com/deconvolution-by-division-in-the-frequency-domain/"> [12] deconvolution-by-division-in-the-frequency-domain </a>
434
+
435
+ <a id="mc_basic_t7" href="http://galton.uchicago.edu/~lalley/Courses/312/MarkovChains.pdf"> [13] Markov Chain:Basic Theory - Theorem 7 </a>
436
+
437
+ <a id="mc_basic_d4" href="http://galton.uchicago.edu/~lalley/Courses/312/MarkovChains.pdf"> [14] Markov Chain:Basic Theory - Definition 4 </a>
438
+
439
+ """, latex_delimiters=g_latex_del, elem_classes="normal mds", elem_id="md_reference")
440
+
441
+ return
442
+
443
+
444
+ def md_about_zh():
445
+ global g_latex_del
446
+
447
+ with gr.Accordion(label="About", elem_classes="first_md", elem_id="about"):
448
+
449
+ gr.Markdown(
450
+ r"""
451
+ <b>APP</b>: 本APP是使用Gradio开发,并部署在HuggingFace。由于资源有限(2核,16G内存),所以可能会响应较慢。为了更好地体验,建议从<a href="https://github.com/blairstar/The_Art_of_DPM">github</a>复制源代码,在本地机器运行。本APP只依赖Gradio, SciPy, Matplotlib。
452
+
453
+ <b>Author</b>: 郑镇鑫,资深视觉算法工程师,十年算法开发经历,曾就职于腾讯京东等互联网公司,目前专注于视频生成(类似Sora)。
454
+
455
+ <b>Email</b>: [email protected]
456
+ """, latex_delimiters=g_latex_del, elem_classes="normal mds", elem_id="md_about")
457
+
458
+ return
459
+
460
+
461
+ def run_app():
462
+
463
+ # with gr.Blocks(css=g_css, js="() => insert_special_formula()", head=js_head) as demo:
464
+ with gr.Blocks(css=g_css, js="() => {insert_special_formula(); write_markdown();}", head=js_head) as demo:
465
+ md_introduction_zh()
466
+
467
+ md_transform_zh()
468
+
469
+ md_likelihood_zh()
470
+
471
+ md_posterior_zh()
472
+
473
+ md_forward_process_zh()
474
+
475
+ md_backward_process_zh()
476
+
477
+ md_fit_posterior_zh()
478
+
479
+ md_posterior_transform_zh()
480
+
481
+ md_deconvolution_zh()
482
+
483
+ md_reference_zh()
484
+
485
+ md_about_zh()
486
+
487
+ demo.launch(allowed_paths=["/"])
488
+
489
+ return
490
+
491
+
492
+ if __name__ == "__main__":
493
+ run_app()
fig2.png ADDED
fig3.png ADDED
fig4.png ADDED
pipe.jpg ADDED
requirements.txt ADDED
@@ -0,0 +1,4 @@
 
 
 
 
 
1
+ gradio==4.12.0
2
+ scipy==1.11.2
3
+ matplotlib==3.8.3
4
+ numpy