MCPcopy Create free account
hub / github.com/CodingBeard/tfkg / main

Function main

examples/bench/main.go:21–146  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19)
20
21func main() {
22 // This is where the trained model will be saved
23 saveDir := filepath.Join("../../logs", fmt.Sprintf("bench-%d", time.Now().Unix()))
24 e := os.MkdirAll(saveDir, os.ModePerm)
25 if e != nil {
26 panic(e)
27 }
28
29 // Create a logger pointed at the save dir
30 logger, e := cblog.NewLogger(cblog.LoggerConfig{
31 LogLevel: cblog.DebugLevel,
32 Format: "%{time:2006-01-02 15:04:05.000} : %{file}:%{line} : %{message}",
33 LogToFile: true,
34 FilePath: filepath.Join(saveDir, "training.log"),
35 FilePerm: os.ModePerm,
36 LogToStdOut: true,
37 SetAsDefaultLogger: true,
38 })
39 if e != nil {
40 panic(e)
41 }
42
43 // Error handler with stack traces
44 errorHandler := cberrors.NewErrorContainer(iowriterprovider.New(logger))
45
46 // Create a new Values dataset, we can pass in values without having to read from a CSV file
47 dataset, e := data.NewValuesDataset(
48 logger,
49 errorHandler,
50 data.ValuesDatasetConfig{
51 TrainPercent: 1,
52 },
53 preprocessor.NewProcessor(
54 errorHandler,
55 "y",
56 preprocessor.ProcessorConfig{
57 Converter: preprocessor.ConvertInterfaceToInt32SliceTensor,
58 },
59 ),
60 preprocessor.NewProcessor(
61 errorHandler,
62 "floats",
63 preprocessor.ProcessorConfig{
64 Converter: preprocessor.ConvertInterfaceFloat32SliceToTensor,
65 },
66 ),
67 )
68 if e != nil {
69 errorHandler.Error(e)
70 return
71 }
72
73 var y []interface{}
74 var x []interface{}
75 // generate random input data with imbalanced classes, if class_weighting works the accuracy should be 0
76 for i := 0; i < 29000; i++ {
77 var xRow []float32
78 for j := 0; j < 1000; j++ {

Callers

nothing calls this directly

Calls 15

SetValuesMethod · 0.95
InfoFMethod · 0.95
NewValuesDatasetFunction · 0.92
NewProcessorFunction · 0.92
NewSequentialModelFunction · 0.92
InputFunction · 0.92
EmbeddingFunction · 0.92
CuDNNLSTMFunction · 0.92
DenseFunction · 0.92
AdamFunction · 0.92
SetInputShapeMethod · 0.80
SetInputLengthMethod · 0.80

Tested by

no test coverage detected