static void testClassMNIST() { MNIST mnist = new MNIST(); mnist.loadTrainingSetFiles(trainingImagesFileName, trainingLabelsFileName); mnist.loadTestSetFiles(testImagesFileName, testLabelsFileName); int i, j; while (Console.ReadLine().Equals("")) { i = random.Next(60000); Console.WriteLine("trainingImages[" + i + "]:"); Console.WriteLine(mnist.trainingImages[i]); Console.WriteLine("trainingLabels[" + i + "]:"); Console.WriteLine(mnist.trainingLabels[i]); j = random.Next(10000); Console.WriteLine("testImages[" + j + "]:"); Console.WriteLine(mnist.testImages[j]); Console.WriteLine("testLabels[" + j + "]:"); Console.WriteLine(mnist.testLabels[j]); Console.WriteLine("Enter non-empty line to quit!"); } for (int k = 0; k < 60000; k++) { if (mnist.trainingLabels[k] < 0 || mnist.trainingLabels[k] > 9) { throw new Exception("testMNIST: Invalid training label. " + "trainingLabels[" + k + "]: " + mnist.trainingLabels[k]); } } Console.WriteLine("trainingLabels OK!"); for (int k = 0; k < 10000; k++) { if (mnist.testLabels[k] < 0 || mnist.testLabels[k] > 9) { throw new Exception("testMNIST: Invalid test label. " + "testLabels[" + k + "]: " + mnist.testLabels[k]); } } Console.WriteLine("testLabels OK!"); }
static void writeImage() { MNIST mnist = new MNIST(); mnist.loadTrainingSetFiles(trainingImagesFileName, trainingLabelsFileName); int i; while (Console.ReadLine().Equals("")) { i = random.Next(60000); Console.WriteLine("trainingImages[" + i + "]:"); Console.WriteLine(mnist.trainingImages[i]); Console.WriteLine("trainingLabels[" + i + "]:"); Console.WriteLine(mnist.trainingLabels[i]); Console.WriteLine("Enter non-empty line to quit!"); } }