30   return M_[0].NumRows();
    34   if (
M_.empty()) { 
return 0.0; }
    35   else { 
return M_[0].NumCols(); }
    39   return static_cast<int32>(
M_.size());
    56   inverse_var.
Eig(&s, &P);
    77       mean->
AddSpVec(1.0, *var, linear, 0.0);
    80       mean->
AddSpVec(1.0, quadratic, linear, 0.0);
    95     cur_mean.
AddSpVec(1.0, quadratic_inv, linear, 0.0);
    98                   << 
", condition is " << quadratic.
Cond();
   100                   << 
", condition is " << quadratic_inv.
Cond();
   105     double change_threshold = 0.1; 
   107     for (
int32 iter = 0; iter < num_iters; iter++) {
   109         KALDI_VLOG(3) << 
"Auxf on iter " << iter << 
" is "   110                       << 
GetAuxf(utt_stats, cur_mean, &quadratic_inv);
   112         if (show_dim > cur_mean.
Dim()) show_dim = cur_mean.
Dim();
   113         KALDI_VLOG(3) << 
"Current distribution mean is "   114                       << cur_mean.
Range(0, show_dim) << 
"... "   115                       << 
", var trace is " << quadratic_inv.
Trace();
   120                            &this_linear, &this_quadratic);
   123       cur_mean.
AddSpVec(1.0, quadratic_inv, this_linear, 0.0);
   124       mean_diff.
AddVec(-1.0, cur_mean);
   125       double change = mean_diff.
Norm(2.0);
   126       KALDI_VLOG(2) << 
"On iter " << iter << 
", iVector changed by " << change;
   127       if (change < change_threshold)
   156   M_.resize(num_gauss);
   157   for (
int32 i = 0; 
i < num_gauss; 
i++) {
   160     M_[
i].CopyColFromVec(gmm_means.
Row(
i), 0);
   175       extractor_(extractor), i_(i) { }
   176   void operator () () { extractor_->ComputeDerivedVars(i_); }
   183   KALDI_LOG << 
"Computing derived variables for iVector extractor";
   214   U_.
Row(i).CopyFromVec(temp_U_vec);
   245     double gamma_i = utt_stats.
gamma_(
i);
   246     double max_term = std::max(gamma_i, gamma * w(
i));
   247     linear_coeff(
i) = gamma_i - gamma * w(
i) + max_term * logw_unnorm(
i);
   248     quadratic_coeff(
i) = max_term;
   263     double gamma = utt_stats.
gamma_(
i);
   337   KALDI_VLOG(3) << 
"Acoustic auxf is " << (acoustic_auxf/num_frames) << 
"/frame over "   338                 << num_frames << 
" frames, prior auxf is " << prior_auxf
   339                 << 
" = " << (prior_auxf/num_frames) << 
" per frame.";
   340   return acoustic_auxf + prior_auxf;
   352     eigs.ApplyFloor(1.0e-20, &floored);
   354       KALDI_WARN << 
"Floored " << floored << 
" eigenvalues of variance.";
   407     return -0.5 * (
VecVec(offset, offset) + var->
Trace() -
   428   KALDI_VLOG(3) << 
"Per frame, auxf is: weight " << (weight_auxf/T) << 
", gconst "   429                 << (gconst_auxf/T) << 
", mean " << (mean_auxf/T) << 
", var "   430                 << (var_auxf/T) << 
", over " << T << 
" frames.";
   431   return weight_auxf + gconst_auxf + mean_auxf + var_auxf;
   469     double gamma = utt_stats.
gamma_(
i);
   475       K += -0.5 * 
VecVec(x, temp);
   477       a.AddMatVec(gamma, 
M_[i], 
kTrans, temp, 1.0);
   499   if (utt_stats.
S_.empty()) {
   509       double gamma = utt_stats.
gamma_(
i);
   512         var.
Scale(1.0 / gamma);
   514         mean.
Scale(1.0 / gamma);
   524                                          double new_prior_offset) {
   533   KALDI_LOG << 
"Setting iVector prior offset to " << new_prior_offset;
   540     const std::vector<std::pair<int32, BaseFloat> > &gauss_post) {
   545   double tot_weight = 0.0;
   547       quadratic_term_dim = (ivector_dim * (ivector_dim + 1)) / 2;
   551   for (
size_t idx = 0; idx < gauss_post.size(); idx++) {
   552     int32 g = gauss_post[idx].first;
   553     double weight = gauss_post[idx].second;
   562     quadratic_term_vec.AddVec(weight, U_g);
   563     tot_weight += weight;
   565   if (max_count_ > 0.0) {
   568     double old_num_frames = num_frames_,
   569         new_num_frames = num_frames_ + tot_weight;
   570     double old_prior_scale = std::max(old_num_frames, max_count_) / max_count_,
   571         new_prior_scale = std::max(new_num_frames, max_count_) / max_count_;
   575     double prior_scale_change = new_prior_scale - old_prior_scale;
   576     if (prior_scale_change != 0.0) {
   578       quadratic_term_.AddToDiag(prior_scale_change);
   581   num_frames_ += tot_weight;
   595     const std::vector<std::vector<std::pair<int32, BaseFloat> > > &gauss_post,
   596     std::unordered_map<int32, GaussInfo> *gauss_info) {
   597   int32 num_frames = gauss_post.size();
   598   for (
int32 t = 0; t < num_frames; t++) {
   599     const std::vector<std::pair<int32, BaseFloat> > &this_post = gauss_post[t];
   600     auto iter = this_post.begin(), end = this_post.end();
   601     for (; iter != end; ++iter) {
   602       int32 gauss_idx = iter->first;
   603       GaussInfo &info = (*gauss_info)[gauss_idx];
   606       info.
frame_weights.push_back(std::pair<int32, BaseFloat>(t, weight));
   614     const std::vector<std::vector<std::pair<int32, BaseFloat> > > &gauss_post) {
   619   std::unordered_map<int32, GaussInfo> gauss_info;
   623   double tot_weight = 0.0;
   625       quadratic_term_dim = (ivector_dim * (ivector_dim + 1)) / 2;
   629   std::unordered_map<int32, GaussInfo>::const_iterator
   630       iter = gauss_info.begin(), end = gauss_info.end();
   631   for (; iter != end; ++iter) {
   632     int32 gauss_idx = iter->first;
   636     std::vector<std::pair<int32, BaseFloat> >::const_iterator
   638     for (; f_iter != f_end; ++f_iter) {
   639       int32 t = f_iter->first;
   641       weighted_feats.
AddVec(weight, features.
Row(t));
   646                            weighted_feats, 1.0);
   648     quadratic_term_vec.AddVec(this_tot_weight, U_g);
   649     tot_weight += this_tot_weight;
   651   if (max_count_ > 0.0) {
   654     double old_num_frames = num_frames_,
   655         new_num_frames = num_frames_ + tot_weight;
   656     double old_prior_scale = std::max(old_num_frames, max_count_) / max_count_,
   657         new_prior_scale = std::max(new_num_frames, max_count_) / max_count_;
   661     double prior_scale_change = new_prior_scale - old_prior_scale;
   662     if (prior_scale_change != 0.0) {
   664       quadratic_term_.AddToDiag(prior_scale_change);
   667   num_frames_ += tot_weight;
   673   double old_num_frames = num_frames_;
   674   num_frames_ *= scale;
   675   quadratic_term_.Scale(scale);
   676   linear_term_.Scale(scale);
   679   if (max_count_ == 0.0) {
   681     quadratic_term_.AddToDiag(1.0 - scale);
   683     double new_num_frames = num_frames_;
   684     double old_prior_scale =
   685         scale * std::max(old_num_frames, max_count_) / max_count_,
   686         new_prior_scale = std::max(new_num_frames, max_count_) / max_count_;
   690     linear_term_(0) += 
prior_offset_ * (new_prior_scale - old_prior_scale);
   691     quadratic_term_.AddToDiag(new_prior_scale - old_prior_scale);
   696   WriteToken(os, binary, 
"<OnlineIvectorEstimationStats>");
   704   quadratic_term_.Write(os, binary);
   706   linear_term_.Write(os, binary);
   707   WriteToken(os, binary, 
"</OnlineIvectorEstimationStats>");
   711   ExpectToken(is, binary, 
"<OnlineIvectorEstimationStats>");
   716   if (tok == 
"<MaxCount>") {
   726   quadratic_term_.Read(is, binary);
   728   linear_term_.Read(is, binary);
   729   ExpectToken(is, binary, 
"</OnlineIvectorEstimationStats>");
   738   if (num_frames_ > 0.0) {
   743     if ((*ivector)(0) == 0.0)
   747     LinearCgd(opts, quadratic_term_, linear_term_, ivector);
   753   KALDI_VLOG(4) << 
"Objective function improvement from estimating the "   754                 << 
"iVector (vs. default value) is "   755                 << ObjfChange(*ivector);
   760   double ans = Objf(ivector) - DefaultObjf();
   767   if (num_frames_ == 0.0) {
   770     return (1.0 / num_frames_) * (-0.5 * 
VecSpVec(ivector, quadratic_term_,
   772                                   + 
VecVec(ivector, linear_term_));
   777   if (num_frames_ == 0.0) {
   781     return (1.0 / num_frames_) * (-0.5 * quadratic_term_(0, 0) * x * x
   782                                   + x * linear_term_(0));
   789     prior_offset_(prior_offset), max_count_(max_count), num_frames_(0.0),
   790     quadratic_term_(ivector_dim), linear_term_(ivector_dim) {
   791   if (ivector_dim != 0) {
   810   w_.Write(os, binary);
   812   w_vec_.Write(os, binary);
   814   int32 size = M_.size();
   819   KALDI_ASSERT(size == static_cast<int32>(Sigma_inv_.size()));
   821     Sigma_inv_[
i].
Write(os, binary);
   824   WriteToken(os, binary, 
"</IvectorExtractor>");
   833   w_vec_.Read(is, binary);
   840     M_[
i].
Read(is, binary);
   842   Sigma_inv_.resize(size);
   844     Sigma_inv_[
i].
Read(is, binary);
   848   ComputeDerivedVars();
   855   typedef std::vector<std::pair<int32, BaseFloat> > VecType;
   857       num_gauss = X_.NumRows(),
   861   bool update_variance = (!S_.empty());
   863   for (
int32 t = 0; t < num_frames; t++) {
   865     const VecType &this_post(post[t]);
   866     if (update_variance) {
   868       outer_prod.
AddVec2(1.0, frame);
   870     for (VecType::const_iterator iter = this_post.begin();
   871          iter != this_post.end(); ++iter) {
   874                    "Out-of-range Gaussian (mismatched posteriors?)");
   875       double weight = iter->second;
   877       X_.Row(i).AddVec(weight, frame);
   879         S_[
i].AddSp(weight, outer_prod);
   887   for (
size_t i = 0; 
i < S_.size(); 
i++)
   894     config_(stats_opts) {
   939     Y_[
i].AddVecVec(1.0, utt_stats.
X_.
Row(
i),
   945   ivec_scatter.
AddVec2(1.0, ivec_mean);
   955   int32 ivector_dim = ivec_mean.
Dim();
   957                                      ivector_dim * (ivector_dim + 1) / 2);
   966     KALDI_VLOG(1) << 
"Flushing cache for IvectorExtractorStats";
   980                  R_ivec_scatter_cache, 
kNoTrans, 1.0);
   996     S_[
i].AddSp(1.0, utt_stats.
S_[
i]);
  1020   for (
int32 i = 0; 
i < num_gauss; 
i++) {
  1021     double gamma_i = utt_stats.
gamma_(
i);
  1022     double max_term = std::max(gamma_i, gamma * w(
i));
  1023     linear_coeff(
i) = gamma_i - gamma * w(
i) + max_term * logw_unnorm(
i);
  1024     quadratic_coeff(
i) = max_term;
  1031   outer_prod.
AddVec2(1.0, ivector);
  1033                                    ivector_dim * (ivector_dim + 1) / 2);
  1034   Q_.
AddVecVec(weight, quadratic_coeff, outer_prod_vec);
  1054   ivecs.AddVecToRows(-1.0, avg_ivec);
  1059   ivecs.AddVecToRows(1.0, ivec_mean);
  1071   ivec_scatter.
AddVec2(1.0, ivec_mean);
  1136   typedef std::vector<std::pair<int32, BaseFloat> > VecType;
  1142   if (feat_dim != feats.
NumCols()) {
  1143     KALDI_ERR << 
"Feature dimension mismatch, expected " << feat_dim
  1144               << 
", got " << feats.
NumCols();
  1148   bool update_variance = (!
S_.empty());
  1166   double tot_log_like = 0.0;
  1167   for (
int32 t = 0; t < num_frames; t++) {
  1171     for (
int32 i = 0; 
i < posterior.Dim(); 
i++)
  1172       post[t].push_back(std::make_pair(
i, posterior(
i)));
  1175   return tot_log_like;
  1181   double weight = 1.0; 
  1185   for (
size_t i = 0; 
i < 
Y_.size(); 
i++)
  1186     Y_[
i].AddMat(weight, other.
Y_[
i]);
  1191   for (
size_t i = 0; 
i < 
S_.size(); 
i++)
  1192     S_[
i].AddSp(weight, other.
S_[
i]);
  1207   WriteToken(os, binary, 
"<IvectorExtractorStats>");
  1219   R_float.
Write(os, binary);
  1222   Q_float.
Write(os, binary);
  1236   WriteToken(os, binary, 
"</IvectorExtractorStats>");
  1241   ExpectToken(is, binary, 
"<IvectorExtractorStats>");
  1253   R_.
Read(is, binary, add);
  1255   Q_.
Read(is, binary, add);
  1257   G_.
Read(is, binary, add);
  1269   ExpectToken(is, binary, 
"</IvectorExtractorStats>");
  1277     KALDI_LOG << 
"Overall auxf/frame on training data was "  1292   KALDI_LOG << 
"Overall objective-function improvement per frame was " << ans;
  1304                       B(extractor.
M_[0].NumRows());
  1310     W.AddSp(w(
i), Sigma_i);
  1313   double trace_W = W.Trace(),
  1314          trace_B = B.Trace();
  1315   KALDI_LOG << 
"The proportion of within-Gaussian variance explained by "  1316             << 
"the iVectors is " << trace_B / (trace_B + trace_W) << 
".";
  1330     KALDI_WARN << 
"Skipping Gaussian index " << i << 
" because count "  1331                << 
gamma_(i) << 
" is below min-count.";
  1341   solver_opts.
name = 
"M";
  1346     KALDI_VLOG(1) << 
"Objf impr for M for Gaussian index " << i << 
" is "  1347                   << (impr / gamma) << 
" per frame over " << gamma << 
" frames.";
  1349   extractor->
M_[
i].CopyFromMat(M);
  1360   int32 quad_dim = ivector_dim*(ivector_dim + 1)/2;
  1369     for (
int32 i = 0; 
i < num_gauss; 
i++) w_uniform(
i) = 1.0;
  1372     uavg_vec.AddMatVec(1.0, extractor->
U_, 
kTrans, extractor->
w_vec_, 0.0);
  1380                            1, ivector_dim-1, 1, ivector_dim-1),
  1382   Vavg.CopyFromMat(Vavg_temp);
  1391   KALDI_LOG << 
"Eigenvalues of Vavg: " << s;
  1401       stats_(stats), opts_(opts), i_(i), extractor_(extractor),
  1402       tot_impr_(tot_impr), impr_(0.0) { }
  1403   void operator () () {
  1404     impr_ = stats_.UpdateProjection(opts_, i_, extractor_);
  1420   double tot_impr = 0.0;
  1428           *
this, opts, 
i, extractor, &tot_impr));
  1431   KALDI_LOG << 
"Overall objective function improvement for M (mean projections) "  1432             << 
"was " << (tot_impr / 
count) << 
" per frame over "  1433             << count << 
" frames.";
  1434   return tot_impr / 
count;
  1441       feat_dim = extractor->
FeatDim(),
  1444   double tot_objf_impr = 0.0;
  1448   std::vector<SpMatrix<double> > raw_variances(num_gauss);
  1450   double var_floor_count = 0.0;
  1452   for (
int32 i = 0; 
i < num_gauss; 
i++) {
  1471     S.
AddSp(-1.0, YMMY_sp);
  1477                             ivector_dim * (ivector_dim + 1) / 2);
  1482     var_floor.
AddSp(1.0, S);
  1483     var_floor_count += 
gamma_(i);
  1497   if (eig_floored > 0) {
  1498     KALDI_WARN << 
"Floored " << eig_floored << 
" eigenvalues of the "  1499                << 
"variance floor matrix.  This is not expected.  Maybe your "  1500                << 
"feature data is linearly dependent.";
  1503   int32 tot_num_floored = 0;
  1504   for (
int32 i = 0; 
i < num_gauss; 
i++) {
  1506     if (S.
NumRows() == 0) 
continue; 
  1511     tot_num_floored += num_floored;
  1512     if (num_floored > 0)
  1513       KALDI_LOG << 
"For Gaussian index " << i << 
", floored "  1514                 << num_floored << 
" eigenvalues of variance.";
  1516     double old_objf = -0.5 * (
TraceSpSp(S, old_inv_var) -
  1522     double new_objf = -0.5 * (
TraceSpSp(S, new_inv_var) -
  1525       KALDI_VLOG(1) << 
"Objf impr/frame for variance for Gaussian index "  1526                     << i << 
" was " << (new_objf - old_objf);
  1528     tot_objf_impr += 
gamma_(i) * (new_objf - old_objf);
  1531   double floored_percent = tot_num_floored * 100.0 / (num_gauss * feat_dim);
  1532   KALDI_LOG << 
"Floored " << floored_percent << 
"% of all Gaussian eigenvalues";
  1534   KALDI_LOG << 
"Overall objf impr/frame for variances was "  1535             << (tot_objf_impr / 
gamma_.
Sum()) << 
" over "  1551   solver_opts.
name = 
"w";
  1559   if (i < 4 && 
gamma_(i) != 0.0) {
  1560     KALDI_VLOG(1) << 
"Auxf impr/frame for Gaussian index " << i
  1561                   << 
" for weights is " << (objf_impr / 
gamma_(i))
  1562                   << 
" over " << 
gamma_(i) << 
" frames.";
  1574       stats_(stats), opts_(opts), i_(i), extractor_(extractor),
  1575       tot_impr_(tot_impr), impr_(0.0) { }
  1576   void operator () () {
  1577     impr_ = stats_.UpdateWeight(opts_, i_, extractor_);
  1594   double tot_impr = 0.0;
  1602           *
this, opts, 
i, extractor, &tot_impr));
  1606   KALDI_LOG << 
"Overall auxf impr/frame from weight update is "  1607             << (tot_impr / num_frames) << 
" over "  1608             << num_frames << 
" frames.";
  1609   return tot_impr / num_frames;
  1631   mean_offset(0) -= old_prior_offset;
  1634   old_covar.
AddVec2(1.0, mean_offset);
  1636   double old_like = -0.5 * old_covar.
Trace();
  1640   double new_like = -0.5 * (ivector_dim + covar.
LogPosDefDet()),
  1641       like_change = new_like - old_like,
  1644   KALDI_LOG << 
"Overall auxf improvement from prior is " << like_change_per_frame
  1645             << 
" per frame, or " << like_change << 
" per iVector.";
  1646   return like_change_per_frame; 
  1667   KALDI_LOG << 
"Eigenvalues of iVector covariance range from "  1668             << s.
Min() << 
" to " << s.
Max();
  1671   if (num_floored > 0)
  1672     KALDI_WARN << 
"Floored " << num_floored << 
" eigenvalues of covar "  1681     if (num_floored == 0) { 
  1689   sum_proj.AddMatVec(1.0, T, 
kNoTrans, sum, 0.0);
  1717   double x0 = x(0), alpha, beta;
  1718   alpha = 1.0 / (
M_SQRT2 * sqrt(1.0 - x0));
  1738                                   Vtemp.NumRows(), 1, Vtemp.NumCols()-1),
  1746   if (num_floored == 0) { 
  1754   sum_vproj.AddMatVec(1.0, V, 
kNoTrans, sum, 0.0);
  1782     int32 ivector_period,
  1790       num_ivectors = (num_frames + ivector_period - 1) / ivector_period;
  1802   for (
int32 frame = 0; frame < num_frames; frame++) {
  1803     online_stats.AccStats(extractor,
  1806     if (frame % ivector_period == 0) {
  1807       online_stats.GetIvector(num_cg_iters, &cur_ivector);
  1808       int32 ivector_index = frame / ivector_period;
  1809       ivectors->
Row(ivector_index).CopyFromVec(cur_ivector);
  1810       if (ivector_index == num_ivectors - 1)  
  1811         ans = online_stats.ObjfChange(cur_ivector);
 
This code computes Goodness of Pronunciation (GOP) and extracts phone-level pronunciation feature for...
 
static double GetLogDetNoFailure(const SpMatrix< double > &var)
 
bool IsUnit(Real cutoff=1.0e-05) const
 
double ObjfChange(const VectorBase< double > &ivector) const
ObjfChange returns the change in objective function *per frame* from using the default value [ prior_...
 
void Write(std::ostream &out, bool binary) const
write to stream. 
 
void ApplyExp()
Apply exponential to each value in vector. 
 
const std::vector< SpMatrix< BaseFloat > > & inv_covars() const
 
This class describes the options for maximizing various quadratic objective functions. 
 
double SolveQuadraticProblem(const SpMatrix< double > &H, const VectorBase< double > &g, const SolverOptions &opts, VectorBase< double > *x)
 
void Read(std::istream &in, bool binary, bool add=false)
 
void AddRowSumMat(Real alpha, const MatrixBase< Real > &M, Real beta=1.0)
Does *this = alpha * (sum of rows of M) + beta * *this. 
 
void Write(std::ostream &out, bool binary) const
 
void Run(C *c)
This function takes ownership of the pointer "c", and will delete it in the same sequence as Run was ...
 
BaseFloat ComponentPosteriors(const VectorBase< BaseFloat > &data, VectorBase< BaseFloat > *posterior) const
Computes the posterior probabilities of all Gaussian components given a data point. 
 
void AddMat2Vec(const Real alpha, const MatrixBase< Real > &M, MatrixTransposeType transM, const VectorBase< Real > &v, const Real beta=0.0)
Extension of rank-N update: this <– beta*this + alpha * M * diag(v) * M^T. 
 
MatrixIndexT NumCols() const
Returns number of columns (or zero for empty matrix). 
 
Real SolveQuadraticMatrixProblem(const SpMatrix< Real > &Q, const MatrixBase< Real > &Y, const SpMatrix< Real > &SigmaInv, const SolverOptions &opts, MatrixBase< Real > *M)
Maximizes the auxiliary function :  Like a numerically stable version of . 
 
Base class which provides matrix operations not involving resizing or allocation. ...
 
void ReadBasicType(std::istream &is, bool binary, T *t)
ReadBasicType is the name of the read function for bool, integer types, and floating-point types...
 
void AccStats(const IvectorExtractor &extractor, const VectorBase< BaseFloat > &feature, const std::vector< std::pair< int32, BaseFloat > > &gauss_post)
 
Definition for Gaussian Mixture Model with full covariances. 
 
int32 GetVerboseLevel()
Get verbosity level, usually set via command line '–verbose=' switch. 
 
void Write(std::ostream &Out, bool binary) const
Writes to C++ stream (option to write in binary). 
 
void AddMat(const Real alpha, const MatrixBase< Real > &M, MatrixTransposeType transA=kNoTrans)
*this += alpha * M [or M^T] 
 
void Read(std::istream &is, bool binary)
 
void ReadToken(std::istream &is, bool binary, std::string *str)
ReadToken gets the next token and puts it in str (exception on failure). 
 
void Eig(VectorBase< Real > *s, MatrixBase< Real > *P=NULL) const
Solves the symmetric eigenvalue problem: at end we should have (*this) = P * diag(s) * P^T...
 
This class helps us to efficiently estimate iVectors in situations where the data is coming in frame ...
 
bool diagonal_precondition
 
static void ConvertPostToGaussInfo(const std::vector< std::vector< std::pair< int32, BaseFloat > > > &gauss_post, std::unordered_map< int32, GaussInfo > *gauss_info)
 
void ApplyLog()
Apply natural log to all elements. 
 
void Resize(MatrixIndexT length, MatrixResizeType resize_type=kSetZero)
Set vector to a specified size (can be zero). 
 
void AddSpVec(const Real alpha, const SpMatrix< Real > &M, const VectorBase< Real > &v, const Real beta)
Add symmetric positive definite matrix times vector: this <– beta*this + alpha*M*v. 
 
Real LogSumExp(Real prune=-1.0) const
Returns log(sum(exp())) without exp overflow If prune > 0.0, ignores terms less than the max - prune...
 
Real ApplySoftMax()
Apply soft-max to vector and return normalizer (log sum of exponentials). 
 
Real Min() const
Returns the minimum value of any element, or +infinity for the empty vector. 
 
MatrixIndexT NumRows() const
 
void SetUnit()
Sets to zero, except ones along diagonal [for non-square matrices too]. 
 
void CopyFromSp(const SpMatrix< Real > &other)
 
Real Norm(Real p) const
Compute the p-th norm of the vector. 
 
OnlineIvectorEstimationStats(int32 ivector_dim, BaseFloat prior_offset, BaseFloat max_count)
 
double Objf(const VectorBase< double > &ivector) const
Returns objective function per frame, at this iVector value. 
 
int ApplyFloor(const SpMatrix< Real > &Floor, Real alpha=1.0, bool verbose=false)
Floors this symmetric matrix to the matrix alpha * Floor, where the matrix Floor is positive definite...
 
void ApplyFloor(Real floor_val, MatrixIndexT *floored_count=nullptr)
Applies floor to all elements. 
 
void CopyFromVec(const VectorBase< Real > &v)
Copy data from another vector (must match own size). 
 
void AddToDiag(const Real r)
 
void AddVec2(const Real alpha, const VectorBase< OtherReal > &v)
rank-one update, this <– this + alpha v v' 
 
void Read(std::istream &in, bool binary, bool add=false)
read from stream. 
 
void Cholesky(const SpMatrix< Real > &orig)
 
std::vector< std::vector< std::pair< int32, BaseFloat > > > Posterior
Posterior is a typedef for storing acoustic-state (actually, transition-id) posteriors over an uttera...
 
Real LogPosDefDet() const
Computes log determinant but only for +ve-def matrices (it uses Cholesky). 
 
const SubVector< Real > Row(MatrixIndexT i) const
Return specific row of matrix [const]. 
 
void Scale(Real alpha)
Multiply each element with a scalar value. 
 
void GetIvector(int32 num_cg_iters, VectorBase< double > *ivector) const
This function gets the current estimate of the iVector. 
 
void AddSp(const Real alpha, const SpMatrix< Real > &Ma)
 
void ExpectToken(std::istream &is, bool binary, const char *token)
ExpectToken tries to read in the given token, and throws an exception on failure. ...
 
void Write(std::ostream &os, bool binary) const
 
void SetRandn()
Sets to random values of a normal distribution. 
 
void AddMatMat(const Real alpha, const MatrixBase< Real > &A, MatrixTransposeType transA, const MatrixBase< Real > &B, MatrixTransposeType transB, const Real beta)
 
Real Max() const
Returns the maximum value of any element, or -infinity for the empty vector. 
 
double TraceSpSp(const SpMatrix< double > &A, const SpMatrix< double > &B)
 
Real VecSpVec(const VectorBase< Real > &v1, const SpMatrix< Real > &M, const VectorBase< Real > &v2)
Computes v1^T * M * v2. 
 
int32 NumGauss() const
Returns the number of mixture components in the GMM. 
 
void WriteToken(std::ostream &os, bool binary, const char *token)
The WriteToken functions are for writing nonempty sequences of non-space characters. 
 
MatrixIndexT Dim() const
Returns the dimension of the vector. 
 
void SetZero()
Sets matrix to zero. 
 
void Scale(Real alpha)
Multiplies all elements by this constant. 
 
const Vector< BaseFloat > & weights() const
 
void AddMatVec(const Real alpha, const MatrixBase< Real > &M, const MatrixTransposeType trans, const VectorBase< Real > &v, const Real beta)
Add matrix times vector : this <– beta*this + alpha*M*v. 
 
Real Sum() const
Returns sum of the elements. 
 
void MulRowsVec(const VectorBase< Real > &scale)
Equivalent to (*this) = diag(scale) * (*this). 
 
void GetMeans(Matrix< Real > *m) const
Accessor for means. 
 
double EstimateIvectorsOnline(const Matrix< BaseFloat > &feats, const Posterior &post, const IvectorExtractor &extractor, int32 ivector_period, int32 num_cg_iters, BaseFloat max_count, Matrix< BaseFloat > *ivectors)
 
SpMatrix< double > quadratic_term_
 
void InvertElements()
Invert all elements. 
 
#define KALDI_ASSERT(cond)
 
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix). 
 
void AddMat2Sp(const Real alpha, const MatrixBase< Real > &M, MatrixTransposeType transM, const SpMatrix< Real > &A, const Real beta=0.0)
Extension of rank-N update: this <– beta*this + alpha * M * A * M^T. 
 
void ApplyPow(Real power)
Take all elements of vector to a power. 
 
Vector< double > linear_term_
 
Real Cond() const
Returns maximum ratio of singular values. 
 
void AddVecVec(const Real alpha, const VectorBase< OtherReal > &a, const VectorBase< OtherReal > &b)
*this += alpha * a * b^T 
 
double DefaultObjf() const
Returns objective function evaluated at the point [ prior_offset_, 0, 0, 0, ... 
 
int32 LinearCgd(const LinearCgdOptions &opts, const SpMatrix< Real > &A, const VectorBase< Real > &b, VectorBase< Real > *x)
 
SubMatrix< Real > Range(const MatrixIndexT row_offset, const MatrixIndexT num_rows, const MatrixIndexT col_offset, const MatrixIndexT num_cols) const
Return a sub-part of matrix. 
 
void WriteBasicType(std::ostream &os, bool binary, T t)
WriteBasicType is the name of the write function for bool, integer types, and floating-point types...
 
void Resize(const MatrixIndexT r, const MatrixIndexT c, MatrixResizeType resize_type=kSetZero, MatrixStrideType stride_type=kDefaultStride)
Sets matrix to a specified size (zero is OK as long as both r and c are zero). 
 
void Resize(MatrixIndexT nRows, MatrixResizeType resize_type=kSetZero)
 
void Invert(Real *log_det=NULL, Real *det_sign=NULL, bool inverse_needed=true)
matrix inverse. 
 
void AddMatTp(const Real alpha, const MatrixBase< Real > &A, MatrixTransposeType transA, const TpMatrix< Real > &B, MatrixTransposeType transB, const Real beta)
this <– beta*this + alpha*A*B. 
 
Provides a vector abstraction class. 
 
void Add(Real c)
Add a constant to each element of a vector. 
 
void SetZero()
Set vector to all zeros. 
 
void Invert(Real *logdet=NULL, Real *det_sign=NULL, bool inverse_needed=true)
matrix inverse. 
 
Real VecVec(const VectorBase< Real > &a, const VectorBase< Real > &b)
Returns dot product between v1 and v2. 
 
void AddVec(const Real alpha, const VectorBase< OtherReal > &v)
Add vector : *this = *this + alpha * rv (with casting between floats and doubles) ...
 
Real MaxAbsEig() const
Returns the maximum of the absolute values of any of the eigenvalues. 
 
std::vector< std::pair< int32, BaseFloat > > frame_weights
 
Sub-matrix representation. 
 
void Read(std::istream &in, bool binary, bool add=false)
Read function using C++ streams. 
 
Represents a non-allocating general vector which can be defined as a sub-vector of higher-level vecto...
 
static bool ApproxEqual(float a, float b, float relative_tolerance=0.001)
return abs(a - b) <= relative_tolerance * (abs(a)+abs(b)). 
 
void Scale(double scale)
Scales the number of frames of stats by 0 <= scale <= 1, to make it as if we had fewer frames of adap...
 
void SortSvd(VectorBase< Real > *s, MatrixBase< Real > *U, MatrixBase< Real > *Vt, bool sort_on_absolute_value)
Function to ensure that SVD is sorted. 
 
SubVector< Real > Range(const MatrixIndexT o, const MatrixIndexT l)
Returns a sub-vector of a vector (a range of elements).