-
Notifications
You must be signed in to change notification settings - Fork 0
/
Synapse.java
executable file
·53 lines (44 loc) · 1.24 KB
/
Synapse.java
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
import java.io.*;
public class Synapse {
//change it to private later CANTNet.write needs it
public double weight;
//change it to private later CANTNet.write needs it
public CANTNeuron fromNeuron;
//change it to private later CANTNet.write needs it
public CANTNeuron toNeuron;
private CANTNet parentNet; //undone do I actually need this
public CANTNeuron getTo () {return toNeuron; }
public double getWeight() {return weight;}
public Synapse (CANTNet net,CANTNeuron from,CANTNeuron to,double wt) {
parentNet = net;
fromNeuron = from;
toNeuron = to;
weight = wt;
}
public void clear() {
weight = 0;
}
public void setWeight(double Wt) {
double median = parentNet.getAxonalStrengthMedian();
if (parentNet.getLearningOn() > 0)
{
if (fromNeuron.isInhibitory())
{
if (Wt < ((-2*median) + 0.01))
weight = (-2*median) + 0.01;
else if (Wt > -0.01)
weight = -0.01;
else weight = Wt;
}
else // if (!fromNeuron.isInhibitory())
{
if (Wt < 0.01)
weight = 0.01;
else if (Wt > ((2*median) - 0.01))
weight = ((2*median) - 0.01);
else weight = Wt;
}
}
else weight = Wt;
}
}