This class helps us to efficiently estimate iVectors in situations where the data is coming in frame by frame. More...
#include <ivector-extractor.h>
Public Member Functions | |
OnlineIvectorEstimationStats (int32 ivector_dim, BaseFloat prior_offset, BaseFloat max_count) | |
OnlineIvectorEstimationStats (const OnlineIvectorEstimationStats &other) | |
void | AccStats (const IvectorExtractor &extractor, const VectorBase< BaseFloat > &feature, const std::vector< std::pair< int32, BaseFloat > > &gauss_post) |
void | AccStats (const IvectorExtractor &extractor, const MatrixBase< BaseFloat > &features, const std::vector< std::vector< std::pair< int32, BaseFloat > > > &gauss_post) |
int32 | IvectorDim () const |
void | GetIvector (int32 num_cg_iters, VectorBase< double > *ivector) const |
This function gets the current estimate of the iVector. More... | |
double | NumFrames () const |
double | PriorOffset () const |
double | ObjfChange (const VectorBase< double > &ivector) const |
ObjfChange returns the change in objective function *per frame* from using the default value [ prior_offset_, 0, 0, ... More... | |
double | Count () const |
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 adaptation data. More... | |
void | Write (std::ostream &os, bool binary) const |
void | Read (std::istream &is, bool binary) |
OnlineIvectorEstimationStats & | operator= (const OnlineIvectorEstimationStats &other) |
Protected Member Functions | |
double | Objf (const VectorBase< double > &ivector) const |
Returns objective function per frame, at this iVector value. More... | |
double | DefaultObjf () const |
Returns objective function evaluated at the point [ prior_offset_, 0, 0, 0, ... More... | |
Protected Attributes | |
double | prior_offset_ |
double | max_count_ |
double | num_frames_ |
SpMatrix< double > | quadratic_term_ |
Vector< double > | linear_term_ |
Friends | |
class | IvectorExtractor |
This class helps us to efficiently estimate iVectors in situations where the data is coming in frame by frame.
Definition at line 314 of file ivector-extractor.h.
OnlineIvectorEstimationStats | ( | int32 | ivector_dim, |
BaseFloat | prior_offset, | ||
BaseFloat | max_count | ||
) |
Definition at line 786 of file ivector-extractor.cc.
References PackedMatrix< Real >::AddToDiag(), OnlineIvectorEstimationStats::linear_term_, and OnlineIvectorEstimationStats::quadratic_term_.
OnlineIvectorEstimationStats | ( | const OnlineIvectorEstimationStats & | other | ) |
Definition at line 797 of file ivector-extractor.cc.
void AccStats | ( | const IvectorExtractor & | extractor, |
const VectorBase< BaseFloat > & | feature, | ||
const std::vector< std::pair< int32, BaseFloat > > & | gauss_post | ||
) |
Definition at line 537 of file ivector-extractor.cc.
References VectorBase< Real >::AddMatVec(), IvectorExtractor::IvectorDependentWeights(), IvectorExtractor::IvectorDim(), KALDI_ASSERT, kaldi::kTrans, IvectorExtractor::prior_offset_, IvectorExtractor::Sigma_inv_M_, and IvectorExtractor::U_.
Referenced by kaldi::TestIvectorExtraction().
void AccStats | ( | const IvectorExtractor & | extractor, |
const MatrixBase< BaseFloat > & | features, | ||
const std::vector< std::vector< std::pair< int32, BaseFloat > > > & | gauss_post | ||
) |
Definition at line 611 of file ivector-extractor.cc.
References VectorBase< Real >::AddVec(), kaldi::ConvertPostToGaussInfo(), GaussInfo::frame_weights, IvectorExtractor::IvectorDependentWeights(), IvectorExtractor::IvectorDim(), KALDI_ASSERT, kaldi::kTrans, kaldi::kUndefined, MatrixBase< Real >::NumCols(), IvectorExtractor::prior_offset_, MatrixBase< Real >::Row(), VectorBase< Real >::SetZero(), IvectorExtractor::Sigma_inv_M_, GaussInfo::tot_weight, and IvectorExtractor::U_.
|
inline |
Definition at line 365 of file ivector-extractor.h.
Referenced by OnlineIvectorExtractorAdaptationState::LimitFrames().
|
protected |
Returns objective function evaluated at the point [ prior_offset_, 0, 0, 0, ...
]... this is used in diagnostics.
Definition at line 776 of file ivector-extractor.cc.
References IvectorExtractor::prior_offset_.
void GetIvector | ( | int32 | num_cg_iters, |
VectorBase< double > * | ivector | ||
) | const |
This function gets the current estimate of the iVector.
Internally it does some work to compute it (currently matrix inversion, but we are doing to use Conjugate Gradient which will increase the speed). At entry, "ivector" must be a pointer to a vector dimension IvectorDim(), and free of NaN's. For faster estimation, you can set "num_cg_iters" to some value > 0, which will limit how many iterations of conjugate gradient we use to re-estimate the iVector; in this case, you should make sure *ivector is set at entry to a recently estimated iVector from the same utterance, which will give the CG a better starting point. If num_cg_iters is set to -1, it will compute the iVector exactly; if it's set to a positive number, the number of conjugate gradient iterations will be limited to that number. Note: the iVectors output still have a nonzero mean (first dim offset by PriorOffset()).
Definition at line 732 of file ivector-extractor.cc.
References VectorBase< Real >::Dim(), IvectorExtractor::IvectorDim(), KALDI_ASSERT, KALDI_VLOG, kaldi::LinearCgd(), LinearCgdOptions::max_iters, IvectorExtractor::prior_offset_, and VectorBase< Real >::SetZero().
Referenced by kaldi::TestIvectorExtraction().
|
inline |
Definition at line 337 of file ivector-extractor.h.
Referenced by OnlineIvectorFeature::SetAdaptationState().
|
inline |
Definition at line 355 of file ivector-extractor.h.
|
protected |
Returns objective function per frame, at this iVector value.
Definition at line 765 of file ivector-extractor.cc.
References kaldi::VecSpVec(), and kaldi::VecVec().
double ObjfChange | ( | const VectorBase< double > & | ivector | ) | const |
ObjfChange returns the change in objective function *per frame* from using the default value [ prior_offset_, 0, 0, ...
] to using the provided value; should be >= 0, if "ivector" is a value we estimated. This is for diagnostics.
Definition at line 758 of file ivector-extractor.cc.
References KALDI_ASSERT, and KALDI_ISNAN.
Referenced by OnlineIvectorFeature::ObjfImprPerFrame(), and kaldi::TestIvectorExtraction().
|
inline |
Definition at line 376 of file ivector-extractor.h.
References OnlineIvectorEstimationStats::linear_term_, OnlineIvectorEstimationStats::max_count_, OnlineIvectorEstimationStats::num_frames_, OnlineIvectorEstimationStats::prior_offset_, and OnlineIvectorEstimationStats::quadratic_term_.
|
inline |
Definition at line 357 of file ivector-extractor.h.
void Read | ( | std::istream & | is, |
bool | binary | ||
) |
Definition at line 710 of file ivector-extractor.cc.
References kaldi::ExpectToken(), KALDI_ASSERT, IvectorExtractor::prior_offset_, kaldi::ReadBasicType(), and kaldi::ReadToken().
Referenced by OnlineIvectorExtractorAdaptationState::Read(), and IvectorExtractor::Read().
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 adaptation data.
Note: it does not apply the scaling to the prior term.
Definition at line 671 of file ivector-extractor.cc.
References KALDI_ASSERT, and IvectorExtractor::prior_offset_.
Referenced by OnlineIvectorExtractorAdaptationState::LimitFrames(), and IvectorExtractorUtteranceStats::Scale().
void Write | ( | std::ostream & | os, |
bool | binary | ||
) | const |
Definition at line 695 of file ivector-extractor.cc.
References IvectorExtractor::prior_offset_, kaldi::WriteBasicType(), and kaldi::WriteToken().
Referenced by OnlineIvectorExtractorAdaptationState::Write(), and IvectorExtractor::Write().
|
friend |
Definition at line 393 of file ivector-extractor.h.
|
protected |
Definition at line 398 of file ivector-extractor.h.
Referenced by OnlineIvectorEstimationStats::OnlineIvectorEstimationStats(), and OnlineIvectorEstimationStats::operator=().
|
protected |
Definition at line 395 of file ivector-extractor.h.
Referenced by OnlineIvectorEstimationStats::operator=().
|
protected |
Definition at line 396 of file ivector-extractor.h.
Referenced by OnlineIvectorEstimationStats::operator=().
|
protected |
Definition at line 394 of file ivector-extractor.h.
Referenced by OnlineIvectorEstimationStats::operator=(), IvectorExtractor::Read(), and IvectorExtractor::Write().
|
protected |
Definition at line 397 of file ivector-extractor.h.
Referenced by OnlineIvectorEstimationStats::OnlineIvectorEstimationStats(), and OnlineIvectorEstimationStats::operator=().