2022年Art神经网络源程序 .pdf
《2022年Art神经网络源程序 .pdf》由会员分享,可在线阅读,更多相关《2022年Art神经网络源程序 .pdf(9页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、/* * * ADAPTIVE RESONANCE THEORY (ART) NETWORK * * */ #include #include #include #include #include / DEFINES #define MAXCNEURONS 75 / MAX COMPARISON LAYER NEURONS #define MAXRNEURONS 30 / MAX RECOGNITION LAYER NEURONS #define MAXPATTERNS 30 / MAX NUMBER OF PATTERNS IN A TRAINING SET #define VERBOSE
2、1 class ARTNET private: double WbMAXCNEURONSMAXRNEURONS; / Bottom up weight matrix int WtMAXRNEURONSMAXCNEURONS; / Top down weight matrixint InDataMAXPATTERNSMAXCNEURONS;/ Array of input vectors to be / presented to the network int NumPatterns; / Number of input patterns double VigilThresh; / Vigile
3、nce threshold valuedouble L; / ART training const (see text) int M; / # of neurons in C-layer int N; / # of neurons in R-layer int XVectMAXCNEURONS; / Current in vect at C-layer. int CVectMAXCNEURONS; / Output vector from C-layer int BestNeuron; / Current best R-layer Neuron int Reset; / Active when
4、 vigilence has/ disabled someone int RVectMAXCNEURONS; / Output vector from R-layer int PVectMAXCNEURONS; / WeightedOutput vector from R-layer int DisabledMAXRNEURONS; / Resets way of disqualifying neuronsint TrainedMAXRNEURONS; / To identify allocated R-Neurons void ClearPvect(); void ClearDisabled
5、(); 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 1 页,共 9 页 - - - - - - - - - void RecoPhase(); / Recognition phasevoid CompPhase(); / Comparison phasevoid SearchPhase(); / Search Phasevoid RunCompLayer(); / Calc comparison layer by 2/3 rulevoid RunRecoLayer(); / Ca
6、lc recognition layers R-vect void Rvect2Pvect(int); / Distribute winners result int Gain1(); / Comp layer gainint Gain2(); / Reco layer gain double Vigilence(); / Calc vigilence metricvoid InitWeights(); / Initialize weights void Train(); / Weight adjustment is done here public: ARTNET(void); / Cons
7、tructor/initializationsint LoadInVects(char *Fname); / load all data vectors void Run(int i); / Run net w/ ith pattern void ShowWeights(); / display top down and / bottom up weights void ShowInVect(); / Display current input pattern void ShowOutVect(); / P-vector from Reco layer(see text) ; / - / ME
8、THOD DEFINITIONS ARTNET:ARTNET() int i; L=2.0; N=MAXRNEURONS; for (i=0; iN; i+) /Set all neurons to untrained and enabled Trainedi=0; Disabledi=0; /* endfor */ int ARTNET:LoadInVects(char *Fname) FILE *PFILE; int i,j,k; PFILE = fopen(Fname,r); if (PFILE=NULL) printf(nUnable to open file %sn,Fname);
9、名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 2 页,共 9 页 - - - - - - - - - exit(0); fscanf(PFILE,%d,&NumPatterns); /How many patterns fscanf(PFILE,%d,&M); /get width of input vector fscanf(PFILE,%lf,&VigilThresh); for (i=0; iNumPatterns; i+) for (j=0; jM; j+) fscanf(
10、PFILE,%d,&k); /Read all the pattern data and. InDataij=k; / .save it for later. /* endfor */ /* endfor */ InitWeights(); return NumPatterns; int ARTNET:Gain2() int i; for (i=0; iM; i+) if (XVecti=1) return 1; /* endfor */ void ARTNET:Rvect2Pvect(int best) int i; for (i=0; iM; i+) PVecti= Wtbesti; /*
11、 endfor */ int ARTNET:Gain1() int i,G; G=Gain2(); for (i=0; iM; i+) if (RVecti=1) return 0; /* endfor */ return G; void ARTNET:RunCompLayer() int i,x; 名师资料总结 - - -精品资料欢迎下载 - - - - - - - - - - - - - - - - - - 名师精心整理 - - - - - - - 第 3 页,共 9 页 - - - - - - - - - for (i=0; i=2) CVecti=1; else CVecti=0; /
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 2022年Art神经网络源程序 2022 Art 神经网络 源程序
限制150内