When using edward, we always use from edward.models import Normal
, but i didn't find the declaration of Normal
in github
anybody who can tell me where is it
When using edward, we always use from edward.models import Normal
, but i didn't find the declaration of Normal
in github
anybody who can tell me where is it
They are defined in
edward/models/random_variables.py
.You import the
Normal
class like this:This suggests looking in
edward/models/__init__.py
, which has this line:Looking in
edward/models/random_variables.py
we find this code:This goes through the
tensorflow.contrib.distributions
module looking for classes derived fromtensorflow.contrib.distributions.Distribution
(ignoring other attributes like e.g. the__file__
member of the module, or the baseDistribution
class itself). For each one, it does a bit of hacking (which only affects the generated documentation) then executes this key line:The
type()
built-in function creates a new type i.e. declares a new class. The second parameter is the list of base classes, which here is edward'sRandomVariable
class and the TensorFlow random variable class. Earlier it defined_globals
to beglobals()
, which is a built-in function returning the dictionary of the module's variables. Therefore, in the case you're interested in, the line above is equivalent to the following:Which in turn is equivalent to this (if you ignore the docstring stuff):