-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathConnections.java
More file actions
44 lines (25 loc) · 906 Bytes
/
Connections.java
File metadata and controls
44 lines (25 loc) · 906 Bytes
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
package arkangel;
import java.util.Random;
//this class defines a Connection object to link any two neurons; one "from"
//which the connection starts, and one "to" which it goes
public class Connections{
Neuron_Object from;
Neuron_Object to;
double weight = 0;
//parameterized constructor which defines the from and to neurons, and randomly
//initializes weight of the connection b/w them
Connections(Neuron_Object source, Neuron_Object dest){
from = source;
to = dest;
weight = (new Random().nextDouble()-0.45);
}
//our error-correcting mechanism is gradient-descent i.e. in training phase, the
//in case of error, the weights of each connection get updated according
//to the parameter (which is the product of error and current input)
double updateWeight(double update) {
return weight-=update;
}
double getWeight() {
return weight;
}
}