Skip to content

Commit cc8fd34

Browse files
committed
Better docs for approximations
1 parent 2dfd78c commit cc8fd34

File tree

1 file changed

+18
-17
lines changed

1 file changed

+18
-17
lines changed

pymc3/variational/approximations.py

Lines changed: 18 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,7 @@
2323

2424
@Group.register
2525
class MeanFieldGroup(Group):
26-
R"""Mean Field Group
27-
28-
Mean Field approximation to the posterior where spherical Gaussian family
26+
R"""Mean Field approximation to the posterior where spherical Gaussian family
2927
is fitted to minimize KL divergence from True posterior. It is assumed
3028
that latent space variables are uncorrelated that is the main drawback
3129
of the method
@@ -101,9 +99,7 @@ def symbolic_logq_not_scaled(self):
10199

102100
@Group.register
103101
class FullRankGroup(Group):
104-
"""Full Rank Group
105-
106-
Full Rank approximation to the posterior where Multivariate Gaussian family
102+
"""Full Rank approximation to the posterior where Multivariate Gaussian family
107103
is fitted to minimize KL divergence from True posterior. In contrast to
108104
MeanField approach correlations between variables are taken in account. The
109105
main drawback of the method is computational cost.
@@ -216,9 +212,7 @@ def symbolic_random(self):
216212

217213
@Group.register
218214
class EmpiricalGroup(Group):
219-
"""Empirical Group
220-
221-
Builds Approximation instance from a given trace,
215+
"""Builds Approximation instance from a given trace,
222216
it has the same interface as variational approximation
223217
"""
224218
supports_batched = False
@@ -336,13 +330,12 @@ def __str__(self):
336330

337331

338332
class NormalizingFlowGroup(Group):
339-
R"""Normalizing Flow Group
340-
341-
Normalizing flow is a series of invertible transformations on initial distribution.
333+
R"""Normalizing flow is a series of invertible transformations on initial distribution.
342334
343335
.. math::
344336
345-
z_K = f_K \circ \dots \circ f_2 \circ f_1(z_0)
337+
z_K &= f_K \circ \dots \circ f_2 \circ f_1(z_0) \\
338+
& z_0 \sim \mathcal{N}(0, 1)
346339
347340
In that case we can compute tractable density for the flow.
348341
@@ -548,17 +541,23 @@ def __getattr__(self, item):
548541

549542

550543
class MeanField(SingleGroupApproximation):
551-
"""Single Group Mean Field Approximation"""
544+
__doc__ = """**Single Group Mean Field Approximation**
545+
546+
""" + str(MeanFieldGroup.__doc__)
552547
_group_class = MeanFieldGroup
553548

554549

555550
class FullRank(SingleGroupApproximation):
556-
"""Single Group Full Rank Approximation"""
551+
__doc__ = """**Single Group Full Rank Approximation**
552+
553+
""" + str(FullRankGroup.__doc__)
557554
_group_class = FullRankGroup
558555

559556

560557
class Empirical(SingleGroupApproximation):
561-
"""Single Group Full Rank Approximation"""
558+
__doc__ = """**Single Group Full Rank Approximation**
559+
560+
""" + str(EmpiricalGroup.__doc__)
562561
_group_class = EmpiricalGroup
563562

564563
def __init__(self, trace=None, size=None, **kwargs):
@@ -568,7 +567,9 @@ def __init__(self, trace=None, size=None, **kwargs):
568567

569568

570569
class NormalizingFlow(SingleGroupApproximation):
571-
"""Single Group Normalizing Flow Approximation"""
570+
__doc__ = """**Single Group Normalizing Flow Approximation**
571+
572+
""" + str(NormalizingFlowGroup.__doc__)
572573
_group_class = NormalizingFlowGroup
573574

574575
def __init__(self, flow=NormalizingFlowGroup.default_flow, *args, **kwargs):

0 commit comments

Comments
 (0)