VectorClusterable wraps vectors in a form accessible to generic clustering algorithms. More...
#include <clusterable-classes.h>
Public Member Functions | |
VectorClusterable () | |
VectorClusterable (const Vector< BaseFloat > &vector, BaseFloat weight) | |
virtual std::string | Type () const |
Return a string that describes the inherited type. More... | |
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 | ~VectorClusterable () |
Public Member Functions inherited from Clusterable | |
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 | weight_ |
Vector< double > | stats_ |
double | sumsq_ |
VectorClusterable wraps vectors in a form accessible to generic clustering algorithms.
Each vector is associated with a weight; these could be 1.0. The objective function (to be maximized) is the negated sum of squared distances from the cluster center to each vector, times that vector's weight.
Definition at line 121 of file clusterable-classes.h.
|
inline |
Definition at line 123 of file clusterable-classes.h.
VectorClusterable | ( | const Vector< BaseFloat > & | vector, |
BaseFloat | weight | ||
) |
Definition at line 296 of file clusterable-classes.cc.
References KALDI_ASSERT, VectorBase< Real >::Scale(), VectorClusterable::stats_, VectorClusterable::sumsq_, and kaldi::VecVec().
|
inlinevirtual |
Definition at line 139 of file clusterable-classes.h.
|
virtual |
Add other stats.
Implements Clusterable.
Definition at line 225 of file clusterable-classes.cc.
References KALDI_ASSERT, Clusterable::Type(), and VectorClusterable::weight_.
Referenced by kaldi::TestClusterUtilsVector().
|
virtual |
Return a copy of this object.
Implements Clusterable.
Definition at line 255 of file clusterable-classes.cc.
References VectorClusterable::stats_, VectorClusterable::sumsq_, and VectorClusterable::weight_.
|
inlinevirtual |
Return the normalizer (typically, count) associated with the stats.
Implements Clusterable.
Definition at line 134 of file clusterable-classes.h.
References GaussClusterable::Copy(), GaussClusterable::ReadNew(), GaussClusterable::Scale(), and GaussClusterable::Write().
|
virtual |
Return the objective function associated with the stats [assuming ML estimation].
Implements Clusterable.
Definition at line 305 of file clusterable-classes.cc.
References KALDI_WARN, VectorClusterable::stats_, VectorClusterable::sumsq_, kaldi::VecVec(), and VectorClusterable::weight_.
Referenced by kaldi::TestClusterUtilsVector().
|
private |
Definition at line 286 of file clusterable-classes.cc.
References kaldi::ExpectToken(), and kaldi::ReadBasicType().
Referenced by VectorClusterable::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 280 of file clusterable-classes.cc.
References VectorClusterable::Read().
|
virtual |
Scale the stats by a positive number f [not mandatory to supply this].
Reimplemented from Clusterable.
Definition at line 263 of file clusterable-classes.cc.
References KALDI_ASSERT.
|
inlinevirtual |
Set stats to empty.
Implements Clusterable.
Definition at line 131 of file clusterable-classes.h.
References GaussClusterable::Add(), MatrixBase< Real >::Set(), GaussClusterable::stats_, and GaussClusterable::Sub().
|
virtual |
Subtract other stats.
Implements Clusterable.
Definition at line 234 of file clusterable-classes.cc.
References KALDI_ASSERT, KALDI_WARN, Clusterable::Type(), and VectorClusterable::weight_.
|
inlinevirtual |
Return a string that describes the inherited type.
Implements Clusterable.
Definition at line 128 of file clusterable-classes.h.
References GaussClusterable::Objf().
|
virtual |
Write data to stream.
Implements Clusterable.
Definition at line 270 of file clusterable-classes.cc.
References kaldi::WriteBasicType(), and kaldi::WriteToken().
|
private |
Definition at line 143 of file clusterable-classes.h.
Referenced by VectorClusterable::Copy(), VectorClusterable::Objf(), and VectorClusterable::VectorClusterable().
|
private |
Definition at line 144 of file clusterable-classes.h.
Referenced by VectorClusterable::Copy(), VectorClusterable::Objf(), and VectorClusterable::VectorClusterable().
|
private |
Definition at line 142 of file clusterable-classes.h.
Referenced by VectorClusterable::Add(), VectorClusterable::Copy(), VectorClusterable::Objf(), and VectorClusterable::Sub().