Newer
Older
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
package cz.vsb.mro0010.neuralnetworks;
public class SigmoidalNeuron extends Neuron {
private float error; //delta
private float slope; //lambda
public void setSlope(float slope) {
this.slope = slope;
}
public SigmoidalNeuron(float slope) {
this.slope = slope;
this.error = 0;
}
@Override
public void transfer() {
float z = this.getPotential();
float y = (float) (1.0/(1.0 + Math.exp(-slope*z)));
this.setState(y);
}
public float getSlope() {
return slope;
}
public float getError() {
return error;
}
public void setError(float error) {
this.error = error;
}
public static void main(String args[]) {
SigmoidalNeuron neuron = new SigmoidalNeuron((float)0.5);
for (int i = -10; i <= 10; i++) {
neuron.initialize();
neuron.adjustPotential(i);
neuron.transfer();
System.out.println(neuron.getState());
}
}
}