Пример #1
0
 def log_likelihoods(self, data, input, mask, tag, x):
     etas, nus = np.exp(self.inv_etas), np.exp(self.inv_nus)
     mus = self.forward(x, input, tag)
     return independent_studentst_logpdf(data[:, None, :],
                                         mus,
                                         etas,
                                         nus,
                                         mask=mask[:, None, :])
Пример #2
0
 def log_likelihoods(self, data, input, mask, tag):
     D, mus, sigmas, nus = self.D, self.mus, np.exp(
         self.inv_sigmas), np.exp(self.inv_nus)
     nus = np.tile(nus[:, None], (1, self.D))
     mask = np.ones_like(data, dtype=bool) if mask is None else mask
     return stats.independent_studentst_logpdf(data[:, None, :],
                                               mus,
                                               sigmas,
                                               nus,
                                               mask=mask[:, None, :])
Пример #3
0
 def log_likelihoods(self, data, input, mask, tag):
     D = self.D
     mus = self._compute_mus(data, input, mask, tag)
     sigmas = self._compute_sigmas(data, input, mask, tag)
     nus = np.exp(self.inv_nus)
     nus = np.tile(nus[:, None], (1, self.D))
     return stats.independent_studentst_logpdf(data[:, None, :],
                                               mus,
                                               sigmas,
                                               nus,
                                               mask=mask[:, None, :])
Пример #4
0
def test_independent_studentst_logpdf(T=100, K=4, D=10):
    # Test single datapoint log pdf
    x = npr.randn(T, D)
    mu = npr.randn(K, D)
    sigmasqs = np.exp(npr.randn(K, D))
    nus = np.exp(npr.randn(K, D))

    ll1 = independent_studentst_logpdf(x[:, None, :], mu, sigmasqs, nus)
    ll2 = np.sum(t.logpdf(x[:, None, :],
                          nus[None, :, :],
                          loc=mu[None, :, :],
                          scale=np.sqrt(sigmasqs[None, :, :])),
                 axis=-1)
    assert np.allclose(ll1, ll2)