def to_child(self): x = self.parent / self.message_to_parent # x = self.parent m, v = x.mean_and_variance() integral = sigmoid_integrals(m, v, [0])[0] proba = tf.where(self.child.proba() == 1., integral, 1. - integral) self.message_to_child = BernoulliArray.from_array(proba)
def to_result(self, x): # compute incoming message from_x = x / self.message_to_x # add noise from_x = GaussianArray.from_array( mean=from_x.mean(), variance=from_x.log_var() + self.variance.value() ) # compute probability proba = 1. - tfp.distributions.Normal(*from_x.mean_and_variance()).cdf(0.0) return BernoulliArray.from_array(proba)
def to_child(self): # only used for prediction, does not affect VMP x = self.parent / self.message_to_parent proba = 1. - tfp.distributions.Normal(*x.mean_and_stddev()).cdf(0.0) self.message_to_child = BernoulliArray.from_array(proba)
def to_result(self, x): x = x / self.message_to_x # TODO: should that be sqrt? proba = 1. - tfp.distributions.Normal(*x.mean_and_variance()).cdf(0.0) return BernoulliArray.from_array(proba)