[mlpack-svn] r17085 - mlpack/trunk/src/mlpack/methods/gmm
fastlab-svn at coffeetalk-1.cc.gatech.edu
fastlab-svn at coffeetalk-1.cc.gatech.edu
Wed Aug 20 15:58:11 EDT 2014
Author: rcurtin
Date: Wed Aug 20 15:58:10 2014
New Revision: 17085
Log:
Remove trailing spaces thanks to vimrc, and fix comment correctness.
Modified:
mlpack/trunk/src/mlpack/methods/gmm/gmm.hpp
mlpack/trunk/src/mlpack/methods/gmm/gmm_impl.hpp
Modified: mlpack/trunk/src/mlpack/methods/gmm/gmm.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/methods/gmm/gmm.hpp (original)
+++ mlpack/trunk/src/mlpack/methods/gmm/gmm.hpp Wed Aug 20 15:58:10 2014
@@ -77,14 +77,14 @@
size_t gaussians;
//! The dimensionality of the model.
size_t dimensionality;
-
+
//! Vector of Gaussians
std::vector<distribution::GaussianDistribution> dists;
-
+
//! Legacy member data, not used.
std::vector<arma::vec> means;
std::vector<arma::mat> covariances;
-
+
//! Vector of a priori weights for each Gaussian.
arma::vec weights;
@@ -214,7 +214,7 @@
* @param SaveRestoreUtility object to save to.
*/
void Save(util::SaveRestoreUtility& sr) const;
-
+
//! Return the number of gaussians in the model.
size_t Gaussians() const { return gaussians; }
//! Modify the number of gaussians in the model. Careful! You will have to
@@ -231,14 +231,14 @@
* Return a const reference to a component distribution.
*
* @param i index of component.
- */
+ */
const distribution::GaussianDistribution& Component(size_t i) const {
return dists[i]; }
/**
* Return a reference to a component distribution.
*
* @param i index of component.
- */
+ */
distribution::GaussianDistribution& Component(size_t i) { return dists[i]; }
//! Functions from earlier releases give errors
@@ -382,7 +382,7 @@
* Returns a string representation of this object.
*/
std::string ToString() const;
-
+
/**
* Returns a string indicating the type.
*/
Modified: mlpack/trunk/src/mlpack/methods/gmm/gmm_impl.hpp
==============================================================================
--- mlpack/trunk/src/mlpack/methods/gmm/gmm_impl.hpp (original)
+++ mlpack/trunk/src/mlpack/methods/gmm/gmm_impl.hpp Wed Aug 20 15:58:10 2014
@@ -33,8 +33,7 @@
localFitter(FittingType()),
fitter(localFitter)
{
- // Set weights to 0. Technically this model is still valid, but
- // only barely.
+ // Set equal weights. Technically this model is still valid, but only barely.
weights.fill(1.0 / gaussians);
}
@@ -58,12 +57,11 @@
weights(gaussians),
fitter(fitter)
{
- // Set weights to 0. Technically this model is still valid, but
- // only barely.
+ // Set equal weights. Technically this model is still valid, but only barely.
weights.fill(1.0 / gaussians);
}
-
+
// Copy constructor.
template<typename FittingType>
template<typename OtherFittingType>
@@ -132,7 +130,7 @@
Log::Warn << "GMM::Save(): error saving to '" << filename << "'.\n";
}
-
+
// Save a GMM to a SaveRestoreUtility.
template<typename FittingType>
void GMM<FittingType>::Save(util::SaveRestoreUtility& sr) const
@@ -149,7 +147,7 @@
std::stringstream o;
o << i;
std::string gaussianName = "gaussian" + o.str();
-
+
// Now save them.
dists[i].Save(child);
sr.AddChild(child, gaussianName);
@@ -163,7 +161,7 @@
sr.LoadParameter(gaussians, "gaussians");
sr.LoadParameter(dimensionality, "dimensionality");
sr.LoadParameter(weights, "weights");
-
+
// We need to do a little error checking here.
if (weights.n_elem != gaussians)
{
@@ -171,9 +169,9 @@
<< " gaussians but weights vector only contains " << weights.n_elem
<< " elements!" << std::endl;
}
-
+
dists.resize(gaussians);
-
+
for (size_t i = 0; i < gaussians; ++i)
{
std::stringstream o;
@@ -193,7 +191,7 @@
double sum = 0;
for (size_t i = 0; i < gaussians; i++)
sum += weights[i] * dists[i].Probability(observation);
-
+
return sum;
}
More information about the mlpack-svn
mailing list