MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / __init__

Method __init__

tensorflow/contrib/distributions/python/ops/mixture.py:80–215  ·  view source on GitHub ↗

Initialize a Mixture distribution. A `Mixture` is defined by a `Categorical` (`cat`, representing the mixture probabilities) and a list of `Distribution` objects all having matching dtype, batch shape, event shape, and continuity properties (the components). The `num_classes` o

(self,
               cat,
               components,
               validate_args=False,
               allow_nan_stats=True,
               use_static_graph=False,
               name="Mixture")

Source from the content-addressed store, hash-verified

78 "instead of `tf.contrib.distributions`.",
79 warn_once=True)
80 def __init__(self,
81 cat,
82 components,
83 validate_args=False,
84 allow_nan_stats=True,
85 use_static_graph=False,
86 name="Mixture"):
87 """Initialize a Mixture distribution.
88
89 A `Mixture` is defined by a `Categorical` (`cat`, representing the
90 mixture probabilities) and a list of `Distribution` objects
91 all having matching dtype, batch shape, event shape, and continuity
92 properties (the components).
93
94 The `num_classes` of `cat` must be possible to infer at graph construction
95 time and match `len(components)`.
96
97 Args:
98 cat: A `Categorical` distribution instance, representing the probabilities
99 of `distributions`.
100 components: A list or tuple of `Distribution` instances.
101 Each instance must have the same type, be defined on the same domain,
102 and have matching `event_shape` and `batch_shape`.
103 validate_args: Python `bool`, default `False`. If `True`, raise a runtime
104 error if batch or event ranks are inconsistent between cat and any of
105 the distributions. This is only checked if the ranks cannot be
106 determined statically at graph construction time.
107 allow_nan_stats: Boolean, default `True`. If `False`, raise an
108 exception if a statistic (e.g. mean/mode/etc...) is undefined for any
109 batch member. If `True`, batch members with valid parameters leading to
110 undefined statistics will return NaN for this statistic.
111 use_static_graph: Calls to `sample` will not rely on dynamic tensor
112 indexing, allowing for some static graph compilation optimizations, but
113 at the expense of sampling all underlying distributions in the mixture.
114 (Possibly useful when running on TPUs).
115 Default value: `False` (i.e., use dynamic indexing).
116 name: A name for this distribution (optional).
117
118 Raises:
119 TypeError: If cat is not a `Categorical`, or `components` is not
120 a list or tuple, or the elements of `components` are not
121 instances of `Distribution`, or do not have matching `dtype`.
122 ValueError: If `components` is an empty list or tuple, or its
123 elements do not have a statically known event rank.
124 If `cat.num_classes` cannot be inferred at graph creation time,
125 or the constant value of `cat.num_classes` is not equal to
126 `len(components)`, or all `components` and `cat` do not have
127 matching static batch shapes, or all components do not
128 have matching static event shapes.
129 """
130 parameters = dict(locals())
131 if not isinstance(cat, categorical.Categorical):
132 raise TypeError("cat must be a Categorical distribution, but saw: %s" %
133 cat)
134 if not components:
135 raise ValueError("components must be a non-empty list or tuple")
136 if not isinstance(components, (list, tuple)):
137 raise TypeError("components must be a list or tuple, but saw: %s" %

Callers

nothing calls this directly

Calls 7

allFunction · 0.85
assert_equalMethod · 0.80
rangeFunction · 0.50
merge_withMethod · 0.45
name_scopeMethod · 0.45
batch_shape_tensorMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected