CovarianceStats Class Reference
Collaboration diagram for CovarianceStats:

Public Member Functions

 CovarianceStats (int32 dim)
 
void GetTotalCovar (SpMatrix< double > *tot_covar) const
 get total covariance, normalized per number of frames. More...
 
void GetWithinCovar (SpMatrix< double > *within_covar)
 
void AccStats (const Matrix< double > &utts_of_this_spk)
 
bool SingularTotCovar ()
 Will return Empty() if the within-class covariance matrix would be zero. More...
 
bool Empty ()
 
std::string Info ()
 
int32 Dim ()
 
void AddStats (const CovarianceStats &other)
 

Private Member Functions

 KALDI_DISALLOW_COPY_AND_ASSIGN (CovarianceStats)
 

Private Attributes

SpMatrix< double > tot_covar_
 
SpMatrix< double > between_covar_
 
int32 num_spk_
 
int32 num_utt_
 

Detailed Description

Definition at line 30 of file ivector-compute-lda.cc.

Constructor & Destructor Documentation

◆ CovarianceStats()

CovarianceStats ( int32  dim)
inline

Definition at line 32 of file ivector-compute-lda.cc.

32  : tot_covar_(dim),
33  between_covar_(dim),
34  num_spk_(0),
35  num_utt_(0) { }
SpMatrix< double > tot_covar_
SpMatrix< double > between_covar_

Member Function Documentation

◆ AccStats()

void AccStats ( const Matrix< double > &  utts_of_this_spk)
inline

Definition at line 49 of file ivector-compute-lda.cc.

References SpMatrix< Real >::AddMat2(), VectorBase< Real >::AddRowSumMat(), SpMatrix< Real >::AddVec2(), CovarianceStats::between_covar_, CovarianceStats::Dim(), kaldi::kTrans, CovarianceStats::num_spk_, CovarianceStats::num_utt_, MatrixBase< Real >::NumRows(), and CovarianceStats::tot_covar_.

Referenced by kaldi::ComputeLdaTransform().

49  {
50  int32 num_utts = utts_of_this_spk.NumRows();
51  tot_covar_.AddMat2(1.0, utts_of_this_spk, kTrans, 1.0);
52  Vector<double> spk_average(Dim());
53  spk_average.AddRowSumMat(1.0 / num_utts, utts_of_this_spk);
54  between_covar_.AddVec2(num_utts, spk_average);
55  num_utt_ += num_utts;
56  num_spk_ += 1;
57  }
void AddMat2(const Real alpha, const MatrixBase< Real > &M, MatrixTransposeType transM, const Real beta)
rank-N update: if (transM == kNoTrans) (*this) = beta*(*this) + alpha * M * M^T, or (if transM == kTr...
Definition: sp-matrix.cc:1110
kaldi::int32 int32
void AddVec2(const Real alpha, const VectorBase< OtherReal > &v)
rank-one update, this <– this + alpha v v&#39;
Definition: sp-matrix.cc:946
SpMatrix< double > tot_covar_
SpMatrix< double > between_covar_
MatrixIndexT NumRows() const
Returns number of rows (or zero for empty matrix).
Definition: kaldi-matrix.h:64

◆ AddStats()

void AddStats ( const CovarianceStats other)
inline

◆ Dim()

int32 Dim ( )
inline

◆ Empty()

bool Empty ( )
inline

◆ GetTotalCovar()

void GetTotalCovar ( SpMatrix< double > *  tot_covar) const
inline

get total covariance, normalized per number of frames.

Definition at line 38 of file ivector-compute-lda.cc.

References KALDI_ASSERT, CovarianceStats::num_utt_, PackedMatrix< Real >::Scale(), and CovarianceStats::tot_covar_.

Referenced by kaldi::ComputeLdaTransform().

38  {
40  *tot_covar = tot_covar_;
41  tot_covar->Scale(1.0 / num_utt_);
42  }
void Scale(Real c)
SpMatrix< double > tot_covar_
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185

◆ GetWithinCovar()

void GetWithinCovar ( SpMatrix< double > *  within_covar)
inline

Definition at line 43 of file ivector-compute-lda.cc.

References SpMatrix< Real >::AddSp(), CovarianceStats::between_covar_, KALDI_ASSERT, CovarianceStats::num_spk_, CovarianceStats::num_utt_, PackedMatrix< Real >::Scale(), and CovarianceStats::tot_covar_.

Referenced by kaldi::ComputeLdaTransform().

43  {
45  *within_covar = tot_covar_;
46  within_covar->AddSp(-1.0, between_covar_);
47  within_covar->Scale(1.0 / num_utt_);
48  }
void Scale(Real c)
void AddSp(const Real alpha, const SpMatrix< Real > &Ma)
Definition: sp-matrix.h:211
SpMatrix< double > tot_covar_
SpMatrix< double > between_covar_
#define KALDI_ASSERT(cond)
Definition: kaldi-error.h:185

◆ Info()

std::string Info ( )
inline

Definition at line 61 of file ivector-compute-lda.cc.

References CovarianceStats::num_spk_, and CovarianceStats::num_utt_.

Referenced by kaldi::ComputeLdaTransform().

61  {
62  std::ostringstream ostr;
63  ostr << num_spk_ << " speakers, " << num_utt_ << " utterances. ";
64  return ostr.str();
65  }

◆ KALDI_DISALLOW_COPY_AND_ASSIGN()

KALDI_DISALLOW_COPY_AND_ASSIGN ( CovarianceStats  )
private

◆ SingularTotCovar()

bool SingularTotCovar ( )
inline

Will return Empty() if the within-class covariance matrix would be zero.

Definition at line 59 of file ivector-compute-lda.cc.

References CovarianceStats::Dim(), and CovarianceStats::num_utt_.

Referenced by kaldi::ComputeLdaTransform().

Member Data Documentation

◆ between_covar_

SpMatrix<double> between_covar_
private

◆ num_spk_

◆ num_utt_

◆ tot_covar_


The documentation for this class was generated from the following file: