-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathactivationfunction_test.go
More file actions
55 lines (44 loc) · 1.76 KB
/
activationfunction_test.go
File metadata and controls
55 lines (44 loc) · 1.76 KB
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
package gorpropplus
import (
"math"
"testing"
)
func round(num float64) int {
return int(num + math.Copysign(0.5, num))
}
func toFixed(num float64, precision int) float64 {
output := math.Pow(10, float64(precision))
return float64(round(num*output)) / output
}
func TestIperbolicTangent(t *testing.T) {
neuronValue := -0.3531139100
activatedNeuronOuput := IperbolicTangent(neuronValue)
correctActivatedNeuronOuput := -0.3391342216
if toFixed(activatedNeuronOuput, 6) != toFixed(correctActivatedNeuronOuput, 6) {
t.Fatalf("Error: the activatedNeuronOuput is %f instead of %f", activatedNeuronOuput, correctActivatedNeuronOuput)
}
}
func TestDerivateIperbolicTangent(t *testing.T) {
neuronValue := -0.7606964211
activatedNeuronOuput := DerivateIperbolicTangent(neuronValue)
correctActivatedNeuronOuput := 0.4213409550
if toFixed(activatedNeuronOuput, 6) != toFixed(correctActivatedNeuronOuput, 6) {
t.Fatalf("Error: the derivate activatedNeuronOuput is %f instead of %f", activatedNeuronOuput, correctActivatedNeuronOuput)
}
}
func TestLogistic(t *testing.T) {
neuronValue := 1.8052738837
activatedNeuronOuput := Logistic(neuronValue)
correctActivatedNeuronOuput := 0.8587897097
if toFixed(activatedNeuronOuput, 6) != toFixed(correctActivatedNeuronOuput, 6) {
t.Fatalf("Error: the activatedNeuronOuput is %f instead of %f", activatedNeuronOuput, correctActivatedNeuronOuput)
}
}
func TestDerivateLogistic(t *testing.T) {
neuronValue := 0.4640093329
activatedNeuronOuput := DerivateLogistic(neuronValue)
correctActivatedNeuronOuput := 0.2487046719
if toFixed(activatedNeuronOuput, 6) != toFixed(correctActivatedNeuronOuput, 6) {
t.Fatalf("Error: the derivate activatedNeuronOuput is %f instead of %f", activatedNeuronOuput, correctActivatedNeuronOuput)
}
}