Last active
March 2, 2019 14:13
-
-
Save DFoly/f5e095fda89784c926ddd502a562b317 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def _compute_loss_function(self, X, pi, mu, sigma): | |
"""Computes lower bound loss function | |
Parameters: | |
----------- | |
X: (N x d), data | |
Returns: | |
--------- | |
pi: (C) | |
mu: (C x d) | |
sigma: (C x d x d) | |
""" | |
N = X.shape[0] | |
C = self.gamma.shape[1] | |
self.loss = np.zeros((N, C)) | |
for c in range(C): | |
dist = mvn(self.mu[c], self.sigma[c],allow_singular=True) | |
self.loss[:,c] = self.gamma[:,c] * (np.log(self.pi[c]+0.00001)+dist.logpdf(X)-np.log(self.gamma[:,c]+0.000001)) | |
self.loss = np.sum(self.loss) | |
return self.loss |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment