123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687 |
- /*
- * 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"
- "git.semlanik.org/semlanik/NeuralNetwork/remotecontrol"
- )
- func main() {
- rc := remotecontrol.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.Run()
- // 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)
- }
|