📄 frdnrl.hpp
字号:
//Header: Frdnrl.hpp
//Language: Borland C++ 3.1
//Version: 1.0
//Environ: Any
//Date: 3/1996
//Purpose: Provide a base class of forword neural netword
/*************************************************************************************
IMPORTANT INFORMATION:
In the forword network, the connet mapper matrix, also weight matrix, is used
according row to colum, for example, a three layer BP network with 4-3-1
structure have the following connect mapper matrix:
| input | hidden |out|
node-number 1 2 3 4 5 6 7 8
1 0 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0 0
3 0 0 0 0 0 0 0 0
4 0 0 0 0 0 0 0 0
5 1 1 1 1 0 0 0 0
6 1 1 1 1 0 0 0 0
7 1 1 1 1 0 0 0 0
8 0 0 0 0 1 1 1 0
*************************************************************************************/
#ifndef __FRDNRL__HPP
#define __FRDNRL__HPP
#include "nrlnet.hpp"
#include <fstream.h>
class FrdNrl : public NrlNet
{
protected:
int LayerNum; //layer's number of the network
int *LyNodeNum; //array of node number in each layer
DblArray **LayerIn; //pointer to input array of each layer
DblArray **LayerOut; //pointer to output array of each layer
long LrnNumAllow; //allow number to learn
//other private methods
int NumTrans(int l, int n); //translation for Lth layer and Nth node to the node number
int CFGLoad(); //load config file
int CFGWrite(); //write config file
int CFGLoadIn(istream&); //read in config file
int CFGWriteIn(ostream&); //write in config file
void FrdInit(int,int*,char*);
public:
//constructor
FrdNrl(void);
FrdNrl(char*); //for exist network
FrdNrl(int ln, int nn[], char *nname=NULL); //for new network
//destructor
~FrdNrl();
//other methods
double NodeOut(int l, int n){ return (*LayerOut[l-1])[n]; };
//output of Lth layer and Nth node
double NodeIn(int l, int n){ return (*LayerIn[l-1])[n]; };
//input of Lth layer and Nth node
double GetWeight(int l, int n, int ll, int nn);
//get the weight of Lth layer and Nth node to LLth layer and NNth node
void SetWeight(double w, int l, int n, int ll, int nn);
//set the weight of Lth layer and Nth node to LLth layer and NNth node
double GetConect(int l, int n, int ll, int nn);
//get the connect of Lth layer and Nth node to LLth layer and NNth node
virtual const double* Run(double *input, double *output); //network run method
virtual long Learn(double **input, double **output,int examplenum)=0;
//network learn method
void SetLrnNum(long n) { LrnNumAllow=n; };//method of leran number allowed set
int* GetStruct(int*); //struct of network
};
#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -