neurontest.cc File Reference

#include <iostream>
#include "SigmoidalNeuron.h"
#include "InputNeuron.h"
#include "UniformRNG.h"
#include <vector>
#include <cmath>

Include dependency graph for neurontest.cc:

Go to the source code of this file.

Functions

int main (void)


Function Documentation

int main ( void   ) 

Definition at line 9 of file neurontest.cc.

References SigmoidalNeuron::bipolar, UniformRNG::GetNumber(), GeneralNeuron::GetOutput(), SigmoidalNeuron::identity, iterations, SigmoidalNeuron::SetBias(), SigmoidalNeuron::SetInput(), SigmoidalNeuron::SetType(), and SigmoidalNeuron::SetWeights().

00010 {
00011         const int iterations = 100;
00012         SigmoidalNeuron TestNeuron;
00013         double testinput1, weight1;
00014         double testinput2, weight2;
00015         double bias, result;
00016         
00017         GeneralLinearCombiner::tinvector testiv;
00018         testiv.push_back(boost::shared_ptr<GeneralNeuron>(new InputNeuron(testinput1)));
00019         testiv.push_back(boost::shared_ptr<GeneralNeuron>(new InputNeuron(testinput2)));
00020         TestNeuron.SetType(SigmoidalNeuron::identity);
00021         TestNeuron.SetInput(testiv);
00022         
00023         UniformRNG Random;
00024         for (int i = 0; i < iterations; ++i)
00025         {
00026                 weight1 = Random.GetNumber();
00027                 weight2 = Random.GetNumber();
00028                 TestNeuron.SetWeights().at(0) = weight1;
00029                 TestNeuron.SetWeights().at(1) = weight2;
00030                 bias =  Random.GetNumber();
00031                 TestNeuron.SetBias(bias);
00032                 testinput1 =  Random.GetNumber();
00033                 testinput2 =  Random.GetNumber();
00034                 result = bias + weight1 * testinput1 + weight2 * testinput2;
00035                 cout << "Output: " << TestNeuron.GetOutput() << " Correct: " << result << endl;
00036         }
00037         
00038         TestNeuron.SetType(SigmoidalNeuron::bipolar);
00039         TestNeuron.SetInput(testiv);
00040         for (int i = 0; i < iterations; ++i)
00041         {
00042                 weight1 = Random.GetNumber();
00043                 weight2 = Random.GetNumber();
00044                 TestNeuron.SetWeights().at(0) = weight1;
00045                 TestNeuron.SetWeights().at(1) = weight2;
00046                 bias =  Random.GetNumber();
00047                 TestNeuron.SetBias(bias);
00048                 testinput1 =  Random.GetNumber();
00049                 testinput2 =  Random.GetNumber();
00050                 result = tanh(0.5*(bias + weight1 * testinput1 + weight2 * testinput2));
00051                 cout << "Output: " << TestNeuron.GetOutput() << " Correct: " << result << endl;
00052         }
00053         
00054 }

Here is the call graph for this function:


Generated on Thu Nov 22 14:03:18 2007 for GPLIB++ by  doxygen 1.5.1