-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEdge.h
61 lines (44 loc) · 1.2 KB
/
Edge.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
52
53
54
55
56
57
58
59
60
61
#pragma once
#include "Perceptron.h"
#include <iostream>
namespace NeNet
{
static int _counter = 0;
enum EdgeType
{
FIXED_VALUE = 0,
VARIABLE_VALUE = 1
};
class Edge
{
private:
EdgeType _type;
double _value; // output of previous perceptron
double _weight;
double _error; // this quantity is being minimalized
std::weak_ptr<Perceptron> _from;
std::weak_ptr<Perceptron> _to;
int _ID; // for debugging purposes
public:
Edge(std::shared_ptr<Perceptron> from,
std::shared_ptr<Perceptron> to,
EdgeType type)
: _value(1),
_weight(1),
_error(std::numeric_limits<int>::max()),
_from(from),
_to(to),
_type(type)
{
_ID = _counter++;
}
double getValue() { return _value; }
void setValue(double value) { _value = value; }
double getWeight() { return _weight; }
void setWeight(double weight) { _weight = weight; }
double getError() { return _error; }
void setError(double error) { _error = error; }
double getWeightedValue() { return _value * _weight; }
double getSuccessorDelta() { return _to.lock()->getDelta(); }
};
}