|
@@ -39,38 +39,40 @@ func main() {
|
|
|
// fmt.Printf("A before:\n%v\n\n", mat.Formatted(nn.A[i], mat.Prefix(""), mat.Excerpt(0)))
|
|
|
// }
|
|
|
|
|
|
- // teacher := teach.NewMNISTReader("./minst.data", "./mnist.labels")
|
|
|
- teacher := teach.NewTextDataReader("wine.data", 7)
|
|
|
- nn.Teach(teacher, 1000)
|
|
|
+ go func() {
|
|
|
+ // teacher := teach.NewMNISTReader("./minst.data", "./mnist.labels")
|
|
|
+ teacher := teach.NewTextDataReader("wine.data", 7)
|
|
|
+ nn.Teach(teacher, 1000)
|
|
|
|
|
|
- // for i := 0; i < nn.Count; i++ {
|
|
|
- // if i > 0 {
|
|
|
- // fmt.Printf("Weights after:\n%v\n\n", mat.Formatted(nn.Weights[i], mat.Prefix(""), mat.Excerpt(0)))
|
|
|
- // fmt.Printf("Biases after:\n%v\n\n", mat.Formatted(nn.Biases[i], mat.Prefix(""), mat.Excerpt(0)))
|
|
|
- // fmt.Printf("Z after:\n%v\n\n", mat.Formatted(nn.Z[i], mat.Prefix(""), mat.Excerpt(0)))
|
|
|
- // }
|
|
|
- // fmt.Printf("A after:\n%v\n\n", mat.Formatted(nn.A[i], mat.Prefix(""), mat.Excerpt(0)))
|
|
|
- // }
|
|
|
+ // for i := 0; i < nn.Count; i++ {
|
|
|
+ // if i > 0 {
|
|
|
+ // fmt.Printf("Weights after:\n%v\n\n", mat.Formatted(nn.Weights[i], mat.Prefix(""), mat.Excerpt(0)))
|
|
|
+ // fmt.Printf("Biases after:\n%v\n\n", mat.Formatted(nn.Biases[i], mat.Prefix(""), mat.Excerpt(0)))
|
|
|
+ // fmt.Printf("Z after:\n%v\n\n", mat.Formatted(nn.Z[i], mat.Prefix(""), mat.Excerpt(0)))
|
|
|
+ // }
|
|
|
+ // fmt.Printf("A after:\n%v\n\n", mat.Formatted(nn.A[i], mat.Prefix(""), mat.Excerpt(0)))
|
|
|
+ // }
|
|
|
|
|
|
- outFile, err := os.OpenFile("./data", os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0666)
|
|
|
- if err != nil {
|
|
|
- log.Fatal(err)
|
|
|
- }
|
|
|
- defer outFile.Close()
|
|
|
- nn.SaveState(outFile)
|
|
|
- outFile.Close()
|
|
|
+ outFile, err := os.OpenFile("./data", os.O_CREATE|os.O_TRUNC|os.O_WRONLY, 0666)
|
|
|
+ if err != nil {
|
|
|
+ log.Fatal(err)
|
|
|
+ }
|
|
|
+ defer outFile.Close()
|
|
|
+ nn.SaveState(outFile)
|
|
|
+ outFile.Close()
|
|
|
|
|
|
- failCount := 0
|
|
|
- teacher.Reset()
|
|
|
- for teacher.NextValidator() {
|
|
|
- dataSet, expect := teacher.GetValidator()
|
|
|
- index, _ := nn.Predict(dataSet)
|
|
|
- if expect.At(index, 0) != 1.0 {
|
|
|
- failCount++
|
|
|
- // fmt.Printf("Fail: %v, %v\n\n", teacher.ValidationIndex(), expect.At(index, 0))
|
|
|
+ failCount := 0
|
|
|
+ teacher.Reset()
|
|
|
+ for teacher.NextValidator() {
|
|
|
+ dataSet, expect := teacher.GetValidator()
|
|
|
+ index, _ := nn.Predict(dataSet)
|
|
|
+ if expect.At(index, 0) != 1.0 {
|
|
|
+ failCount++
|
|
|
+ // fmt.Printf("Fail: %v, %v\n\n", teacher.ValidationIndex(), expect.At(index, 0))
|
|
|
+ }
|
|
|
}
|
|
|
- }
|
|
|
- fmt.Printf("Fail count: %v\n\n", failCount)
|
|
|
+ fmt.Printf("Fail count: %v\n\n", failCount)
|
|
|
+ }()
|
|
|
|
|
|
// nn = &neuralnetwork.NeuralNetwork{}
|
|
|
// inFile, err := os.Open("./data")
|
|
@@ -93,4 +95,5 @@ func main() {
|
|
|
// }
|
|
|
|
|
|
// fmt.Printf("Fail count: %v\n\n", failCount)
|
|
|
+ rc.Run()
|
|
|
}
|