⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 gmm.h

📁 gmm test gmm test gmm test
💻 H
字号:
#ifdef DLL_GMM_EXPORTS
#define DLL_GMM_API __declspec(dllexport)
#else
#define DLL_GMM_API __declspec(dllimport)
#endif

#define GMM_MIXTURE_NUMBER_ERROR DBL_MAX
#define GMM_FEATURE_ORDER_ERROR DBL_MIN

#define GMM_WEIGHT_ERROR DBL_MAX

#define GMM_LOG_RANGE_ERROR DBL_MAX

#define GMM_SAVE_FILE_ERROR -1

#define GMM_LOAD_FILE_ERROR -1
#define GMM_MODEL_FILE_ERROR -2
#define GMM_MODEL_VALUE_ERROR -3
#define GMM_MODEL_EOF -4

#define GMM_INIT_RANDOM 0

#include <iostream>
#include <string>
#include <fstream>
#include <math.h>
#include <float.h>

//For random generation 
#include <stdlib.h> 
#include <time.h>


using namespace std;



/**
 * \ingroup dll_GMM
 *
 * \par requirements
 * win98 or later\n
 * win2k or later\n
 * MFC\n
 * Visual Studio 6.0 or higher\n
 * (Tested in .net 2003 only)
 *
 * \version 1.051014
 *
 *
 *
 * \author lbjcom(lbjcom@dsp.yonsei.ac.kr)
 *
 * 
 * \todo 
 *  \li \ref Training function must be tested.
 *  \li <b>\ref Training function exception handling!</b>
 *  \li Add Initialize function. (Random with seed)
 *  \li Load Function
 *  \li operator= --> const肺 官操磊-
 *  \li 葛胆 颇老阑 matlab俊辑 官肺 何甫荐 乐绰 器杆栏肺 历厘且 荐 乐档废 秦焊磊
 *  \li support full covariance matrix.
 *
 * <b>Version History</b><br>
 * v1.051014
 * \li EM舅绊府硫 檬扁拳俊辑 飘饭捞醋 单捞磐 辨捞啊 辨 锭 惯积窍绰 坷滚敲肺快 秦搬(thanks to minikey)
 * 
 *  
 *
 */
class DLL_GMM_API CGMM
{
public:
	CGMM(void);
	~CGMM(void);


	double InitializeGMM(int number_of_mixture, int feature_order, string name="NONAME");
	int InitializeGMM();
	
	inline double GetMean(int mixture, int feature_order);
	inline double* GetMean(int mixture);
	
	inline double GetVar(int mixture, int feature_order);
	inline double* GetVar(int mixture);
	
	inline double GetWeight(int mixture);
	inline double* GetWeight();

	inline double SetMean(int mixture, int feature_order, double value);
	inline double SetMean(int mixture, const double* value);

	inline double SetVar(int mixture, int feature_order, double value);
	inline double SetVar(int mixture, const double* value);

	inline double SetWeight(int mixture, double value);
	inline double SetWeight(const double* value);
	
	inline int GetFeatureOrder();
	inline int GetNumberofMixture();

	inline int SetName(string name);
	inline string GetName();


	double GetProbability(double *data);
	double GetProbability(float *data);
	double GetProbability(double *data, int mixture);
	double GetProbability(float *data, int mixture);

	int Training(double *data, int length, int iteration, int init_method = GMM_INIT_RANDOM);
	int Training(float *data, int length, int iteration, int init_method = GMM_INIT_RANDOM);


	double ViewLog(int iter);

	int SaveGMM(string filename, bool isAppend = false);
	static int LoadGMM(CGMM &model, string modelfilename = "");

	double GetRelativeEntropy(CGMM& targetmodel);

	CGMM& operator= (CGMM& c);

protected:
	int Release(bool clearbuffer=false);
	int EM_Initialization(double *data, int length, int init_method = GMM_INIT_RANDOM);

	/// Number of mixtures.
	int M; 

	/// Feature order.
	int d; 

	/// Name of this GMM.
	string n; 

	/// Training Iteration
	int iteration;

	/// Training Log
	double *traininglog;

	/// Model file pointer
	static ifstream *fin_model;

	///GMM parameters
	struct LAMBDA
	{
		double *weight;
		double *mean;
		double *var;
	}lambda;
};

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -