Of course we'd have to test our neural network.
First we load up the testing data:
testImgs, err := readImageFile(os.Open("t10k-images.idx3-ubyte"))if err != nil { log.Fatal(err)}testlabels, err := readLabelFile(os.Open("t10k-labels.idx1-ubyte")) if err != nil { log.Fatal(err) }testData := prepareX(testImgs)testLbl := prepareY(testlabels)shape := testData.Shape()visualize(testData, 10, 10, "testData.png")
In the last line, we visualize the test data to ensure that we do indeed have the correct dataset:
Then we have the main testing loop. Do observe that it's extremely similar to the training loop - because it's the same neural network! ...