-
Notifications
You must be signed in to change notification settings - Fork 1
/
Neuron.h
35 lines (28 loc) · 1.08 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
#pragma once
#include "connection.h"
#include <vector>
class Neuron;
using Layer = std::vector<Neuron>;
class Neuron
{
public:
Neuron(size_t num_outputs, size_t my_index);
double GetOutputVal(void) const;
void SetOutputVal(double val);
void FeedFrom(const Layer &prev_layer);
void CalcOutputGradients(double target_val);
void CalcHiddenGradients(Layer &next_layer);
void UpdateInputWeights(Layer &prev_layer);
std::vector<Connection>& GetOutputWeightsRef();
const std::vector<Connection>& GetOutputWeightsRef() const;
private:
size_t my_index_;
double output_val_;
double gradient_;
std::vector<Connection> output_weights_;
static double TransferFunction(double x);
static double TransferFunctionDerivative(double x);
static double RandomWeight(void);
static constexpr double eta_ = 0.15; //domain [0.0, 1.0] overall net training rate
static constexpr double alpha_ = 0.3; //domain [0.0, n] multiplier of last weight change (momentum) (can be above 1 it appears, as it is from [0,n], not [0,1], according to the tutorial)
};