Reoccurring outputs

So, what keeps happening is i get the same output every single time for the network.GetOutputValue(). My guess would be that there has to be a problem with the calculation since it outputs it correctly the first time but outputs the same number every other time. Here is the input:
this is the description.
3 30 Pass
1 12 Run
4 10 Pass
2 4 Pass

Here is the output i get:
0.75 0.3 0.942474
0.25 0.12 0.942474
0.99 0.1 0.942474
0.5 0.04 0.942474

Here is the output i should get:
0.75 0.3 0.942474
0.25 0.12 0.819178
0.99 0.1 0.949462
0.5 0.04 0.850639


What is it that I am doing wrong?
ANN.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#include <iostream>
#include <vector>
#include <cmath>
#include "ANN.h"
using namespace std;

const int NUM_HIDDEN_NEURONS = 3;


//*****************************************************************************


void Neuron::SetWeights(int n) {
  weights.clear();
  for (int k = 0; k < n; k++)
    weights.push_back(0.5);
  return;
}


//*****************************************************************************


void Neuron::PrintWeights() {
  cout << "weights: ";
  for (int k = 0; k < weights.size(); k++)
    cout << weights[k] << " ";
  cout << endl << endl;
  return;
}


//*****************************************************************************


void ANN::JustDoIt() {
  hidden.SetWeights(NUM_HIDDEN_NEURONS);
  output.SetWeights(NUM_HIDDEN_NEURONS);
  output.PrintWeights();
}


//*****************************************************************************


void HiddenNeuron::SetNeuronData(double down, double yards , int i){

  theNeuron = down + yards;
  theNeuron = theNeuron * weights[i];
  theNeuron = theNeuron - theNeuron - theNeuron;
  theNeuron = 1 / (1 + pow(2.71828, theNeuron));
  neurons.push_back(theNeuron);
}


//*****************************************************************************


void OutputNeuron::SetNeuronData(HiddenNeuron neurons){
  double value;
theNeuron = 0;
  for(int i = 0; i < NUM_HIDDEN_NEURONS; ++i){// begin for loop
    value = neurons.GetNeuronData(i);
    theNeuron = theNeuron + (value * weights[i]);
  }//end for loop
}


//*****************************************************************************


double HiddenNeuron::GetNeuronData(int i) const{
  return neurons[i];
}


//*****************************************************************************


double OutputNeuron::GetNeuronData() const{
  return theNeuron;
}


//*****************************************************************************


double ANN::GetOutputValue() const{
  return output.GetNeuronData();
}


//*****************************************************************************

void ANN::SetData(double down, double yards){
  for(int i = 0; i < NUM_HIDDEN_NEURONS; ++i)
    hidden.SetNeuronData(down, yards, i);
  output.SetNeuronData(hidden);
}


ANN.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#ifndef ANN_H
#define ANN_H
#include <iostream>
#include <vector>
#include "TrainData.h"
using namespace std;




class Neuron {
  protected:
    vector<double> weights; //The weights of the neurons
    double theNeuron;       //the calculated neuron
  public:
    void PrintWeights();    //function that Print the weights
    void SetWeights(int n); //function that sets the weights
};



class HiddenNeuron : public Neuron {
  private:
      vector<double> neurons; //vector of calculated neurons
  public:
    void SetNeuronData(double down, double pass, int i); //sets the neuron data
    double GetNeuronData(int i) const; //gets the neuron data
};



class OutputNeuron : public Neuron {
  public:
    void SetNeuronData(HiddenNeuron neurons);//sets the neuron data
    double GetNeuronData() const;//gets the neuron data
};



class ANN {
  private:
    HiddenNeuron hidden; // the hidden neurons
    OutputNeuron output; // the output neuron
  public:
    double GetOutputValue() const; // function that gets the outputneuron value
    void JustDoIt(); // function that runs parts of the hidden neuron
    void SetData(double down, double yards); //function that calls setneuron function

};
#endif


football.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46

//*****************************************************************************


#include <iostream>
#include <fstream>
#include <string>
#include "TrainData.h"
#include "ANN.h"
using namespace std;


//*****************************************************************************


int main()
{
  ANN network;                 // the Neural network
  TrainingSet footballData;    // the football training set
  string fileName;
  int i;                       // a counter variable
  TrainingEntry entry;         // training entry variable
  double down;                 // a down variable
  double yards;                // a yards variable

    cout << "Enter the name of the file with all of the training data." << endl
    cin >> fileName;

  footballData.OpenFile(fileName);

  footballData.SetEntry();

 cout << endl << footballData.GetDescription() << endl;
  network.JustDoIt();
  for(i = 0; i < footballData.GetNumberOfEntries(); i++)
  {
    entry = footballData.GetTrainingEntries(i);
    yards = entry.GetNormalizedYTG();
    down = entry.GetNormalizedDown();
    network.SetData(down, yards);
    cout << down << " " << yards << " " << network.GetOutputValue() << endl;
  }// end for

  return 0;
}
Topic archived. No new replies allowed.