1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- /*
- * MIT License
- *
- * Copyright (c) 2019 Alexey Edelev <semlanik@gmail.com>
- *
- * This file is part of NeuralNetwork project https://git.semlanik.org/semlanik/NeuralNetwork
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy of this
- * software and associated documentation files (the "Software"), to deal in the Software
- * without restriction, including without limitation the rights to use, copy, modify,
- * merge, publish, distribute, sublicense, and/or sell copies of the Software, and
- * to permit persons to whom the Software is furnished to do so, subject to the following
- * conditions:
- *
- * The above copyright notice and this permission notice shall be included in all copies
- * or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
- * INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR
- * PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE
- * FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
- * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
- * DEALINGS IN THE SOFTWARE.
- */
- package main
- import (
- "git.semlanik.org/semlanik/NeuralNetwork/neuralnetwork"
- "git.semlanik.org/semlanik/NeuralNetwork/neuralnetwork/gradients"
- )
- func main() {
- rc := NewRemoteControl()
- sizes := []int{13, 8, 12, 3}
- nn, _ := neuralnetwork.NewNeuralNetwork(sizes, gradients.NewRPropInitializer(gradients.RPropConfig{
- NuPlus: 1.2,
- NuMinus: 0.5,
- DeltaMax: 50.0,
- DeltaMin: 0.000001,
- }))
- nn.SetStateWatcher(rc)
- rc.RunServices()
- // inFile, err := os.Open("./networkstate")
- // if err != nil {
- // log.Fatal(err)
- // }
- // defer inFile.Close()
- // nn.LoadState(inFile)
- // nn, _ := neuralnetwork.NewNeuralNetwork(sizes, neuralnetwork.NewBackPropInitializer(0.1))
- // for i := 0; i < nn.Count; i++ {
- // if i > 0 {
- // fmt.Printf("Weights before:\n%v\n\n", mat.Formatted(nn.Weights[i], mat.Prefix(""), mat.Excerpt(0)))
- // fmt.Printf("Biases before:\n%v\n\n", mat.Formatted(nn.Biases[i], mat.Prefix(""), mat.Excerpt(0)))
- // fmt.Printf("Z before:\n%v\n\n", mat.Formatted(nn.Z[i], mat.Prefix(""), mat.Excerpt(0)))
- // }
- // fmt.Printf("A before:\n%v\n\n", mat.Formatted(nn.A[i], mat.Prefix(""), mat.Excerpt(0)))
- // }
- // nn = &neuralnetwork.NeuralNetwork{}
- // inFile, err := os.Open("./data")
- // if err != nil {
- // log.Fatal(err)
- // }
- // defer inFile.Close()
- // nn.LoadState(inFile)
- // inFile.Close()
- // failCount = 0
- // training.Reset()
- // for training.NextValidator() {
- // dataSet, expect := training.GetValidator()
- // index, _ := nn.Predict(dataSet)
- // if expect.At(index, 0) != 1.0 {
- // failCount++
- // // fmt.Printf("Fail: %v, %v\n\n", training.ValidationIndex(), expect.At(index, 0))
- // }
- // }
- // fmt.Printf("Fail count: %v\n\n", failCount)
- }
|