IvectorExtractTask Class Reference
Collaboration diagram for IvectorExtractTask:

Public Member Functions

 IvectorExtractTask (const IvectorExtractor &extractor, std::string utt, const Matrix< BaseFloat > &feats, const Posterior &posterior, BaseFloatVectorWriter *writer, double *tot_auxf_change)
 
void operator() ()
 
 ~IvectorExtractTask ()
 

Private Attributes

const IvectorExtractorextractor_
 
std::string utt_
 
Matrix< BaseFloatfeats_
 
Posterior posterior_
 
BaseFloatVectorWriterwriter_
 
double * tot_auxf_change_
 
Vector< double > ivector_
 
double auxf_change_
 

Detailed Description

Definition at line 32 of file ivector-extract.cc.

Constructor & Destructor Documentation

◆ IvectorExtractTask()

IvectorExtractTask ( const IvectorExtractor extractor,
std::string  utt,
const Matrix< BaseFloat > &  feats,
const Posterior posterior,
BaseFloatVectorWriter writer,
double *  tot_auxf_change 
)
inline

Definition at line 34 of file ivector-extract.cc.

Referenced by main().

39  :
40  extractor_(extractor), utt_(utt), feats_(feats), posterior_(posterior),
41  writer_(writer), tot_auxf_change_(tot_auxf_change) { }
BaseFloatVectorWriter * writer_
Matrix< BaseFloat > feats_
const IvectorExtractor & extractor_

◆ ~IvectorExtractTask()

~IvectorExtractTask ( )
inline

Definition at line 64 of file ivector-extract.cc.

References IvectorExtractTask::auxf_change_, IvectorExtractTask::extractor_, IvectorExtractTask::ivector_, KALDI_VLOG, VectorBase< Real >::Norm(), IvectorExtractTask::posterior_, IvectorExtractor::PriorOffset(), IvectorExtractTask::tot_auxf_change_, kaldi::TotalPosterior(), IvectorExtractTask::utt_, TableWriter< Holder >::Write(), and IvectorExtractTask::writer_.

64  {
65  if (tot_auxf_change_ != NULL) {
66  double T = TotalPosterior(posterior_);
68  KALDI_VLOG(2) << "Auxf change for utterance " << utt_ << " was "
69  << (auxf_change_ / T) << " per frame over " << T
70  << " frames (weighted)";
71  }
72  // We actually write out the offset of the iVectors from the mean of the
73  // prior distribution; this is the form we'll need it in for scoring. (most
74  // formulations of iVectors have zero-mean priors so this is not normally an
75  // issue).
77  KALDI_VLOG(2) << "Ivector norm for utterance " << utt_
78  << " was " << ivector_.Norm(2.0);
80  }
double PriorOffset() const
The distribution over iVectors, in our formulation, is not centered at zero; its first dimension has ...
Real Norm(Real p) const
Compute the p-th norm of the vector.
void Write(const std::string &key, const T &value) const
BaseFloat TotalPosterior(const Posterior &post)
Returns the total of all the weights in "post".
Definition: posterior.cc:230
BaseFloatVectorWriter * writer_
A class representing a vector.
Definition: kaldi-vector.h:406
#define KALDI_VLOG(v)
Definition: kaldi-error.h:156
const IvectorExtractor & extractor_

Member Function Documentation

◆ operator()()

void operator() ( )
inline

Definition at line 43 of file ivector-extract.cc.

References IvectorExtractorUtteranceStats::AccStats(), IvectorExtractTask::auxf_change_, IvectorExtractTask::extractor_, IvectorExtractor::FeatDim(), IvectorExtractTask::feats_, IvectorExtractor::GetAuxf(), IvectorExtractor::GetIvectorDistribution(), IvectorExtractTask::ivector_, IvectorExtractor::IvectorDim(), IvectorExtractor::NumGauss(), IvectorExtractTask::posterior_, IvectorExtractor::PriorOffset(), Vector< Real >::Resize(), and IvectorExtractTask::tot_auxf_change_.

43  {
44  bool need_2nd_order_stats = false;
45 
48  need_2nd_order_stats);
49 
50  utt_stats.AccStats(feats_, posterior_);
51 
54 
55  if (tot_auxf_change_ != NULL) {
56  double old_auxf = extractor_.GetAuxf(utt_stats, ivector_);
57  extractor_.GetIvectorDistribution(utt_stats, &ivector_, NULL);
58  double new_auxf = extractor_.GetAuxf(utt_stats, ivector_);
59  auxf_change_ = new_auxf - old_auxf;
60  } else {
61  extractor_.GetIvectorDistribution(utt_stats, &ivector_, NULL);
62  }
63  }
double PriorOffset() const
The distribution over iVectors, in our formulation, is not centered at zero; its first dimension has ...
double GetAuxf(const IvectorExtractorUtteranceStats &utt_stats, const VectorBase< double > &mean, const SpMatrix< double > *var=NULL) const
Returns the log-likelihood objective function, summed over frames, for this distribution of iVectors ...
void Resize(MatrixIndexT length, MatrixResizeType resize_type=kSetZero)
Set vector to a specified size (can be zero).
Matrix< BaseFloat > feats_
void AccStats(const MatrixBase< BaseFloat > &feats, const Posterior &post)
void GetIvectorDistribution(const IvectorExtractorUtteranceStats &utt_stats, VectorBase< double > *mean, SpMatrix< double > *var) const
Gets the distribution over ivectors (or at least, a Gaussian approximation to it).
These are the stats for a particular utterance, i.e.
const IvectorExtractor & extractor_

Member Data Documentation

◆ auxf_change_

double auxf_change_
private

◆ extractor_

const IvectorExtractor& extractor_
private

◆ feats_

Matrix<BaseFloat> feats_
private

Definition at line 84 of file ivector-extract.cc.

Referenced by IvectorExtractTask::operator()().

◆ ivector_

Vector<double> ivector_
private

◆ posterior_

Posterior posterior_
private

◆ tot_auxf_change_

double* tot_auxf_change_
private

◆ utt_

std::string utt_
private

Definition at line 83 of file ivector-extract.cc.

Referenced by IvectorExtractTask::~IvectorExtractTask().

◆ writer_

BaseFloatVectorWriter* writer_
private

Definition at line 86 of file ivector-extract.cc.

Referenced by IvectorExtractTask::~IvectorExtractTask().


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