Skip to content
Merged
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
16 changes: 12 additions & 4 deletions src/ivectorbin/ivector-plda-scoring-dense.cc
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,14 @@
namespace kaldi {

bool EstPca(const Matrix<BaseFloat> &ivector_mat, BaseFloat target_energy,
Matrix<BaseFloat> *mat) {
const std::string &reco, Matrix<BaseFloat> *mat) {

// If the target_energy is 1.0, it's equivalent to not applying the
// conversation-dependent PCA at all, so it's better to exit this
// function before doing any computation.
if (ApproxEqual(target_energy, 1.0, 0.001))
return false;

int32 num_rows = ivector_mat.NumRows(),
num_cols = ivector_mat.NumCols();
Vector<BaseFloat> sum;
Expand All @@ -50,6 +57,8 @@ bool EstPca(const Matrix<BaseFloat> &ivector_mat, BaseFloat target_energy,
else
Matrix<BaseFloat>(sumsq).Svd(&s, &P, NULL);
} catch (...) {
KALDI_WARN << "Unable to compute conversation dependent PCA for"
<< " recording " << reco << ".";
return false;
}

Expand Down Expand Up @@ -181,7 +190,7 @@ int main(int argc, char *argv[]) {
for (size_t i = 0; i < ivectors.size(); i++) {
ivector_mat.Row(i).CopyFromVec(ivectors[i]);
}
if (EstPca(ivector_mat, target_energy, &pca_transform)) {
if (EstPca(ivector_mat, target_energy, reco, &pca_transform)) {
// Apply the PCA transform to the raw i-vectors.
ApplyPca(ivector_mat, pca_transform, &ivector_mat_pca);

Expand All @@ -192,8 +201,7 @@ int main(int argc, char *argv[]) {
TransformIvectors(ivector_mat_pca, plda_config, this_plda,
&ivector_mat_plda);
} else {
KALDI_WARN << "Unable to compute conversation dependent PCA for"
<< " recording " << reco << ".";
// If EstPca returns false, we won't apply any PCA.
TransformIvectors(ivector_mat, plda_config, this_plda,
&ivector_mat_plda);
}
Expand Down