-
Notifications
You must be signed in to change notification settings - Fork 0
/
neuron.h
40 lines (35 loc) · 1.1 KB
/
neuron.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
#ifndef NEURON_H
#define NEURON_H
#include <vector>
#include <cstdlib>
struct Connection {
double weight;
double deltaweight;
};
class Neuron
{
public:
Neuron(unsigned numborofoutputs);
void feedForward(const std::vector<Neuron *> prevLayer,unsigned _myIndex);
void setOutput(double val);
double getOutput();
static double transfer(double x);
static double transferderivative(double x);
void calcoutputgrad(double target);
void calchiddengrad(const std::vector<Neuron *> nextLayer);
void updateInputWeights(std::vector<Neuron *> prevLayer);
void setOutputNumber(unsigned num);
std::pair<std::vector<double>,std::vector<double>> getOutputWeight();
void setOutputWeight(std::vector<std::pair<double,double>> loaded);
static unsigned map_size;
private:
static double eta;
static double alpha;
double output;
std::vector<Connection> outputweights;
static double randomWeight(void);
double sumdow(const std::vector<Neuron *> nextLayer);
unsigned myIndex;
double gradient;
};
#endif // NEURON_H