-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNN.h
51 lines (44 loc) · 958 Bytes
/
NN.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 NN_H
#define NN_H
#include<vector>
#include<cmath>
#include<cassert>
#include<iostream>
using namespace std;
class Neuron;
typedef vector<Neuron> Layer;
class connection
{
public:
double weight;
double deltaweight;
void setDW(double dw)
{
deltaweight = dw;
}
};
class Neuron
{
public:
Neuron(unsigned numOutputs, unsigned myIndex);
void feedForward(Layer &prevLayer);
double getOutputVal();
void setOutputVal(double n);
void calcHiddenGradients(const Layer &nextLayer);
void calcOutputGradients(double targetVal);
void updateInputWeights(Layer &prevLayer);
void NaivelyUpdateWeights();
double eta;
double alpha;
vector <connection> m_outputWeights;
int getIndex();
private:
double m_gradient;
double m_outputVal;
static double randomWeight();
unsigned m_myIndex;
double sumDOW(const Layer &nextLayer) const;
static double transferFunctionDerivative(double x);
static double transferFunction(double x);
};
#endif