forked from Yancey0623/gotorch
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions_test.go
More file actions
40 lines (34 loc) · 776 Bytes
/
functions_test.go
File metadata and controls
40 lines (34 loc) · 776 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
package gotorch_test
import (
"fmt"
torch "github.com/wangkuiyi/gotorch"
)
func ExampleMMException() {
defer func() {
torch.GC()
if r := recover(); r != nil {
fmt.Println("Recovered:", r.(string)[:45])
}
torch.FinishGC()
}()
x := torch.RandN([]int64{10, 20}, true)
y := torch.RandN([]int64{200, 300}, true)
z := torch.MM(x, y)
_ = z
// Output: Recovered: size mismatch, m1: [10 x 20], m2: [200 x 300]
}
func ExampleMM() {
x := torch.RandN([]int64{10, 20}, true)
y := torch.RandN([]int64{20, 30}, true)
z := torch.MM(x, y)
_ = z
// Output:
}
func ExampleRelu() {
x := torch.RandN([]int64{10, 20}, true)
r := torch.Relu(x)
r = torch.LeakyRelu(x, 0.01)
_ = r
// TODO(shendiaomo): more tests when other function wrapper available
// Output:
}