Skip to content

Instantly share code, notes, and snippets.

@hslr4
Created February 26, 2019 18:44
Show Gist options
  • Select an option

  • Save hslr4/297e8608aae5116d2eadc157201dab69 to your computer and use it in GitHub Desktop.

Select an option

Save hslr4/297e8608aae5116d2eadc157201dab69 to your computer and use it in GitHub Desktop.
var net *deep.Neural
func init() {
net = deep.NewNeural(&deep.Config{
Inputs: 2,
Layout: []int{2, 5, 1},
Activation: deep.ActivationReLU,
Mode: deep.ModeRegression,
Weight: deep.NewUniform(0.1, 0.0),
Bias: true,
})
}
func trainModel(data training.Examples) {
optimizer := training.NewAdam(0.02, 0.9, 0.999, 1e-8)
trainer := training.NewBatchTrainer(optimizer, 1, 200, 8)
training, heldout := data.Split(0.75)
trainer.Train(net, training, heldout, 7)
}
func getCapFromModel(s, j int) int {
p := net.Predict([]float64{float64(s), float64(j)})
return int(p[0])
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment