neuron.h
来自「神经网络中的多层感知器的BP(反向传播)学习算法」· C头文件 代码 · 共 67 行
H
67 行
#if _MSC_VER > 1000
#pragma once
#endif /* _MSC_VER */
typedef vector<double> DVec;
#define P_A 1.7159
#define P_B (2.0 / 3.0)
#define P_E 0.7159
class NeuralLayer
{
public:
NeuralLayer(int iNeuronNumber, double dbLearnRate = 0.0,
double dbActiveLvl = 1.0, double dbMomentum = 0.0);
~NeuralLayer();
void setLeftLayer(NeuralLayer *pLeftLayer);
void setRightLayer(NeuralLayer *pRightLayer);
NeuralLayer * getLeftLayer() { return m_pLeftLayer; }
NeuralLayer * getRightLayer() { return m_pRightLayer; }
/* get the output vector calculate last time */
void active(DVec& vecOutputs);
void active(DVec &vecInputs, DVec& vecOutputs);
void learn(DVec &vecInputs, DVec& vecFeedBack);
int getNeuronNum();
double getB(int j);
double getWeight(int i, int j);
int getActiveStep();
private:
int m_iActiveStep;
DVec m_vecActives;
int m_iNeuronNum;
double m_dbLearnRate;
double m_dbActiveLvl;
double m_dbMomentum;
DMatrix *m_pDeltaWeights;
DMatrix *m_pWeightsMatrix;
NeuralLayer *m_pLeftLayer;
NeuralLayer *m_pRightLayer;
};
class NeuralNetwork
{
public:
NeuralNetwork(int iInputSize);
~NeuralNetwork();
void appendLayer(int iNeuronNumber, double dbLearnRate,
double dbActiveLvl, double dbMomentum);
void active(DVec &vecInputs, DVec& vecOutputs);
void learn(DVec &vecInputs, DVec& vecFeedBack);
/* return the w(i, j), and the j is in the layer which iLayerIndex indicated */
double getWeight(int iLayerIndex, int i, int j);
double getB(int iLayerIndex, int j);
private:
NeuralLayer *m_pInputLayer;
NeuralLayer *m_pOutputLayer;
int m_iLayerNum;
};
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?