-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathneuron.hpp
31 lines (29 loc) · 1.08 KB
/
neuron.hpp
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
#ifndef NEURON_HPP
#define NEURON_HPP
class neuron {
public:
neuron(unsigned numOutputs, unsigned numInputs, double learningRate, double threshold);
void setOutputVal(double val) { m_outputVal = val; }
double getOutputVal(void) { return m_outputVal; }
void feedForward(const Layer &prevLayer);
void calcDelta(const Layer &nextLayer);
void backProp(const Layer &nextLayer);
void calcOutputGradients(double targetVals);
void calcHiddenGradients(const Layer &nextLayer);
void updateInputWeights(Layer &prevLayer);
private:
static double eta; //net training rate
static double alpha; // multiplier of last weight change [momentum]
static double hiddenBiasGrads; // gradient on hidden bias
static double outputBiasGrads; // gradient on output bias
static double randomWeight(void) { return rand() / double(RAND_MAX); }
double sumDow(const Layer &nextLayer) const;
double m_outputVal;
double m_outputGrads;
double m_hiddenGrads;
double m_delta;
double m_outputBias;
unsigned m_myIndex;
double m_gradient;
};
#endif