Exemplo n.º 1
0
 def test_update(self):
     P = 10
     Q = 5
     hyper = vbfa.Hyper(P, Q)
     q_lambda = vbfa.Lambda(P, Q)
     q_nu = vbfa.Nu(Q)
     q_nu.update(hyper, q_lambda)
     self.assertTrue(np.all(q_nu.b > 0))
Exemplo n.º 2
0
 def test_init(self):
     P = 10
     Q = 5
     q_lambda = vbfa.Lambda(P, Q)
     self.assertEqual(q_lambda.mean.shape, (P, Q))
     self.assertEqual(len(q_lambda.cov), P)
     for p in range(P):
         self.assertEqual(q_lambda.cov[p].shape, (Q, Q))
     self.assertTrue(len(q_lambda.__str__()) > 0)
Exemplo n.º 3
0
 def test_update(self):
     np.random.seed(0)
     P = 10
     Q = 5
     N = 100
     q_x = vbfa.X(Q, N)
     hyper = vbfa.Hyper(P, Q)
     y = np.random.rand(P, N)
     q_lambda = vbfa.Lambda(P, Q)
     q_mu = vbfa.Mu(P)
     q_x.update(hyper, q_lambda, q_mu, y)
Exemplo n.º 4
0
 def test_update(self):
     np.random.seed(0)
     P = 10
     Q = 5
     hyper = vbfa.Hyper(P, Q)
     q_lambda = vbfa.Lambda(P, Q)
     N = 100
     y = np.random.rand(P, N)
     q_mu = vbfa.Mu(P)
     q_nu = vbfa.Nu(Q)
     q_x = vbfa.X(Q, N)
     q_lambda.update(hyper, q_mu, q_nu, q_x, y)
     for p in range(P):
         self.assertTrue(np.all(np.linalg.eigvals(q_lambda.cov[p]) > 0))
Exemplo n.º 5
0
 def test_permute(self):
     P = 10
     Q = 4
     q_lambda = vbfa.Lambda(P, Q)
     mean_before = q_lambda.mean.copy()
     cov_before = q_lambda.cov.copy()
     order = [2, 3, 1, 0]
     q_lambda.permute(order)
     self.assertEqual(q_lambda.mean.shape, (P, Q))
     for q in range(Q):
         npt.assert_equal(q_lambda.mean[:, q], mean_before[:, order[q]])
     for p in range(P):
         for i in range(Q):
             for j in range(Q):
                 self.assertEqual(q_lambda.cov[p, q, q],
                                  cov_before[p, order[q], order[q]])