Commit 7565fb1a authored by Korbinian Riedhammer's avatar Korbinian Riedhammer
Browse files

cosmetic changes

git-svn-id: https://svn.code.sf.net/p/kaldi/code/sandbox/discrim@448 5e6a8d80-dfce-4ca6-a32a-6e07a63d50c8
parent a6f1b688
......@@ -120,7 +120,7 @@ void UnitTestAmTiedDiagGmm() {
for (int32 j = 0; j < wts.Dim(); ++j)
wts(j) = kaldi::RandInt(1, 1024);
wts.Scale(1./wts.Sum());
wts.Scale(1.0 / wts.Sum());
tied.SetWeights(wts);
......
......@@ -45,7 +45,7 @@ void AmTiedDiagGmm::Init(const DiagGmm& proto) {
// make sure the weights are uniform
Vector<BaseFloat> w(proto.NumGauss());
w.Set(1./w.Dim());
w.Set(1.0 / w.Dim());
densities_[0]->SetWeights(w);
dim_ = proto.Dim();
......@@ -62,7 +62,7 @@ void AmTiedDiagGmm::AddPdf(const DiagGmm &gmm) {
// make sure the weights are uniform
Vector<BaseFloat> w(gmm.NumGauss());
w.Set(1./w.Dim());
w.Set(1.0 / w.Dim());
gmm_ptr->SetWeights(w);
densities_.push_back(gmm_ptr);
......
......@@ -120,7 +120,7 @@ void UnitTestAmTiedDiagGmm() {
for (int32 j = 0; j < wts.Dim(); ++j)
wts(j) = kaldi::RandInt(1, 1024);
wts.Scale(1./wts.Sum());
wts.Scale(1.0 / wts.Sum());
tied.SetWeights(wts);
......
......@@ -45,7 +45,7 @@ void AmTiedFullGmm::Init(const FullGmm& proto) {
// make sure the weights are uniform
Vector<BaseFloat> w(proto.NumGauss());
w.Set(1./w.Dim());
w.Set(1.0 / w.Dim());
densities_[0]->SetWeights(w);
dim_ = proto.Dim();
......@@ -62,7 +62,7 @@ void AmTiedFullGmm::AddPdf(const FullGmm &gmm) {
// make sure the weights are uniform
Vector<BaseFloat> w(gmm.NumGauss());
w.Set(1./w.Dim());
w.Set(1.0 / w.Dim());
gmm_ptr->SetWeights(w);
densities_.push_back(gmm_ptr);
......
......@@ -112,7 +112,7 @@ void AccumTiedGmm::AccumulateFromPosteriors(
/// Propagate the sufficient statistics to the target accumulator
void AccumTiedGmm::Propagate(AccumTiedGmm *target) const {
KALDI_ASSERT(num_comp_ == target->num_comp_);
target->occupancy_.AddVec(1., occupancy_);
target->occupancy_.AddVec(1.0, occupancy_);
}
/// Interpolate the local model depending on the occupancies
......@@ -125,7 +125,7 @@ void AccumTiedGmm::Interpolate(BaseFloat rho, const AccumTiedGmm *source) {
if (rhoi > 0.8)
KALDI_VLOG(1) << "rhoi > 0.8";
occupancy_.Scale(1.-rhoi);
occupancy_.Scale(1.0 - rhoi);
occupancy_.AddVec(rhoi, source->occupancy_);
}
......@@ -191,7 +191,7 @@ void MleTiedGmmUpdate(const MleTiedGmmOptions &config,
// to correct for the min weights
// we need to re-normalize the weights
Vector<BaseFloat> w(tied->weights());
w.Scale(1./w.Sum());
w.Scale(1.0 / w.Sum());
tied->SetWeights(w);
KALDI_WARN << "Floored " << floored_weights.size() << " weights to "
......
......@@ -34,7 +34,7 @@ void TiedGmm::Setup(int32 pdf_index, int32 nmix) {
weights_.Resize(nmix);
/// init weights with uniform distribution
weights_.Set(1./nmix);
weights_.Set(1.0 / nmix);
}
void TiedGmm::CopyFromTiedGmm(const TiedGmm &copy) {
......@@ -75,7 +75,7 @@ BaseFloat TiedGmm::ComponentPosteriors(BaseFloat c,
BaseFloat log_sum = log(sum);
// make posteriors
posteriors->Scale(1. / sum);
posteriors->Scale(1.0 / sum);
// add svq offset
log_sum += c;
......@@ -89,14 +89,14 @@ BaseFloat TiedGmm::ComponentPosteriors(BaseFloat c,
/// this = rho x source + (1-rho) x this
void TiedGmm::Interpolate(BaseFloat rho, const TiedGmm *source) {
KALDI_ASSERT(NumGauss() == source->NumGauss());
KALDI_ASSERT(rho > 0. && rho < 1.);
KALDI_ASSERT(rho > 0.0 && rho < 1.0);
// interpolate
weights_.Scale(1.-rho);
weights_.Scale(1.0 - rho);
weights_.AddVec(rho, source->weights_);
// renorm to sum to one
weights_.Scale(1. / weights_.Sum());
weights_.Scale(1.0 / weights_.Sum());
}
/// Split the tied GMM weights based on the split sequence of the mixture
......@@ -113,12 +113,12 @@ void TiedGmm::Split(std::vector<int32> *sequence) {
for (std::vector<int32>::iterator it = sequence->begin(),
end = sequence->end(); it != end; ++it) {
BaseFloat w = weights_(*it);
weights_(*it) = w / 2.;
weights_(oldsize++) = w / 2.;
weights_(*it) = w / 2.0;
weights_(oldsize++) = w / 2.0;
}
// re-norm weights
weights_.Scale(1. / weights_.Sum());
weights_.Scale(1.0 / weights_.Sum());
}
/// Merge the tied GMM weights based on the merge sequence of the mixture
......@@ -146,7 +146,7 @@ void TiedGmm::Merge(std::vector<int32> *sequence) {
++m;
}
weights_.Scale(1. / weights_.Sum());
weights_.Scale(1.0 / weights_.Sum());
}
void TiedGmm::Write(std::ostream &out_stream, bool binary) const {
......
......@@ -69,8 +69,8 @@ void AllocateDiagGmms(const BuildTreeStatsType &stats,
if (count < 100)
KALDI_VLOG(1) << "Very small count for state "<< i << ": " << count;
x.Scale(1. / count);
x2.Scale(1. / count);
x.Scale(1.0 / count);
x2.Scale(1.0 / count);
x2.AddVec2(-1.0, x); // subtract mean^2.
KALDI_ASSERT(x2.Min() > 0);
......@@ -231,7 +231,7 @@ int main(int argc, char *argv[]) {
}
// transfer back
npdfsi.weights_.Scale(1. / npdfsi.weights_.Sum());
npdfsi.weights_.Scale(1.0 / npdfsi.weights_.Sum());
npdfsi.CopyToDiagGmm(pdfs[i]);
// now resize to target number of gaussians
......
......@@ -77,8 +77,8 @@ void Lbg(int32 min_n, int32 total_n, vector<int32> &mapping,
// accumulate only for target Gmm
if (*mit != i) continue;
x.AddVec(1., *fit);
x2.AddVec2(1., Vector<double>(*fit));
x.AddVec(1.0, *fit);
x2.AddVec2(1.0, Vector<double>(*fit));
++n;
}
......@@ -86,15 +86,15 @@ void Lbg(int32 min_n, int32 total_n, vector<int32> &mapping,
&& "No observations for codebook, check tree and alignment!");
// normalize parameters
x.Scale(1. / n);
x2.Scale(1. / n);
x2.AddVec2(-1., x);
x.Scale(1.0 / n);
x2.Scale(1.0 / n);
x2.AddVec2(-1.0, x);
// transfer to normal gmm...
DiagGmm *diag = new DiagGmm();
diag->Resize(1, x.Dim());
DiagGmmNormal ngmm(*diag);
ngmm.weights_(0) = 1.;
ngmm.weights_(0) = 1.0;
ngmm.means_.CopyRowFromVec(x, 0);
ngmm.vars_.CopyRowFromVec(x2, 0);
ngmm.CopyToDiagGmm(diag);
......@@ -140,7 +140,7 @@ void Lbg(int32 min_n, int32 total_n, vector<int32> &mapping,
for (mit = mapping.begin(), mend = mapping.end(), fit = features.begin(),
fend = features.end(); mit != mend && fit != fend; ++mit, ++fit) {
if (*mit == i)
acc.AccumulateFromDiag(*diag, *fit, 1.);
acc.AccumulateFromDiag(*diag, *fit, 1.0);
}
MleDiagGmmUpdate(config, acc, kGmmAll, diag, NULL, NULL);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment