📄 bpnet.h
字号:
#if !defined(AFX_BPNET_H__7ACF7725_EE66_11D6_AAF0_00E04F29491B__INCLUDED_)
#define AFX_BPNET_H__7ACF7725_EE66_11D6_AAF0_00E04F29491B__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// BpNet.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CBpNet window
#include "math.h"
class CMatrix
{
public:
//初始化
CMatrix();
CMatrix(CMatrix &mIn);
virtual ~CMatrix();
BOOL Create(CSize szM);
BOOL Zeros(int nRows,int nCols);
void Destroy();
//属性
int rows();
int cols();
void Display();
//操作
double operator()(int nRow,int nCol);
double operator()(int nNo);
void Set(int nRos,int nCol,double dVal);
CMatrix& operator=(CMatrix &mIn);
BOOL SetData(int nRow,int nCol,double *pData);
BOOL SetData(int nRow,int nCol,BYTE *pData);
BOOL SaveAsText(CString strPath);
public:
double Max(int &nNo);
int m_nRows;//行数
int m_nCols;//列数
double * m_pData;
};
class CBpNet : public CObject
{
public:
CBpNet();
public:
void GetFeaNN(BYTE &nH,BYTE &nV,BYTE &nL,BYTE &nR,BYTE &nS,BYTE * pData,int nDim=5);
BOOL GetFeature(CImage &ImgIn,BYTE *pFea,int &nLen);
void Serialize( CArchive& ar );
void display(CMatrix &data);
CMatrix scope(CMatrix &mData);
long lEpochs;
double dblMse;
static double dblError;
double randab(double a,double b);
void stop();
void learn();
bool SaveBpNet(CString &strNetName);
void LoadBpNet(CString &strNetName);
int Recogn(CImage &ImgIn,double &dRecVal);
int Recogn1(CImage &ImgIn,double &dRecVal);
CMatrix simulate(CMatrix &mData);
void Create(CMatrix &mInputData,CMatrix &mTarget,int iInput,int iHidden,int iOutput);
virtual ~CBpNet();
// Generated message map functions
protected:
//{{AFX_MSG(CBpNet)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_MSG
DECLARE_SERIAL(CBpNet)
public:
bool m_isOK;
void LoadPattern(CMatrix &mIn,CMatrix &mOut);
int iHidden;//隐层神经元个数
int iInput;//输入个数
int iOutput;//输出个数
protected:
CMatrix mInput;//单个样本输入数据
CMatrix mSampleInput;//全体样本输入数据
CMatrix mSampleTarget;//全体目标数据
CMatrix mHidden;//计算得到的隐层数据
CMatrix mOutput;//计算输出
CMatrix mWeighti;//输入-隐层权重
CMatrix mWeighto;//隐层-输出权重
CMatrix mChangei;//输入-隐层权重变化
CMatrix mChangeo;//隐层-输出权重变化
public:
double GetError();
CMatrix mInputNormFactor;//正规化因子,iInputx2
CMatrix mTargetNormFactor;//输出正规化因子,iOutputx2
protected:
CMatrix mThresholdi;//阙值
CMatrix mThresholdo;
CMatrix mOutputDeltas;//误差
CMatrix mHiddenDeltas;
protected:
static bool m_IsStop;
double dblMomentumFactor;
double dblLearnRate1;
double dblLearnRate2;
void backward(int iSample);
void forward(int iSample);
void normalize();//将输入输出样本数据正规化处理
private:
double dblErr;
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations iCMatrixediately before the previous line.
#endif // !defined(AFX_BPNET_H__7ACF7725_EE66_11D6_AAF0_00E04F29491B__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -