forked from auxten/go-ctr
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
57 lines (47 loc) · 1.11 KB
/
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
52
53
54
55
56
57
package main
import (
"context"
"embed"
"flag"
"github.com/auxten/edgeRec/example/movielens"
"github.com/auxten/edgeRec/model/mlp"
nn "github.com/auxten/edgeRec/nn/neural_network"
rcmd "github.com/auxten/edgeRec/recommend"
log "github.com/sirupsen/logrus"
)
//go:embed frontend/website/*
var f embed.FS
var verFlag = flag.Bool("v", false, "show binary version")
var Version = "unknown-version"
var Commit = "unknown-commit"
func main() {
flag.Parse()
if *verFlag {
log.Println("Version: ", Version)
log.Println("Commit: ", Commit)
return
}
var (
recSys = &movielens.MovielensRec{
DataPath: "movielens.db",
SampleCnt: 80000,
}
model rcmd.Predictor
err error
)
log.SetLevel(log.DebugLevel)
fiter := nn.NewMLPClassifier(
[]int{100},
"relu", "adam", 1e-5,
)
fiter.Verbose = true
fiter.MaxIter = 20
// fiter.LearningRate = "adaptive"
// fiter.LearningRateInit = .0025
trainCtx := context.Background()
model, err = rcmd.Train(trainCtx, recSys, &mlp.SimpleMlpFitWrap{Model: fiter})
if err != nil {
log.Fatal(err)
}
rcmd.StartHttpApi(model, "/api/v1/recommend", ":8080", &f)
}