def __init__(self, name, distribution, n_samples, observed=None):
self._name = name
self._distribution = distribution
self._n_samples = n_samples
self._dtype = distribution.dtype
if observed is not None:
try:
observed = tf.convert_to_tensor(observed, dtype=self.dtype)
except ValueError as e:
raise ValueError(
"StochasticTensor('{}') not compatible "
"with its observed value. Error message: {}".format(
self._name, e))
self._observed = observed
try:
self._net = BayesianNet.get_context()
self._net._add_stochastic_tensor(self)
except RuntimeError:
self._net = None
super(StochasticTensor, self).__init__()
评论列表
文章目录