-
Notifications
You must be signed in to change notification settings - Fork 3
/
math_test.go
57 lines (53 loc) · 989 Bytes
/
math_test.go
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
package lin
import (
"testing"
"github.com/stretchr/testify/assert"
)
func TestSigmoid(t *testing.T) {
for _, tc := range []struct {
in float32
expect float32
}{
// Answers pulled from:
// https://keisan.casio.com/exec/system/15157249643425
{
in: 0,
expect: 0.5,
},
{
in: 1,
expect: 0.7310585786300048792512,
},
{
in: -1,
expect: 0.2689414213699951207488,
},
} {
got := Sigmoid(tc.in)
assert.InDelta(t, tc.expect, got, 0.0000001, "input: %v", tc.in)
}
}
func TestSigmoidDerivative(t *testing.T) {
for _, tc := range []struct {
in float32
expect float32
}{
// Answers pulled from:
// https://keisan.casio.com/exec/system/15157249643425
{
in: 0,
expect: 0.25,
},
{
in: 1,
expect: 0.1966119332414818525374,
},
{
in: -1,
expect: 0.1966119332414818525374,
},
} {
got := SigmoidDerivative(tc.in)
assert.InDelta(t, tc.expect, got, 0.0000001, "input: %v", tc.in)
}
}