-
Notifications
You must be signed in to change notification settings - Fork 16
/
main.go
57 lines (47 loc) · 1.1 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/go-ctr/example/movielens"
"github.com/auxten/go-ctr/model/mlp"
nn "github.com/auxten/go-ctr/nn/neural_network"
rcmd "github.com/auxten/go-ctr/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)
}