private bool TrainBatch(int batchSize, int iteration, MnistImageReader reader) { int i = 0, matches = 0; while (i < batchSize) { var(image, label) = reader.ReadImage(); // Upload image into input layer UploadImage(image); // Create expected results vector var expectedResults = new double[activations[^ 1].Length];
public int Recognize(MnistImageReader reader, int numberOfImages) { int matches = 0; for (int i = 0; i < numberOfImages; i++) { var(image, label) = reader.ReadImage(); var result = Recognize(image); var match = result == label; Console.WriteLine($"{i+1}: match={match}, in={label}, out={result}"); if (match) { matches++; } } Console.WriteLine($"RESULT: {((double)matches/(double)numberOfImages*100.0):F}% ({matches}/{numberOfImages})"); return(numberOfImages); }