Пример #1
0
 def observed(cls, parent: Gaussian, child: torch.tensor,
              variance: torch.Tensor):
     child = Gaussian.observed(child)
     obj = cls(parent, child, variance)
     obj._observed = True
     return obj
Пример #2
0
# prior case
shape = (2, 3)
child = Gaussian.from_shape(shape, 1., 2.)
self = GaussianFactor.prior(child, 0., 1.)
self.forward()
self.backward()
self
self.to_elbo()

# observed case

shape = (2, 3)
parent = Gaussian.from_shape(shape, 0., 1.)
child = torch.randn(shape)
child[0, 0] = np.nan
Gaussian.observed(child)
self = GaussianFactor.observed(parent, child, 1.)
self.forward()
self.backward()
self
self.to_elbo()

# -----------------------------------------------------------------------------
# Logistic
import torch
import numpy as np
from NNVI.vmp.utils import sigmoid_integrals
from NNVI.vmp.bernoulli import Bernoulli
from NNVI.vmp.gaussian import Gaussian
from NNVI.vmp.factors import Logistic