Skip to content

Commit dd1fafa

Browse files
Merge pull request #154 from hyperion-ml/persephone-refactor
debug gmm
2 parents 38cc512 + ad9de1c commit dd1fafa

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

hyperion/np/clustering/kmeans.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,14 +188,14 @@ def _compute_centroids(self, x, index):
188188
for k in range(self.num_clusters):
189189
r = index == k
190190
if np.sum(r) > 0:
191-
mu[k] = np.mean(x[index == k], axis=0)
191+
mu[k] = np.mean(x[r], axis=0)
192192
return mu
193193

194194
@staticmethod
195195
def _compute_centroid(x, index, k):
196196
r = index == k
197197
if np.sum(r) > 0:
198-
return np.mean(x[index == k], axis=0)
198+
return np.mean(x[r], axis=0)
199199
else:
200200
return None
201201

hyperion/np/pdfs/mixtures/exp_family_mixture.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Copyright 2018 Johns Hopkins University (Author: Jesus Villalba)
33
Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
44
"""
5+
56
import logging
67

78
import numpy as np
@@ -104,6 +105,8 @@ def fit(
104105
)
105106
elbo_val[epoch] = self.elbo(None, N=N, u_x=u_x, log_h=log_h_val)
106107

108+
print(self.log_prob(x, mode="nat"), self.log_prob(x, mode="std"))
109+
107110
if x_val is None:
108111
return elbo, elbo / x.shape[0]
109112
else:

hyperion/np/pdfs/mixtures/gmm_diag_cov.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,11 @@ def Mstep(self, N, u_x):
180180

181181
if self.update_Lambda:
182182
S = S / N[:, None] - self.mu**2
183+
print("1", S)
183184
S_floor = self.var_floor * np.mean(S[N > self.min_N], axis=0)
184185
S_floor = np.maximum(S_floor, 1e-10)
185186
S = np.maximum(S, S_floor)
187+
print("2", S)
186188
print(np.min(S))
187189
self.Lambda = 1 / S
188190
self._Sigma = S

0 commit comments

Comments
 (0)