📄 neuronetwork.h
字号:
//#if !defined(AFX_IGPC_NEURONETWORK_H_)
//#define AFX_IGPC_NEURONETWORK_H_
#define NEURONET_FUNCTYPE_LINEAR 0
#define NEURONET_FUNCTYPE_SIGMOID 1
#define NEURONET_FUNCTYPE_WAVELET 2
class CNeuroNet;
class CNeuron : public CObject
{
private:
protected:
int m_iLayerNo; //the layer index of this neuron
int m_iWeightNum; //number of weights of this neuron
int m_iFunType; //function type
double* m_pWeights; //weight array
double m_dThreshold; //threshold
int m_iNo; //index of this neuron in its layer
CNeuroNet* m_pNet;
double m_dError; //backward error
public:
double m_dInputSum;
double m_dOutput;
CNeuron(CNeuroNet* pNet, int iLayerNo, int iNo, double* pInitWeights, double dInitThreshold);
CNeuron();
~CNeuron();
void Initialize(CNeuroNet* pNet, int iLayerNo, int iNo, double* pInitWeights, double dInitThreshold);
void CalcInputSum();
void CalcOutput();
BOOL AdjustWeights();
};
//BP network
class CNeuroNet : public CObject
{
private:
protected:
double* m_pInput;
public:
CNeuron** m_Layers; //2-D array point to each neuron
int* m_pLayNodNum; //each layer's neuron number
int m_iLayNum; //network's layer number
int m_iMidLayFun; //function of middle layer neurons
int m_iOutLayFun; //function of output layer neurons
double m_dDelta; //learning factor
double* m_pExpOutput; //expected output
CNeuroNet();
CNeuroNet(int* pLayNodNum, int iLayNum, int iMidLayFun, int iOutLayFun, double dDelta);
~CNeuroNet();
void GenerateInitWeights(double* pWeights, int iWeightNum);
void SetInput(double* pInputVector);
void SetExpOutput(double* pExpOutputVector);
BOOL Train(int iTrainTimes);
BOOL TrainOneTime();
void ForwardCalc();
BOOL BackwardCalc();
void GetOutput(double* pOutputVector);
};
//交互传播网络
class CNeuronIT : public CNeuron
{
private:
protected:
public:
BOOL AdjustWeights();
BOOL NormalizeWeight();
double CalcDistance();
};
class CNeuroNetIT : public CNeuroNet
{
private:
protected:
public:
//CNeuronIT** m_Layers; //2-D array point to each neuron
//CNeuroNetIT();
CNeuroNetIT(int iInLayNodNum, int iOutLayNodNum, double dDelta);
~CNeuroNetIT();
BOOL Train(int iTrainTimes);
BOOL TrainOneTime();
int GetWinNeuron();
BOOL NormalizeVector(double* pVector, int iSize);
};
// #endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -