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
Normalclass like this:This suggests looking in
edward/models/__init__.py, which has this line:Looking in
edward/models/random_variables.pywe find this code:This goes through the
tensorflow.contrib.distributionsmodule looking for classes derived fromtensorflow.contrib.distributions.Distribution(ignoring other attributes like e.g. the__file__member of the module, or the baseDistributionclass 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'sRandomVariableclass and the TensorFlow random variable class. Earlier it defined_globalsto 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):