File tree Expand file tree Collapse file tree 3 files changed +28
-4
lines changed Expand file tree Collapse file tree 3 files changed +28
-4
lines changed Original file line number Diff line number Diff line change 13
13
14
14
@six .add_metaclass (abc .ABCMeta )
15
15
class Inference (object ):
16
- """Base class for Edward inference methods.
16
+ """Abstract base class for inference. All inference algorithms in
17
+ Edward inherit from ``Inference``, sharing common methods and
18
+ properties via a class hierarchy.
19
+
20
+ Specific algorithms typically inherit from other subclasses of
21
+ ``Inference`` rather than ``Inference`` directly. For example, one
22
+ might inherit from the abstract classes ``MonteCarlo`` or
23
+ ``VariationalInference``.
24
+
25
+ To build an algorithm inheriting from ``Inference``, one must at the
26
+ minimum implement ``initialize`` and ``update``: the former builds
27
+ the computational graph for the algorithm; the latter runs the
28
+ computational graph for the algorithm.
17
29
"""
18
30
def __init__ (self , latent_vars = None , data = None ):
19
31
"""Initialization.
Original file line number Diff line number Diff line change 14
14
15
15
@six .add_metaclass (abc .ABCMeta )
16
16
class MonteCarlo (Inference ):
17
- """Base class for Monte Carlo inference methods.
17
+ """Abstract base class for Monte Carlo. Specific Monte Carlo methods
18
+ inherit from ``MonteCarlo``, sharing methods in this class.
19
+
20
+ To build an algorithm inheriting from ``MonteCarlo``, one must at the
21
+ minimum implement ``build_update``: it determines how to assign
22
+ the samples in the ``Empirical`` approximations.
18
23
"""
19
24
def __init__ (self , latent_vars = None , data = None ):
20
25
"""Initialization.
@@ -143,7 +148,7 @@ def print_progress(self, info_dict):
143
148
@abc .abstractmethod
144
149
def build_update (self ):
145
150
"""Build update rules, returning an assign op for parameters in
146
- the Empirical random variables.
151
+ the `` Empirical`` random variables.
147
152
148
153
Any derived class of ``MonteCarlo`` **must** implement this method.
149
154
Original file line number Diff line number Diff line change 19
19
20
20
@six .add_metaclass (abc .ABCMeta )
21
21
class VariationalInference (Inference ):
22
- """Base class for variational inference methods.
22
+ """Abstract base class for variational inference. Specific
23
+ variational inference methods inherit from ``VariationalInference``,
24
+ sharing methods such as a default optimizer.
25
+
26
+ To build an algorithm inheriting from ``VariaitonalInference``, one
27
+ must at the minimum implement ``build_loss_and_gradients``: it
28
+ determines the loss function and gradients to apply for a given
29
+ optimizer.
23
30
"""
24
31
def __init__ (self , * args , ** kwargs ):
25
32
super (VariationalInference , self ).__init__ (* args , ** kwargs )
You can’t perform that action at this time.
0 commit comments