Skip to content

Persephone refactor #152

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jun 10, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions egs/voxceleb/ssl.v1/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,8 +141,9 @@ run_xxx_xxxx.sh --config-file global_conf/other_config.sh
| | | | | | PLDA | 4.04 | 0.185 | 0.291 |
| | | | | FT-1 | Cosine | 2.03 | 0.125 | 0.203 |
| | | | | FT-1 | PLDA | 2.44 | 0.149 | 0.231 |
| | | | | FT-2 | Cosine |
| | | | | FT-2 | PLDA |
| | | | | FT-2 | Cosine | 1.88 | 0.115 | 0.198 |
| | | | | FT-2 | PLDA | 2.57 | 0.147 | 0.234 |



### VoxCeleb 1 Entire-Clean trial list
Expand Down Expand Up @@ -171,8 +172,9 @@ run_xxx_xxxx.sh --config-file global_conf/other_config.sh
| | | | | | PLDA | 4.32 | 0.166 | 0.263 |
| | | | | FT-1 | Cosine | 2.61 | 0.138 | 0.210 |
| | | | | FT-1 | PLDA | 2.72 | 0.1366 | 0.216 |
| | | | | FT-2 | Cosine |
| | | | | FT-2 | PLDA |
| | | | | FT-2 | Cosine | 2.41 | 0.121 | 0.193 |
| | | | | FT-2 | PLDA | 2.82 | 0.140 | 0.219 |



### VoxCeleb 1 Hard-Clean trial list
Expand Down Expand Up @@ -201,6 +203,5 @@ run_xxx_xxxx.sh --config-file global_conf/other_config.sh
| | | | | | PLDA | 5.95 | 0.269 | 0.438 |
| | | | | FT-1 | Cosine | 4.38 | 0.222 | 0.337 |
| | | | | FT-1 | PLDA | 4.68 | 0.237 | 0.375 |
| | | | | FT-2 | Cosine |
| | | | | FT-2 | PLDA |

| | | | | FT-2 | Cosine | 4.07 | 0.197 | 0.301 |
| | | | | FT-2 | PLDA | 4.75 | 0.229 | 0.352 |
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ cluster_ft_s1_dir=exp/clustering/$nnet_ft_s1_2_name/$cluster_ft_s1_name
nnet_ft_s2_1_base_cfg=conf/train_fwseresnet34_xvec_stage1.1_v1.2.2.yaml
nnet_ft_s2_1_name=$nnet_name.s1.ft.s2.1
nnet_ft_s2_1_dir=exp/xvector_nnets/$nnet_ft_s2_1_name
nnet_ft_s2_1=$nnet_ft_s2_1_dir/model_ep0030.pth
nnet_ft_s2_1=$nnet_ft_s2_1_dir/model_ep0025.pth

# finetuning stage 2.2
nnet_ft_s2_2_base_cfg=conf/train_fwseresnet34_xvec_stage1.2_v1.2.2.yaml
Expand Down
13 changes: 7 additions & 6 deletions hyperion/np/pdfs/mixtures/gmm.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright 2018 Johns Hopkins University (Author: Jesus Villalba)
Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
"""

import h5py
import numpy as np
import scipy.linalg as la
Expand Down Expand Up @@ -150,8 +151,8 @@ def _initialize_kmeans(self, num_comp, x):
self.Lambda[0] = invert_pdmat(S, return_inv=True)[-1]
return

kmeans = KMeans(num_clusters=num_comp)
loss, cluster_index = kmeans.fit(x, epochs=100)
kmeans = KMeans(num_clusters=num_comp, epochs=100)
loss, cluster_index = kmeans.fit(x)

self.mu = kmeans.mu
self.pi = np.zeros((self.num_comp,), dtype=float_cpu())
Expand Down Expand Up @@ -253,7 +254,7 @@ def split_comp(self, K=2):
"""
num_comp = self.num_comp * K
pi = np.repeat(self.pi, K) / K
Lambda = np.repeat(self.Lambda, K, axis=0) * (K ** 2)
Lambda = np.repeat(self.Lambda, K, axis=0) * (K**2)
mu = np.repeat(self.mu, K, axis=0)

