-
-
Save hslr4/297e8608aae5116d2eadc157201dab69 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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