-
-
Notifications
You must be signed in to change notification settings - Fork 173
Expand file tree
/
Copy pathsoftmax_test.go
More file actions
43 lines (35 loc) · 783 Bytes
/
softmax_test.go
File metadata and controls
43 lines (35 loc) · 783 Bytes
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
package stats_test
import (
"fmt"
"testing"
"github.com/montanaflynn/stats"
)
func ExampleSoftMax() {
sm, _ := stats.SoftMax([]float64{3.0, 1.0, 0.2})
fmt.Println(sm)
// Output: [0.8360188027814407 0.11314284146556013 0.05083835575299916]
}
func TestSoftMaxEmptyInput(t *testing.T) {
_, err := stats.SoftMax([]float64{})
if err != stats.EmptyInputErr {
t.Errorf("Should have returned empty input error")
}
}
func TestSoftMax(t *testing.T) {
sm, err := stats.SoftMax([]float64{3.0, 1.0, 0.2})
if err != nil {
t.Error(err)
}
a := 0.8360188027814407
if sm[0] != a {
t.Errorf("%v != %v", sm[0], a)
}
a = 0.11314284146556013
if sm[1] != a {
t.Errorf("%v != %v", sm[1], a)
}
a = 0.05083835575299916
if sm[2] != a {
t.Errorf("%v != %v", sm[1], a)
}
}