GaussClusterable wraps Gaussian statistics in a form accessible to generic clustering algorithms. More...
#include <clusterable-classes.h>
Public Member Functions | |
GaussClusterable () | |
GaussClusterable (int32 dim, BaseFloat var_floor) | |
GaussClusterable (const Vector< BaseFloat > &x_stats, const Vector< BaseFloat > &x2_stats, BaseFloat var_floor, BaseFloat count) | |
virtual std::string | Type () const |
Return a string that describes the inherited type. More... | |
void | AddStats (const VectorBase< BaseFloat > &vec, BaseFloat weight=1.0) |
virtual BaseFloat | Objf () const |
Return the objective function associated with the stats [assuming ML estimation]. More... | |
virtual void | SetZero () |
Set stats to empty. More... | |
virtual void | Add (const Clusterable &other_in) |
Add other stats. More... | |
virtual void | Sub (const Clusterable &other_in) |
Subtract other stats. More... | |
virtual BaseFloat | Normalizer () const |
Return the normalizer (typically, count) associated with the stats. More... | |
virtual Clusterable * | Copy () const |
Return a copy of this object. More... | |
virtual void | Scale (BaseFloat f) |
Scale the stats by a positive number f [not mandatory to supply this]. More... | |
virtual void | Write (std::ostream &os, bool binary) const |
Write data to stream. More... | |
virtual Clusterable * | ReadNew (std::istream &is, bool binary) const |
Read data from a stream and return the corresponding object (const function; it's a class member because we need access to the vtable so generic code can read derived types). More... | |
virtual | ~GaussClusterable () |
BaseFloat | count () const |
SubVector< double > | x_stats () const |
SubVector< double > | x2_stats () const |
![]() | |
virtual | ~Clusterable () |
virtual BaseFloat | ObjfPlus (const Clusterable &other) const |
Return the objective function of the combined object this + other. More... | |
virtual BaseFloat | ObjfMinus (const Clusterable &other) const |
Return the objective function of the subtracted object this - other. More... | |
virtual BaseFloat | Distance (const Clusterable &other) const |
Return the objective function decrease from merging the two clusters, negated to be a positive number (or zero). More... | |
Private Member Functions | |
void | Read (std::istream &is, bool binary) |
Private Attributes | |
double | count_ |
Matrix< double > | stats_ |
double | var_floor_ |
GaussClusterable wraps Gaussian statistics in a form accessible to generic clustering algorithms.
Definition at line 65 of file clusterable-classes.h.
|
inline |
Definition at line 67 of file clusterable-classes.h.
Referenced by GaussClusterable::Copy(), and GaussClusterable::ReadNew().
|
inline |
Definition at line 68 of file clusterable-classes.h.
|
inline |
Definition at line 107 of file clusterable-classes.h.
References MatrixBase< Real >::Row(), and GaussClusterable::stats_.
|
inlinevirtual |
Definition at line 86 of file clusterable-classes.h.
|
virtual |
Add other stats.
Implements Clusterable.
Definition at line 144 of file clusterable-classes.cc.
References MatrixBase< Real >::AddMat(), GaussClusterable::count_, KALDI_ASSERT, GaussClusterable::stats_, and Clusterable::Type().
void AddStats | ( | const VectorBase< BaseFloat > & | vec, |
BaseFloat | weight = 1.0 |
||
) |
Definition at line 137 of file clusterable-classes.cc.
References GaussClusterable::count_, MatrixBase< Real >::Row(), and GaussClusterable::stats_.
Referenced by kaldi::GenRandStats().
|
virtual |
Return a copy of this object.
Implements Clusterable.
Definition at line 160 of file clusterable-classes.cc.
References GaussClusterable::GaussClusterable(), KALDI_ASSERT, MatrixBase< Real >::NumCols(), MatrixBase< Real >::NumRows(), GaussClusterable::stats_, and GaussClusterable::var_floor_.
|
inline |
Definition at line 88 of file clusterable-classes.h.
References GaussClusterable::count_.
Referenced by kaldi::ClusterGaussiansToUbm(), DiagGmm::DiagGmm(), kaldi::InitAmGmm(), and DiagGmm::MergeKmeans().
|
inlinevirtual |
Return the normalizer (typically, count) associated with the stats.
Implements Clusterable.
Definition at line 81 of file clusterable-classes.h.
References GaussClusterable::count_.
|
virtual |
Return the objective function associated with the stats [assuming ML estimation].
Implements Clusterable.
Definition at line 193 of file clusterable-classes.cc.
References GaussClusterable::count_, rnnlm::d, KALDI_ISNAN, KALDI_WARN, M_LOG_2PI, MatrixBase< Real >::NumCols(), GaussClusterable::stats_, VectorBase< Real >::SumLog(), and GaussClusterable::var_floor_.
|
private |
Definition at line 186 of file clusterable-classes.cc.
References GaussClusterable::count_, kaldi::ExpectToken(), Matrix< Real >::Read(), kaldi::ReadBasicType(), GaussClusterable::stats_, and GaussClusterable::var_floor_.
Referenced by GaussClusterable::ReadNew().
|
virtual |
Read data from a stream and return the corresponding object (const function; it's a class member because we need access to the vtable so generic code can read derived types).
Implements Clusterable.
Definition at line 180 of file clusterable-classes.cc.
References GaussClusterable::GaussClusterable(), and GaussClusterable::Read().
|
virtual |
Scale the stats by a positive number f [not mandatory to supply this].
Reimplemented from Clusterable.
Definition at line 167 of file clusterable-classes.cc.
References GaussClusterable::count_, KALDI_ASSERT, MatrixBase< Real >::Scale(), and GaussClusterable::stats_.
|
inlinevirtual |
Set stats to empty.
Implements Clusterable.
Definition at line 102 of file clusterable-classes.h.
References GaussClusterable::count_, MatrixBase< Real >::SetZero(), and GaussClusterable::stats_.
|
virtual |
Subtract other stats.
Implements Clusterable.
Definition at line 152 of file clusterable-classes.cc.
References MatrixBase< Real >::AddMat(), GaussClusterable::count_, KALDI_ASSERT, GaussClusterable::stats_, and Clusterable::Type().
|
inlinevirtual |
Return a string that describes the inherited type.
Implements Clusterable.
Definition at line 75 of file clusterable-classes.h.
|
virtual |
Write data to stream.
Implements Clusterable.
Definition at line 173 of file clusterable-classes.cc.
References GaussClusterable::count_, GaussClusterable::stats_, GaussClusterable::var_floor_, MatrixBase< Real >::Write(), kaldi::WriteBasicType(), and kaldi::WriteToken().
|
inline |
Definition at line 91 of file clusterable-classes.h.
References MatrixBase< Real >::Row(), and GaussClusterable::stats_.
Referenced by kaldi::ClusterGaussiansToUbm(), DiagGmm::DiagGmm(), and DiagGmm::MergeKmeans().
|
inline |
Definition at line 90 of file clusterable-classes.h.
References MatrixBase< Real >::Row(), and GaussClusterable::stats_.
Referenced by kaldi::ClusterGaussiansToUbm(), DiagGmm::DiagGmm(), and DiagGmm::MergeKmeans().
|
private |
Definition at line 93 of file clusterable-classes.h.
Referenced by GaussClusterable::Add(), GaussClusterable::AddStats(), GaussClusterable::count(), GaussClusterable::Normalizer(), GaussClusterable::Objf(), GaussClusterable::Read(), GaussClusterable::Scale(), GaussClusterable::SetZero(), GaussClusterable::Sub(), and GaussClusterable::Write().
|
private |
Definition at line 94 of file clusterable-classes.h.
Referenced by GaussClusterable::Add(), GaussClusterable::AddStats(), GaussClusterable::Copy(), GaussClusterable::GaussClusterable(), GaussClusterable::Objf(), GaussClusterable::Read(), GaussClusterable::Scale(), GaussClusterable::SetZero(), GaussClusterable::Sub(), GaussClusterable::Write(), GaussClusterable::x2_stats(), and GaussClusterable::x_stats().
|
private |
Definition at line 95 of file clusterable-classes.h.
Referenced by GaussClusterable::Copy(), GaussClusterable::Objf(), GaussClusterable::Read(), and GaussClusterable::Write().