[mlpack-git] master: Remove old load/save utilities. (05db9c3)

gitdub at big.cc.gt.atl.ga.us gitdub at big.cc.gt.atl.ga.us
Mon Jul 13 04:04:32 EDT 2015


Repository : https://github.com/mlpack/mlpack

On branch  : master
Link       : https://github.com/mlpack/mlpack/compare/8b2ca720828224607c70d2b539c43aecf8f4ec32...b4659b668021db631b3c8a48e3d735b513706fdc

>---------------------------------------------------------------

commit 05db9c30beb84f052fca5b309e309d9dcf645dc7
Author: Ryan Curtin <ryan at ratml.org>
Date:   Sat Jul 11 12:28:17 2015 +0000

    Remove old load/save utilities.


>---------------------------------------------------------------

05db9c30beb84f052fca5b309e309d9dcf645dc7
 src/mlpack/methods/hmm/CMakeLists.txt    |   2 -
 src/mlpack/methods/hmm/hmm_util.hpp      |  49 --------
 src/mlpack/methods/hmm/hmm_util_impl.hpp | 189 -------------------------------
 3 files changed, 240 deletions(-)

diff --git a/src/mlpack/methods/hmm/CMakeLists.txt b/src/mlpack/methods/hmm/CMakeLists.txt
index ef841a6..179a32b 100644
--- a/src/mlpack/methods/hmm/CMakeLists.txt
+++ b/src/mlpack/methods/hmm/CMakeLists.txt
@@ -3,8 +3,6 @@
 set(SOURCES
   hmm.hpp
   hmm_impl.hpp
-  hmm_util.hpp
-  hmm_util_impl.hpp
   hmm_regression.hpp
   hmm_regression_impl.hpp
 )
