Another way we could test how well the neural network is learning is to cross-validate. The neural network could learn very well on the training data, in essence, memorizing which collections of pixels will result in a particular label. However, to check that the machine learning algorithm generalizes well, we need to show the neural network some data it's never seen before.
Here's the code to do so:
log.Printf("Start testing")
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()
testData2, err := zca(testData)
if err != nil {
log.Fatal(err)
}
visualize(testData, 10...