-
Notifications
You must be signed in to change notification settings - Fork 0
/
CANTNeuronFastBind.java
executable file
·60 lines (53 loc) · 1.72 KB
/
CANTNeuronFastBind.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
54
55
56
57
58
59
60
//This neuron will have fast bind synapses.
//The fast bind synapses will just increase or decrease by the
//learning rate, but also loose weight each time they don't fire.
public class CANTNeuronFastBind extends CANTNeuron {
public CANTNeuronFastBind(int neuronID, CANTNet net) {
super(neuronID, net);
}
public CANTNeuronFastBind(int neuronID, CANTNet net, double weightChange) {
super(neuronID, net);
fastBindWeightChange = weightChange;
}
public CANTNeuronFastBind(int neuronID ,CANTNet net, double weightChange,
int synapsesPerNeuron) {
super(neuronID,net,synapsesPerNeuron);
fastBindWeightChange = weightChange;
}
private double fastBindWeightChange = 0.004;
public void fastLearn() {
double weight = 0.0;
if (getFired() && (!getInhibitory()))
//System.out.println("fastLearn " + id);
for (int synapseIndex=0;synapseIndex<getCurrentSynapses();synapseIndex++)
{
CANTNeuron toNeuron = synapses[synapseIndex].getTo();
if (toNeuron.getFired())
{
weight = synapses[synapseIndex].getWeight();
weight += parentNet.getLearningRate();
if (weight > 1.0) weight = 1.0;
synapses[synapseIndex].setWeight(weight);
}
}
//here's where the weight slowly fades
else //not fired
{
for (int synapseIndex = 0; synapseIndex < getCurrentSynapses(); synapseIndex++)
{
weight = synapses[synapseIndex].getWeight();
if (isInhibitory())
{
weight += fastBindWeightChange;
if (weight > 0) weight = -.001;
}
else
{
weight -= fastBindWeightChange;
if (weight < 0) weight = .001;
}
synapses[synapseIndex].setWeight(weight);
}
}
}
}