diff --git a/src/mlpack/methods/hmm/hmm_util.hpp b/src/mlpack/methods/hmm/hmm_util.hpp
deleted file mode 100644
index baf6c0b..0000000
--- a/src/mlpack/methods/hmm/hmm_util.hpp
+++ /dev/null
@@ -1,49 +0,0 @@
-/**
- * @file hmm_util.hpp
- * @author Ryan Curtin
- * @author Michael Fox
- *
- * Deprecated Save/load utilities for HMMs. See HMM::Save, HMM::Load.
- */
-#ifndef __MLPACK_METHODS_HMM_HMM_UTIL_HPP
-#define __MLPACK_METHODS_HMM_HMM_UTIL_HPP
-
-#include "hmm.hpp"
-
-namespace mlpack {
-namespace hmm {
-
-/**
- * Save an HMM to file (deprecated).
- *
- * @tparam Distribution Distribution type of HMM.
- * @param sr SaveRestoreUtility to use.
- */
-template<typename Distribution>
-void SaveHMM(const HMM<Distribution>& hmm, util::SaveRestoreUtility& sr);
-
-/**
- * Load an HMM from file (deprecated).
- *
- * @tparam Distribution Distribution type of HMM.
- * @param sr SaveRestoreUtility to use.
- */
-template<typename Distribution>
-void LoadHMM(HMM<Distribution>& hmm, util::SaveRestoreUtility& sr);
-
-/**
- * Converter for HMMs saved using older MLPACK versions.
- *
- * @tparam Distribution Distribution type of HMM.
- * @param sr SaveRestoreUtility to use.
- */
-template<typename Distribution>
-void ConvertHMM(HMM<Distribution>& hmm, const util::SaveRestoreUtility& sr);
-
-}; // namespace hmm
-}; // namespace mlpack
-
-// Include implementation.
-#include "hmm_util_impl.hpp"
-
-#endif
diff --git a/src/mlpack/methods/hmm/hmm_util_impl.hpp b/src/mlpack/methods/hmm/hmm_util_impl.hpp
deleted file mode 100644
index 47fbd9d..0000000
--- a/src/mlpack/methods/hmm/hmm_util_impl.hpp
+++ /dev/null
@@ -1,189 +0,0 @@
-/**
- * @file hmm_util_impl.hpp
- * @author Ryan Curtin
- * @author Michael Fox
- *
- * Implementation of HMM load/save functions.
- */
-#ifndef __MLPACK_METHODS_HMM_HMM_UTIL_IMPL_HPP
-#define __MLPACK_METHODS_HMM_HMM_UTIL_IMPL_HPP
-
-// In case it hasn't already been included.
-#include "hmm_util.hpp"
-// Only required for conversion util
-#include <mlpack/methods/gmm/gmm.hpp>
-
-namespace mlpack {
-namespace hmm {
-
-/**
- * Save an HMM to file (deprecated).
- *
- * @tparam Distribution Distribution type of HMM.
- * @param sr SaveRestoreUtility to use.
- */
-template<typename Distribution>
-void SaveHMM(const HMM<Distribution>& hmm, util::SaveRestoreUtility& sr)
-{
-  Log::Warn << "SaveHMM is deprecated. See HMM::Save.";
-  hmm.Save(sr);
-}
-
-/**
- * Load an HMM from file (deprecated).
- *
- * @tparam Distribution Distribution type of HMM.
- * @param sr SaveRestoreUtility to use.
- */
-template<typename Distribution>
-void LoadHMM(HMM<Distribution>& hmm, util::SaveRestoreUtility& sr)
-{
-  Log::Warn << "LoadHMM is deprecated. See HMM::Load.";
-  hmm.Load(sr);
-}
-
-/**
- * Converter for HMMs saved using older MLPACK versions.
- *
- * @tparam Distribution Distribution type of HMM.
- * @param sr SaveRestoreUtility to use.
- */
-template<typename Distribution>
-void ConvertHMM(HMM<Distribution>& /* hmm */,
-                const util::SaveRestoreUtility& /* sr */)
-{
-  Log::Fatal << "HMM conversion not implemented for arbitrary distributions."
-      << std::endl;
-}
-
-template<>
-void ConvertHMM(HMM<distribution::DiscreteDistribution>& hmm,
-                const util::SaveRestoreUtility& sr)
-{
-  std::string type;
-  size_t states;
-
-  sr.LoadParameter(type, "hmm_type");
-  if (type != "discrete")
-  {
-    Log::Fatal << "Cannot load non-discrete HMM (of type " << type << ") as "
-        << "discrete HMM!" << std::endl;
-  }
-
-  sr.LoadParameter(states, "hmm_states");
-
-  // Load transition matrix.
-  sr.LoadParameter(hmm.Transition(), "hmm_transition");
-
-  // Now each emission distribution.
-  hmm.Emission().resize(states);
-  for (size_t i = 0; i < states; ++i)
-  {
-    std::stringstream s;
-    s << "hmm_emission_distribution_" << i;
-    sr.LoadParameter(hmm.Emission()[i].Probabilities(), s.str());
-  }
-
-  hmm.Dimensionality() = 1;
-}
-
-template<>
-void ConvertHMM(HMM<distribution::GaussianDistribution>& hmm,
-                const util::SaveRestoreUtility& sr)
-{
-  std::string type;
-  size_t states;
-
-  sr.LoadParameter(type, "hmm_type");
-  if (type != "gaussian")
-  {
-    Log::Fatal << "Cannot load non-Gaussian HMM (of type " << type << ") as "
-        << "a Gaussian HMM!" << std::endl;
-  }
-
-  sr.LoadParameter(states, "hmm_states");
-
-  // Load transition matrix.
-  sr.LoadParameter(hmm.Transition(), "hmm_transition");
-
-  // Now each emission distribution.
-  hmm.Emission().resize(states);
-  for (size_t i = 0; i < states; ++i)
-  {
-    std::stringstream s;
-    s << "hmm_emission_mean_" << i;
-    sr.LoadParameter(hmm.Emission()[i].Mean(), s.str());
-
-    s.str("");
-    arma::mat covariance;
-    s << "hmm_emission_covariance_" << i;
-    sr.LoadParameter(covariance, s.str());
-    hmm.Emission()[i].Covariance(std::move(covariance));
-  }
-
-  hmm.Dimensionality() = hmm.Emission()[0].Mean().n_elem;
-}
-
-template<>
-void ConvertHMM(HMM<gmm::GMM<> >& hmm, const util::SaveRestoreUtility& sr)
-{
-  std::string type;
-  size_t states;
-
-  sr.LoadParameter(type, "hmm_type");
-  if (type != "gmm")
-  {
-    Log::Fatal << "Cannot load non-GMM HMM (of type " << type << ") as "
-        << "a Gaussian Mixture Model HMM!" << std::endl;
-  }
-
-  sr.LoadParameter(states, "hmm_states");
-
-  // Load transition matrix.
-  sr.LoadParameter(hmm.Transition(), "hmm_transition");
-
-  // Now each emission distribution.
-  hmm.Emission().resize(states, gmm::GMM<>(1, 1));
-  for (size_t i = 0; i < states; ++i)
-  {
-    std::stringstream s;
-    s << "hmm_emission_" << i << "_gaussians";
-    size_t gaussians;
-    sr.LoadParameter(gaussians, s.str());
-
-    s.str("");
-    // Extract dimensionality.
-    arma::vec meanzero;
-    s << "hmm_emission_" << i << "_gaussian_0_mean";
-    sr.LoadParameter(meanzero, s.str());
-    size_t dimensionality = meanzero.n_elem;
-
-    // Initialize GMM correctly.
-    hmm.Emission()[i].Gaussians() = gaussians;
-    hmm.Emission()[i].Dimensionality() = dimensionality;
-
-    for (size_t g = 0; g < gaussians; ++g)
-    {
-      s.str("");
-      s << "hmm_emission_" << i << "_gaussian_" << g << "_mean";
-      sr.LoadParameter(hmm.Emission()[i].Component(g).Mean(), s.str());
-
-      s.str("");
-      s << "hmm_emission_" << i << "_gaussian_" << g << "_covariance";
-      arma::mat covariance;
-      sr.LoadParameter(covariance, s.str());
-      hmm.Emission()[i].Component(g).Covariance(std::move(covariance));
-    }
-
-    s.str("");
-    s << "hmm_emission_" << i << "_weights";
-    sr.LoadParameter(hmm.Emission()[i].Weights(), s.str());
-  }
-
-  hmm.Dimensionality() = hmm.Emission()[0].Dimensionality();
-}
-
-}; // namespace hmm
-}; // namespace mlpack
-
-#endif



More information about the mlpack-git mailing list