/// <summary> /// Print out epoch sessions /// </summary> /// <param name="nn">neural network</param> /// <param name="data">whole input data</param> /// <param name="labels">whole labels</param> /// <param name="epochs">number of epochs</param> /// <param name="curEpoch">current epoch</param> /// <param name="index">current data index</param> public static void trainResult(NeuralNetwork <T> nn, double[][] data, T[] labels, int curEpoch, int batchSize, NeuralNetwork.CustomTextBox aiTextBox) { int success = 0; for (int batchIndex = 0; batchIndex < batchSize; batchIndex++) { if (labels[batchIndex].Equals(nn.determine(data[batchIndex]))) { success++; } } // edge case to be implemented Console.WriteLine("Epoch " + curEpoch + ": " + success + " / " + batchSize); if (aiTextBox.Lines.Length == 6) { NeuralNetwork.CustomTextBox temp = new NeuralNetwork.CustomTextBox(); for (int i = 1; i < aiTextBox.Lines.Length; i++) { temp.Text += aiTextBox.Lines[i] + "\n"; } temp.Text += "Epoch " + curEpoch + ": " + success + " / " + batchSize; aiTextBox.Invoke(new Action(() => { aiTextBox.Text = temp.Text; })); } else { aiTextBox.Invoke(new Action(() => { aiTextBox.Text += "\nEpoch " + curEpoch + ": " + success + " / " + batchSize; })); } }
/// <summary> /// Write message to AI Text Box /// </summary> /// <param name="message">Message</param> /// <param name="aiTextBox">AI text box</param> public static void WriteToAITextBox(String message, NeuralNetwork.CustomTextBox aiTextBox) { if (aiTextBox.Lines.Length == 6) { NeuralNetwork.CustomTextBox temp = new NeuralNetwork.CustomTextBox(); for (int i = 1; i < aiTextBox.Lines.Length; i++) { temp.Text += aiTextBox.Lines[i] + "\n"; } temp.Text += message; aiTextBox.Invoke(new Action(() => { aiTextBox.Text = temp.Text; })); } else { aiTextBox.Invoke(new Action(() => { aiTextBox.Text += message; })); } }