C++ Neural Networks and Fuzzy Logic
by Valluru B. Rao M&T Books, IDG Books Worldwide, Inc. ISBN: 1558515526 Pub Date: 06/01/95 |
Previous | Table of Contents | Next |
For our illustration run, we provided for six neurons in the input layer and five in the output layer. We used three pairs of exemplars for encoding. We used two additional input vectors, one of which is the complement of the X of an exemplar pair, after the encoding is done, to see what association will be established in these cases, or what recall will be made by the BAM network.
As expected, the complement of the Y of the exemplar is found to be associated with the complement of the X of that pair. When the second input vector is presented, however, a new pair of associated vectors is found. After the code is presented, we list the computer output also.
Listing 8.1 bamntwrk.h
//bamntwrk.h V. Rao, H. Rao //Header file for BAM network program #include <iostream.h> #include <math.h> #include <stdlib.h> #define MXSIZ 10 // determines the maximum size of the network class bmneuron { protected: int nnbr; int inn,outn; int output; int activation; int outwt[MXSIZ]; char *name; friend class network; public: bmneuron() { }; void getnrn(int,int,int,char *); }; class exemplar { protected: int xdim,ydim; int v1[MXSIZ],v2[MXSIZ]; int u1[MXSIZ],u2[MXSIZ]; friend class network; friend class mtrx; public: exemplar() { }; void getexmplr(int,int,int *,int *); void prexmplr(); void trnsfrm(); void prtrnsfrm(); }; class asscpair { protected: int xdim,ydim,idn; int v1[MXSIZ],v2[MXSIZ]; friend class network; public: asscpair() { }; void getasscpair(int,int,int); void prasscpair(); }; class potlpair { protected: int xdim,ydim; int v1[MXSIZ],v2[MXSIZ]; friend class network; public: potlpair() { }; void getpotlpair(int,int); void prpotlpair(); }; class network { public: int anmbr,bnmbr,flag,nexmplr,nasspr,ninpt; bmneuron (anrn)[MXSIZ],(bnrn)[MXSIZ]; exemplar (e)[MXSIZ]; asscpair (as)[MXSIZ]; potlpair (pp)[MXSIZ]; int outs1[MXSIZ],outs2[MXSIZ]; int mtrx1[MXSIZ][MXSIZ],mtrx2[MXSIZ][MXSIZ]; network() { }; void getnwk(int,int,int,int [][6],int [][5]); void compr1(int,int); void compr2(int,int); void prwts(); void iterate(); void findassc(int *); void asgninpt(int *); void asgnvect(int,int *,int *); void comput1(); void comput2(); void prstatus(); };
The program source file is presented as follows.
Previous | Table of Contents | Next |