Main Page   Alphabetical List   Compound List   File List   Compound Members   File Members  

Net Class Reference

#include <nkern_net.h>

List of all members.

Public Methods

 Net ()
 Net (int NumInputs, int NumOutputs, int NumHiddenLayers, int NumNeuronsPerLayer)
void CreateNet ()
void Net::ModNet (int NumInputs, int NumOutputs, int NumHiddenLayers, int NumNeuronsPerLayer)
vector< float > GetWeights ()
int GetNumberOfWeights ()
void PutWeights (vector< float > weights)
vector< float > Update (vector< float > inputs)
float Sigmoid (float activation, float response)

Private Attributes

int m_NumInputs
int m_NumOutputs
int m_NumHiddenLayers
int m_NumNeuronsPerLayer
char name [256]
vector< NeuronLayerm_vecLayers


Constructor & Destructor Documentation

Net::Net  
 

Definition at line 27 of file net.cpp.

References CreateNet, m_NumHiddenLayers, m_NumInputs, m_NumNeuronsPerLayer, and m_NumOutputs.

00027         {
00028                    m_NumInputs          = 2; //g_SimData.NumInputs;
00029                    m_NumOutputs         = 2; //g_SimData.NumOutputs;
00030                    m_NumHiddenLayers    = 2; //g_SimData.NumHiddenLayers;
00031                    m_NumNeuronsPerLayer = 3; //g_SimData.NeuronsPerHLayer;
00032 
00033                    CreateNet();
00034 
00035 }

Net::Net int    NumInputs,
int    NumOutputs,
int    NumHiddenLayers,
int    NumNeuronsPerLayer
 

Definition at line 40 of file net.cpp.

References CreateNet.

00043                                           : m_NumInputs(NumInputs),
00044                                             m_NumOutputs(NumOutputs),
00045                                             m_NumHiddenLayers(NumHiddenLayers),
00046                                             m_NumNeuronsPerLayer(NumNeuronsPerLayer)
00047 
00048 {
00049      CreateNet();
00050 }


Member Function Documentation

void Net::CreateNet  
 

Definition at line 56 of file net.cpp.

References m_NumHiddenLayers, m_NumInputs, m_NumNeuronsPerLayer, m_NumOutputs, and m_vecLayers.

Referenced by Net.

00056                    {
00057      m_vecLayers.push_back(NeuronLayer(m_NumNeuronsPerLayer, m_NumInputs));
00058      if (m_NumHiddenLayers > 1){
00059         for (int i=0; i<m_NumHiddenLayers-1; i++)
00060             m_vecLayers.push_back(NeuronLayer(m_NumNeuronsPerLayer, m_NumNeuronsPerLayer));
00061      }
00062 
00063      m_vecLayers.push_back(NeuronLayer(m_NumOutputs, m_NumNeuronsPerLayer));
00064 
00065 }

int Net::GetNumberOfWeights  
 

Definition at line 116 of file net.cpp.

References m_NumHiddenLayers, and m_vecLayers.

00116                            {
00117     int weights = 0;
00118     for (int i=0; i<m_NumHiddenLayers +1; i++){
00119         for (int j=0; j<m_vecLayers[i].m_NumNeurons; j++){
00120             for (int k=0; k<m_vecLayers[i].m_vecNeurons[j].m_NumInputs; k++)
00121                 weights++;
00122         }
00123     }
00124     return weights;
00125 }

vector< float > Net::GetWeights  
 

Definition at line 80 of file net.cpp.

References m_NumHiddenLayers, and m_vecLayers.

00080                              {
00081      vector<float> weights;
00082      for (int i=0; i<m_NumHiddenLayers + 1; i++){
00083          for (int j=0; j<m_vecLayers[j].m_NumNeurons; j++){
00084              for (int k=0; k<m_vecLayers[i].m_vecNeurons[j].m_NumInputs; k++){
00085                  weights.push_back(m_vecLayers[i].m_vecNeurons[j].m_vecWeight[k]);
00086              }
00087          }
00088      }
00089      return weights;
00090 }

void Net::Net::ModNet int    NumInputs,
int    NumOutputs,
int    NumHiddenLayers,
int    NumNeuronsPerLayer
 

void Net::PutWeights vector< float >    weights
 

Definition at line 98 of file net.cpp.

References m_NumHiddenLayers, and m_vecLayers.

00098                                          {
00099      int cWeight = 0;
00100          for (int i=0; i<m_NumHiddenLayers + 1; i++){
00101              for (int j=0; j<m_vecLayers[i].m_NumNeurons; j++){
00102                  for (int k=0; k<m_vecLayers[i].m_vecNeurons[j].m_NumInputs; k++){
00103                      m_vecLayers[i].m_vecNeurons[j].m_vecWeight[k] = weights[cWeight++];
00104                  }
00105              }
00106          }
00107      return;
00108 }

float Net::Sigmoid float    activation,
float    response
[inline]
 

Definition at line 171 of file net.cpp.

Referenced by Update.

00171                                                 {
00172       return (1 / ( 1 + exp(-netinput / response)));
00173 }

vector< float > Net::Update vector< float >    inputs
 

Definition at line 133 of file net.cpp.

References ACTIVATION_RESPONSE, BIAS, m_NumHiddenLayers, m_NumInputs, m_vecLayers, and Sigmoid.

00133                                              {
00134    vector<float> outputs;
00135    int cWeight = 0;
00136 
00137    if (inputs.size() != m_NumInputs)
00138       return outputs;
00139 
00140    for (int i=0; i<m_NumHiddenLayers +1; i++){
00141        if ( i > 0 )
00142           inputs = outputs;
00143 
00144        outputs.clear();
00145 
00146        cWeight = 0;
00147 
00148        for (int j=0; j<m_vecLayers[i].m_NumNeurons; j++){
00149            float netinput = 0.0f;
00150            int NumInputs = m_vecLayers[i].m_vecNeurons[j].m_NumInputs;
00151 
00152            for (int k=0; k<NumInputs - 1; k++){
00153                netinput += m_vecLayers[i].m_vecNeurons[j].m_vecWeight[k] * inputs[cWeight++];
00154            }
00155 
00156            netinput += m_vecLayers[i].m_vecNeurons[j].m_vecWeight[NumInputs-1] * BIAS;
00157 
00158            outputs.push_back(Sigmoid (netinput, ACTIVATION_RESPONSE));
00159 
00160            cWeight = 0;
00161 
00162        }
00163    }
00164    return outputs;
00165 }


Member Data Documentation

int Net::m_NumHiddenLayers [private]
 

Definition at line 25 of file nkern_net.h.

Referenced by CreateNet, GetNumberOfWeights, GetWeights, Net, PutWeights, and Update.

int Net::m_NumInputs [private]
 

Definition at line 23 of file nkern_net.h.

Referenced by CreateNet, Net, and Update.

int Net::m_NumNeuronsPerLayer [private]
 

Definition at line 26 of file nkern_net.h.

Referenced by CreateNet, and Net.

int Net::m_NumOutputs [private]
 

Definition at line 24 of file nkern_net.h.

Referenced by CreateNet, and Net.

vector<NeuronLayer> Net::m_vecLayers [private]
 

Definition at line 28 of file nkern_net.h.

Referenced by CreateNet, GetNumberOfWeights, GetWeights, PutWeights, and Update.

char Net::name[256] [private]
 

Definition at line 27 of file nkern_net.h.


The documentation for this class was generated from the following files:
Generated on Mon Jun 23 23:09:58 2003 for NeReK Documentation by doxygen1.2.14 written by Dimitri van Heesch, © 1997-2002