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

📄 patternhw4doc.h

📁 Neural Network program for pattern classification
💻 H
字号:
// PatternHW4Doc.h : interface of the CPatternHW4Doc class
//
/////////////////////////////////////////////////////////////////////////////
#if !defined(AFX_PATTERNHW4DOC_H__C2EBF46B_7995_4CE4_BD28_7500A1BC3F26__INCLUDED_)
#define AFX_PATTERNHW4DOC_H__C2EBF46B_7995_4CE4_BD28_7500A1BC3F26__INCLUDED_

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#define MAXLAY	5
#define MAXEPOCH	500
typedef struct RegressData{
	double Data[2];
	double Response;
}RegressData;

typedef struct IrisData{
	double sepalLength;			// Sepal Length in cm
	double sepalWidth;			// Sepal Width in cm
	double petalLength;			// Petal Length in cm
	double petalWidth;			// Petal Width in cm
	double CLdata[3];			// Desired Response for each class

}IrisData;

typedef struct Layer{
	double Y[11];				// State variable for current node
	double W[11][11];			// Weight vector
	double delta[11];			// Delta = Error*Y*(1-Y)
	double var_W[11][11];		// Variation of Weight vector
	double momentum;			// Momentum alpha value
	double learning_rate;		// Learning Rate
	
	int nodes;					// Number of nodes in layer
	int layer_mode;				// The mode of Layer: INPUTMODE, HIDDENMODE, OUTPUTMODE
	Layer* prev_layer;			// Address of previous layer
}Layer;
class CPatternHW4Doc : public CDocument
{
protected: // create from serialization only
	CPatternHW4Doc();
	DECLARE_DYNCREATE(CPatternHW4Doc)

// Attributes
public:
// Operations
public:

// Overrides
	// ClassWizard generated virtual function overrides
	//{{AFX_VIRTUAL(CPatternHW4Doc)
	public:
	virtual BOOL OnNewDocument();
	virtual void Serialize(CArchive& ar);
	virtual BOOL OnOpenDocument(LPCTSTR lpszPathName);
	//}}AFX_VIRTUAL

// Implementation
public:
	void TestTrain(int hidLay, double learnRate, int hidNode, double momen, double threshold);
	double UpdataY2(Layer* current_layer);
	void TestR(int hidLay, double learnRate, int hidNode, double momen, double threshold);
	void NormalizeR(RegressData *Data);
	void MLPR(int hidLay, double learnRate, int hidNode, double momen, double th);
	void EnterRegressData(int mode);
	void Test(int hidLay, double learnRate, int hidNode, double momen, double threshold);
	void UpdateW(Layer* current_layer);
	void Backward(Layer* current_layer, Layer* next_layer);
	void Backward(Layer* current_layer, double *Error);
	void UpdateY(Layer* current_layer);
	BOOL SetInputvalue(Layer* current_layer, double *data);
	void InitMLPLayer(Layer* current_layer,int mode, int nd, double Momentum, double Leaning_rate, Layer* prev_Layer);
	void EnterData(int mode);
	void Normalize(IrisData *Data);
	void MLP(int hidLay, double learnRate, int hidNode, double momen, double th);

	RegressData TsData[225];
	RegressData TrnData[225];
	IrisData TstData[75];
	IrisData TrData[75];
	float** m_DataR;
	float** m_Data3;
	float** m_Data2;
	float** m_Data1;
	int FileMode;
	LONG m_dim;
	LONG m_nData;
	double Test_Result[75][3];		// each problem use as output layer 
	double Test_ResultR[225];
	double m_SSE[MAXEPOCH];

	Layer	HiddenLayer[MAXLAY];
	Layer	InputLayer;
	Layer	OutputLayer;

	virtual ~CPatternHW4Doc();
#ifdef _DEBUG
	virtual void AssertValid() const;
	virtual void Dump(CDumpContext& dc) const;
#endif

protected:

// Generated message map functions
protected:
	//{{AFX_MSG(CPatternHW4Doc)
	afx_msg void OnRegressinput();
	//}}AFX_MSG
	DECLARE_MESSAGE_MAP()
};

/////////////////////////////////////////////////////////////////////////////

//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.

#endif // !defined(AFX_PATTERNHW4DOC_H__C2EBF46B_7995_4CE4_BD28_7500A1BC3F26__INCLUDED_)

⌨️ 快捷键说明

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