📄 inputwnd.h
字号:
#if !defined(AFX_INPUTWND_H__6B4F797F_1BBB_415E_8D14_FAF2EEF3152C__INCLUDED_)
#define AFX_INPUTWND_H__6B4F797F_1BBB_415E_8D14_FAF2EEF3152C__INCLUDED_
#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000
// InputWnd.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CInputWnd window
#define LEN 10 ///
#define LENF 10.0
#define N LEN*LEN //输入层节点数
#define M 5//M为隐层的节点数
#define P 10 //P输出层的节点数
#define FX(x) 1/(1+exp(-x)) //特征函数
#define DFX(x) FX(x)*(1-FX(x)) //特征函数的导数
#define A 0.07 //学习系数
#define precision 0.4 //精度
//返回结构体
typedef struct {
int result;
float error;
}RESULT,*PRESULT;
typedef struct {
BYTE Figure;//识别的数字
int input[LEN*LEN];//输入样本
int output[P];
bool simpling; //用来判断是否被训练过
}E,*PE;//用来存储识别信息的结构
//权值结构体
typedef struct{
float v[N][M];
float w[M][P];
}WEIGHT,*PWEIGHT;
//用来文件输入输出的结构体
typedef struct{
E e[10];
WEIGHT WE;
}DATA,*PDATA; ///
class CInputWnd : public CWnd
{
DECLARE_DYNCREATE(CInputWnd)
// Construction
public:
CInputWnd();
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CInputWnd)
public:
virtual void OnFinalRelease();
//}}AFX_VIRTUAL
// Implementation
public:
int Training(int index);
bool Initialization(void);
RESULT Identification(void);
bool GetInput(int index);
bool DrawInputWnd(CPaintDC *pDC);
bool ClearInput(void);
E e[10]; //存储10个样本的输入和输出
// 背景画刷
CBrush m_brBack;
CBrush m_brSquare;
CPen m_hPen;
CRect m_rectThis;
CRect m_rectArray[LEN][LEN];
int m_bArray[LEN][LEN];
//权值
WEIGHT WE;
bool m_bInitDraw;
bool m_bTrain;
// 关联信息文件
HANDLE m_hFile;
// 给输入的矩阵清零,用来下次输入
BYTE m_InputArray[LEN][LEN];
virtual ~CInputWnd();
// Generated message map functions
protected:
//{{AFX_MSG(CInputWnd)
afx_msg void OnPaint();
afx_msg void OnLButtonDown(UINT nFlags, CPoint point);
afx_msg void OnMouseMove(UINT nFlags, CPoint point);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
DECLARE_OLECREATE(CInputWnd) ////
// Generated OLE dispatch map functions
//{{AFX_DISPATCH(CInputWnd)
// NOTE - the ClassWizard will add and remove member functions here.
//}}AFX_DISPATCH
DECLARE_DISPATCH_MAP() ////
DECLARE_INTERFACE_MAP() ////
private:
void InitWeight(void);
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Visual C++ will insert additional declarations immediately before the previous line.
#endif // !defined(AFX_INPUTWND_H__6B4F797F_1BBB_415E_8D14_FAF2EEF3152C__INCLUDED_)
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -