-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
51 lines (44 loc) · 978 Bytes
/
main.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
package main
import (
"fmt"
"os"
"github.com/MagnusChase03/GoML/ml"
)
func main() {
n, err := ml.NewFFNN([]int{3, 2, 1});
if err != nil {
fmt.Fprintf(os.Stderr, "%v", err);
return;
}
inputs := [][]float64{
{0, 0, 0},
{0, 1, 0},
{0, 1, 1},
{1, 0, 0},
{1, 0, 1},
{1, 1, 1},
};
targets := [][]float64{
{0},
{1},
{0},
{1},
{0},
{1},
};
n.Train(inputs, targets, 0.01, 100, 2);
outputs, err := n.Forward([][]float64{{1, 1, 0}, {0, 0, 1}});
if err != nil {
fmt.Fprintf(os.Stderr, "%v", err);
return;
}
fmt.Printf("%v\n", outputs);
n.Save("./model.json")
/*n2, err := ml.LoadFFNN("./model.json");
if err != nil {
fmt.Fprintf(os.Stderr, "%v", err);
return;
}
fmt.Printf("%v\n", n.Layers[0].Weights);
fmt.Printf("%v\n", n2.Layers[0].Weights);*/
}