for g in range(self.num_comp):
Expand Down Expand Up @@ -400,7 +401,7 @@ def load_from_kaldi(cls, file_path):
x_dim = len(fields)
eta1 = np.zeros((num_comp, x_dim), dtype=float_cpu())
eta2 = np.zeros(
(num_comp, int((x_dim ** 2 + 3 * x_dim) / 2)),
(num_comp, int((x_dim**2 + 3 * x_dim) / 2)),
dtype=float_cpu(),
)

Expand Down Expand Up @@ -436,7 +437,7 @@ def _validate_Lambda(self):

def _validate_eta(self):
assert self.eta.shape[0] == self.num_comp
assert self.eta.shape[1] == (self.x_dim ** 2 + 3 * self.x_dim) / 2
assert self.eta.shape[1] == (self.x_dim**2 + 3 * self.x_dim) / 2

def validate(self):
"""Validates the parameters of the distribution."""
Expand All @@ -454,7 +455,7 @@ def validate(self):
def compute_eta(mu, Lambda):
"""Computes nat param. from mean and precision."""
x_dim = mu.shape[-1]
eta_dim = int((x_dim ** 2 + 3 * x_dim) / 2)
eta_dim = int((x_dim**2 + 3 * x_dim) / 2)
eta = np.zeros((mu.shape[0], eta_dim), dtype=float_cpu())
for k in range(mu.shape[0]):
eta[k] = Normal.compute_eta(mu[k], Lambda[k])
Expand Down
4 changes: 2 additions & 2 deletions hyperion/np/pdfs/mixtures/gmm_diag_cov.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,8 +121,8 @@ def _initialize_kmeans(self, num_comp, x):
self.Lambda = 1 / np.std(x, axis=0, keepdims=True) ** 2
return

kmeans = KMeans(num_clusters=num_comp)
loss, cluster_index = kmeans.fit(x, epochs=100)
kmeans = KMeans(num_clusters=num_comp, epochs=100)
loss, cluster_index = kmeans.fit(x)

self.mu = kmeans.mu
self.pi = np.zeros((self.num_comp,), dtype=float_cpu())
Expand Down
9 changes: 5 additions & 4 deletions hyperion/np/pdfs/mixtures/gmm_tied_diag_cov.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
Copyright 2018 Johns Hopkins University (Author: Jesus Villalba)
Apache 2.0 (http://www.apache.org/licenses/LICENSE-2.0)
"""

import h5py
import numpy as np
from scipy.special import erf
Expand Down Expand Up @@ -83,8 +84,8 @@ def _initialize_kmeans(self, num_comp, x):
self.Lambda = 1 / np.std(x, axis=0, keepdims=True) ** 2
return

kmeans = KMeans(num_clusters=num_comp)
loss, cluster_index = kmeans.fit(x, epochs=100)
kmeans = KMeans(num_clusters=num_comp, epochs=100)
loss, cluster_index = kmeans.fit(x)

self.mu = kmeans.mu
self.pi = np.zeros((self.num_comp,), dtype=float_cpu())
Expand All @@ -93,7 +94,7 @@ def _initialize_kmeans(self, num_comp, x):
r = cluster_index == k
self.pi[k] = np.sum(r) / x.shape[0]
delta = x[r] - self.mu[k]
C += np.sum(delta ** 2, axis=0)
C += np.sum(delta**2, axis=0)

self.Lambda = x.shape[0] / C

Expand All @@ -111,7 +112,7 @@ def Mstep(self, N, u_x):
self.mu = F / N[:, None]

if self.update_Lambda:
S = S / N[:, None] - self.mu ** 2
S = S / N[:, None] - self.mu**2
S_floor = self.var_floor * np.mean(S[N > self.min_N], axis=0)
S = np.maximum(S, S_floor)
Spool = np.sum(N[:, None] * S, axis=0) / np.sum(N)
Expand Down